예제 #1
0
class Account(db.Model):
    account_id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey(User.user_id), nullable=False)
    account_name = db.Column(db.String, nullable=False)
    account_type = db.Column(db.String, nullable=False)
    transactions = db.relationship('Transaction', backref=db.backref('Account', uselist=True))
    account_tags = db.relationship('Account_tag', backref=db.backref('Account', uselist=True))
    debts = db.relationship('Debt', backref=db.backref('Account', uselist=True))
    def __repr__(self):
        return '<Account %r>' % self.account_name
예제 #2
0
class Debt(db.Model):
    debt_id = db.Column(db.Integer, primary_key=True)
    lender = db.Column(db.String, nullable=False)
    principal = db.Column(db.Float, nullable=False)
    interest_rate = db.Column(db.Float, nullable=True)
    interest_period = db.Column(db.String, nullable = True)
    payment_account = db.Column(db.Integer, db.ForeignKey(Account.account_id), nullable=False)
    payment_date = db.Column(db.String, nullable=True)
    transactions_debt = db.relationship('Transaction_debt', backref=db.backref('Debt', uselist=False))
    def __repr__(self):
        return '<Debt %r>' % self.lender
예제 #3
0
class Transaction(db.Model):
    transaction_id = db.Column(db.Integer, primary_key=True)
    account_id = db.Column(db.Integer, db.ForeignKey(Account.account_id), nullable=False)
    transaction_type = db.Column(db.String, nullable=False)
    transaction_value = db.Column(db.Float, nullable=False)
    transaction_date = db.Column(db.Date, nullable=False, default=date.today())
    # transaction_time = db.Column(db.Time, nullable=False)
    transaction_note = db.Column(db.String)
    transactions_ba = db.relationship('Transaction_bank_account', backref=db.backref('Transaction', uselist=True))
    transactions_re = db.relationship('Transaction_real_estate', backref=db.backref('Transaction', uselist=True))
    transactions_bond = db.relationship('Transaction_bond', backref=db.backref('Transaction', uselist=True))
    transactions_stock = db.relationship('Transaction_stock', backref=db.backref('Transaction', uselist=True))
    transactions_debt = db.relationship('Transaction_debt', backref=db.backref('Transaction', uselist=True))
    transaction_tags = db.relationship('Transaction_tag', backref=db.backref('Transaction', uselist=True))
    def __repr__(self):
        return '<Transaction %r>' % self.transaction_type
예제 #4
0
class Transaction_real_estate(db.Model):
    transaction_re_id = db.Column(db.Integer, primary_key=True)
    transaction_id = db.Column(db.Integer, db.ForeignKey(Transaction.transaction_id), nullable=False)
    real_estate_id = db.Column(db.Integer, db.ForeignKey(Real_estate.real_estate_id), nullable=False)
예제 #5
0
class Transaction_debt(db.Model):
    transaction_debt_id = db.Column(db.Integer, primary_key=True)
    transaction_id = db.Column(db.Integer, db.ForeignKey('transaction.transaction_id'), nullable=False)
    debt_id = db.Column(db.Integer, db.ForeignKey('debt.debt_id'), nullable=False)
예제 #6
0
class Transaction_bank_account(db.Model):
    transaction_ba_id =  db.Column(db.Integer, primary_key=True)
    transaction_id = db.Column(db.Integer, db.ForeignKey(Transaction.transaction_id), nullable=False)
    bank_account_id = db.Column(db.Integer, db.ForeignKey(Bank_account.bank_account_id), nullable=False)
예제 #7
0
class Account_tag(db.Model):
    account_tag_id = db.Column(db.Integer, primary_key=True)
    account_id = db.Column(db.Integer, db.ForeignKey(Account.account_id), nullable=False)
    tag_id = db.Column(db.Integer, db.ForeignKey(Tag.tag_id), nullable=False)
예제 #8
0
class Transaction_tag(db.Model):
    transaction_tag_id = db.Column(db.Integer, primary_key=True)
    transaction_id = db.Column(db.Integer, db.ForeignKey(Transaction.transaction_id), nullable=False)
    tag_id = db.Column(db.Integer, db.ForeignKey(Tag.tag_id), nullable=False)
예제 #9
0
class Transaction_stock(db.Model):
    transaction_stock_id = db.Column(db.Integer, primary_key=True)
    transaction_id = db.Column(db.Integer, db.ForeignKey(Transaction.transaction_id), nullable=False)
    stock_id = db.Column(db.Integer, db.ForeignKey(Stock.stock_id), nullable=False)
예제 #10
0
class Transaction_bond(db.Model):
    transaction_bond_id = db.Column(db.Integer, primary_key=True)
    transaction_id = db.Column(db.Integer, db.ForeignKey(Transaction.transaction_id), nullable=False)
    bond_id = db.Column(db.Integer, db.ForeignKey(Bond.bond_id), nullable=False)