Began project refactoring.
This commit is contained in:
0
api/model/__init__.py
Normal file
0
api/model/__init__.py
Normal file
28
api/model/accounts.py
Normal file
28
api/model/accounts.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""
|
||||
This file is part of Accountant.
|
||||
|
||||
Accountant is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Foobar is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from app import app
|
||||
from app import db
|
||||
|
||||
class Account(db.Model):
|
||||
id = db.Column(db.Integer, primary_key = True)
|
||||
name = db.Column(db.String(200), nullable = False)
|
||||
authorized_overdraft = db.Column(db.Integer, nullable = True, default = 0)
|
||||
|
||||
def __init__(self, name, authorized_overdraft):
|
||||
self.name = name
|
||||
self.authorized_overdraft = authorized_overdraft
|
||||
|
49
api/model/entries.py
Normal file
49
api/model/entries.py
Normal file
@ -0,0 +1,49 @@
|
||||
"""
|
||||
This file is part of Accountant.
|
||||
|
||||
Accountant is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Foobar is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from app import app
|
||||
from app import db
|
||||
|
||||
from api.model.accounts import Account
|
||||
from api.model.scheduled_operations import ScheduledOperation
|
||||
|
||||
from sqlalchemy import func, desc
|
||||
from sqlalchemy.orm import column_property
|
||||
from sqlalchemy.sql import func, select
|
||||
|
||||
class Entry(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
pointed = db.Column(db.Boolean, nullable = False, default = False)
|
||||
operation_date = db.Column(db.Date, nullable = False)
|
||||
label = db.Column(db.String(500), nullable = False)
|
||||
value = db.Column(db.Numeric(15, 2), nullable = False)
|
||||
account_id = db.Column(db.Integer, db.ForeignKey('account.id'))
|
||||
scheduled_operation_id = db.Column(db.Integer, db.ForeignKey('scheduled_operation.id'))
|
||||
|
||||
account = db.relationship(Account, backref = db.backref('entry', lazy="Dynamic"))
|
||||
scheduled_operation = db.relationship(ScheduledOperation, backref = db.backref('entry', lazy="Dynamic"))
|
||||
|
||||
category = db.Column(db.String(100), nullable = True)
|
||||
|
||||
def __init__(self, pointed, label, value, account_id, operation_date = None, category = None, scheduled_operation_id = None):
|
||||
self.pointed = pointed
|
||||
self.operation_date = operation_date
|
||||
self.label = label
|
||||
self.value = value
|
||||
self.account_id = account_id
|
||||
self.category = category
|
||||
self.scheduled_operation_id = scheduled_operation_id
|
||||
|
49
api/model/operations.py
Normal file
49
api/model/operations.py
Normal file
@ -0,0 +1,49 @@
|
||||
"""
|
||||
This file is part of Accountant.
|
||||
|
||||
Accountant is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Foobar is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from app import app
|
||||
from app import db
|
||||
|
||||
from api.model.accounts import Account
|
||||
from api.model.scheduled_operations import ScheduledOperation
|
||||
|
||||
from sqlalchemy import func, desc
|
||||
from sqlalchemy.orm import column_property
|
||||
from sqlalchemy.sql import func, select
|
||||
|
||||
class Operation(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
pointed = db.Column(db.Boolean, nullable = False, default = False)
|
||||
operation_date = db.Column(db.Date, nullable = False)
|
||||
label = db.Column(db.String(500), nullable = False)
|
||||
value = db.Column(db.Numeric(15, 2), nullable = False)
|
||||
account_id = db.Column(db.Integer, db.ForeignKey('account.id'))
|
||||
scheduled_operation_id = db.Column(db.Integer, db.ForeignKey('scheduled_operation.id'))
|
||||
|
||||
account = db.relationship(Account, backref = db.backref('operation', lazy="Dynamic"))
|
||||
|
||||
category = db.Column(db.String(100), nullable = True)
|
||||
|
||||
canceled = db.Column(db.Boolean, nullable = False)
|
||||
|
||||
def __init__(self, pointed, label, value, account_id, operation_date = None, category = None):
|
||||
self.pointed = pointed
|
||||
self.operation_date = operation_date
|
||||
self.label = label
|
||||
self.value = value
|
||||
self.account_id = account_id
|
||||
self.category = category
|
||||
|
33
api/model/scheduled_operations.py
Normal file
33
api/model/scheduled_operations.py
Normal file
@ -0,0 +1,33 @@
|
||||
from app import app
|
||||
from app import db
|
||||
|
||||
from api.model.accounts import Account
|
||||
|
||||
from sqlalchemy import func, desc
|
||||
from sqlalchemy.orm import column_property
|
||||
from sqlalchemy.sql import func, select
|
||||
|
||||
class ScheduledOperation(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
start_date = db.Column(db.Date, nullable = False)
|
||||
stop_date = db.Column(db.Date, nullable = False)
|
||||
day = db.Column(db.Integer, nullable = False)
|
||||
frequency = db.Column(db.Integer, nullable = False)
|
||||
label = db.Column(db.String(500), nullable = False)
|
||||
value = db.Column(db.Numeric(15, 2), nullable = False)
|
||||
account_id = db.Column(db.Integer, db.ForeignKey('account.id'))
|
||||
|
||||
account = db.relationship(Account, backref = db.backref('scheduled_operation', lazy="Dynamic"))
|
||||
|
||||
category = db.Column(db.String(100), nullable = True)
|
||||
|
||||
def __init__(self, start_date, stop_date, day, frequency, label, value, account_id, category = None):
|
||||
self.start_date = start_date
|
||||
self.stop_date = stop_date
|
||||
self.day = day
|
||||
self.frequency = frequency
|
||||
self.label = label
|
||||
self.value = value
|
||||
self.account_id = account_id
|
||||
self.category = category
|
||||
|
Reference in New Issue
Block a user