class Budget(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(60)) budget = db.Column(db.Float) closed = db.Column(db.Boolean, default=False) term_id = db.Column(db.Integer, db.ForeignKey('term.id')) expenditures = db.relationship('Expenditure', backref='budget', lazy=True)
class Account(db.Model): account_id = db.Column(db.Integer, primary_key=True) holder_name = db.Column(db.String(30), nullable=False) account_type = db.Column(db.String(20), nullable=False, default='Resident') block_no = db.Column(db.String(1), nullable=True) phone_no = db.Column(db.String(10), nullable=False) flat_no = db.Column(db.Integer, nullable=True, unique=True) balance = db.Column(db.Float, default=0.0, nullable=False) transactions = db.relationship('Transactions', backref='ref_acc', lazy=True) init_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) def __repr__(self): return "Account('{}', '{}', '{}')".format(self.account_id, self.account_type, self.holder_name)
class Transactions(db.Model): trans_id = db.Column(db.Integer, primary_key=True) trans_user = db.Column(db.Integer, db.ForeignKey('account.account_id'), nullable=False) trans_amount = db.Column(db.Float, nullable=False) trans_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) trans_mode = db.Column(db.String(10), nullable=False) trans_type = db.Column(db.String(10), nullable=False) trans_descr = db.Column(db.Text) def __repr__(self): return "Transcation('{}', '{}', '{}')".format(self.trans_id, self.trans_user, self.trans_mode)
class Fixedcost(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(60)) price = db.Column(db.Float) payed = db.Column(db.Boolean) fixedcosttemplate_id = db.Column(db.Integer, db.ForeignKey('fixedcosttemplate.id'))
class Fixedcosttemplate(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(60)) price = db.Column(db.Float) default = db.Column(db.Boolean)
class Expenditure(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(60)) price = db.Column(db.Float) payed = db.Column(db.Boolean) budget_id = db.Column(db.Integer, db.ForeignKey('budget.id'))
class Term(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(60)) income = db.Column(db.Float) budgets = db.relationship('Budget', backref='term', lazy=True)
class Budgettemplate(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(60)) budget = db.Column(db.Float)