2013-02-08 13:07:27 +01:00
|
|
|
"""
|
|
|
|
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/>.
|
|
|
|
"""
|
2013-01-24 00:01:42 +01:00
|
|
|
from app import app
|
|
|
|
from app import db
|
|
|
|
|
|
|
|
from api.model.accounts import Account
|
2013-07-28 23:25:51 +02:00
|
|
|
from api.model.scheduled_operations import ScheduledOperation
|
2013-01-24 00:01:42 +01:00
|
|
|
|
|
|
|
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)
|
2013-01-26 01:15:07 +01:00
|
|
|
pointed = db.Column(db.Boolean, nullable = False, default = False)
|
|
|
|
operation_date = db.Column(db.Date, nullable = False)
|
2013-01-24 00:01:42 +01:00
|
|
|
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'))
|
2013-07-28 23:25:51 +02:00
|
|
|
scheduled_operation_id = db.Column(db.Integer, db.ForeignKey('scheduled_operation.id'))
|
2013-01-24 00:01:42 +01:00
|
|
|
|
|
|
|
account = db.relationship(Account, backref = db.backref('entry', lazy="Dynamic"))
|
2013-07-28 23:25:51 +02:00
|
|
|
scheduled_operation = db.relationship(ScheduledOperation, backref = db.backref('entry', lazy="Dynamic"))
|
2013-01-24 00:01:42 +01:00
|
|
|
|
|
|
|
category = db.Column(db.String(100), nullable = True)
|
|
|
|
|
2013-07-28 23:25:51 +02:00
|
|
|
def __init__(self, pointed, label, value, account_id, operation_date = None, category = None, scheduled_operation_id = None):
|
2013-01-26 01:15:07 +01:00
|
|
|
self.pointed = pointed
|
2013-01-24 00:01:42 +01:00
|
|
|
self.operation_date = operation_date
|
|
|
|
self.label = label
|
|
|
|
self.value = value
|
|
|
|
self.account_id = account_id
|
|
|
|
self.category = category
|
2013-07-28 23:25:51 +02:00
|
|
|
self.scheduled_operation_id = scheduled_operation_id
|
2013-01-24 00:01:42 +01:00
|
|
|
|