05/31 Phase 1: initial codes
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
from app.extensions import db
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class Budget(db.Model):
|
||||
__tablename__ = 'budgets'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
category_id = db.Column(db.Integer, db.ForeignKey('categories.id'), nullable=False)
|
||||
month = db.Column(db.String(7), nullable=False, index=True) # YYYY-MM
|
||||
limit_amount = db.Column(db.Numeric(15, 2), nullable=False)
|
||||
rollover_enabled = db.Column(db.Boolean, default=False)
|
||||
rollover_amount = db.Column(db.Numeric(15, 2), default=0.00)
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
|
||||
category = db.relationship('Category')
|
||||
|
||||
__table_args__ = (
|
||||
db.UniqueConstraint('category_id', 'month', name='uq_budget_category_month'),
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return f'<Budget {self.month} cat={self.category_id} limit={self.limit_amount}>'
|
||||
Reference in New Issue
Block a user