Exemple #1
0
class Tag(db.Model):
    tag_id = db.Column(db.Integer, primary_key=True)
    tag_name = db.Column(db.String, unique=True, nullable=False)
    account_tags = db.relationship('Account_tag', backref=db.backref('Tag', uselist=True))
    transaction_tags = db.relationship('Transaction_tag', backref=db.backref('Tag', uselist=True))
    def __repr__(self):
        return '<Tag %r>' % self.tag_name
Exemple #2
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
Exemple #3
0
class Real_estate(db.Model):
    real_estate_id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String, nullable=False)
    original_value = db.Column(db.Float, nullable=False)
    estimated_value = db.Column(db.Float, nullable=False)
    transactions_re = db.relationship('Transaction_real_estate', backref=db.backref('Real_estate', uselist=False))
    def __repr__(self):
        return '<Real Estate %r>' % self.name
Exemple #4
0
class Bond(db.Model):
    bond_id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String, nullable=False)
    value = db.Column(db.Float, nullable=False)
    maturation_date = db.Column(db.Date, nullable=False, default=date.today())
    transactions_bond = db.relationship('Transaction_bond', backref=db.backref('Bond', uselist=False))
    def __repr__(self):
        return '<Bond %r>' % self.name
Exemple #5
0
class Bank_account(db.Model):
    bank_account_id = db.Column(db.Integer, primary_key=True)
    bank_name = db.Column(db.String, nullable=False)
    account_digits = db.Column(db.String, nullable=False)
    interest_rate = db.Column(db.Integer, nullable=True)
    interest_period = db.Column(db.String, nullable = True)
    transactions_ba = db.relationship('Transaction_bank_account', backref=db.backref('Bank_account', uselist=False))
    def __repr__(self):
        return '<Bank Account %r %r>' % (self.bank_name, self.account_digits)
Exemple #6
0
class Stock(db.Model):
    stock_id = db.Column(db.Integer, primary_key=True)
    stock_symbol = db.Column(db.String, nullable=False)
    exchange = db.Column(db.String, nullable=False)
    num_stocks = db.Column(db.Integer, nullable=False) #Starting number of stocks
    transactions_stock = db.relationship('Transaction_stock', backref=db.backref('Stock', uselist=False))
    # stock_ids = db.relationship('Stock_value', backref=db.backref('Stock', uselist=True))
    def __repr__(self):
        return '<Stock %r>' % self.stock_symbol
Exemple #7
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
Exemple #8
0
class User(UserMixin, db.Model):
    user_id = db.Column(db.Integer, primary_key=True)
    user_name = db.Column(db.String, unique=True, nullable=False)
    pass_hash = db.Column(db.String, nullable=False)
    accounts = db.relationship('Account', backref=db.backref('User', uselist=False))

    def get_id(self):
        return int(self.user_id)

    def get_username(self):
        return str(self.user_name)

    def __repr__(self):
        return '<User %r>' % self.user_name
Exemple #9
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