05/31 Phase 1: initial codes

This commit is contained in:
2026-05-31 10:03:28 -04:00
parent b0a5ce5399
commit b0c0bd363b
35 changed files with 2871 additions and 164 deletions
+32
View File
@@ -0,0 +1,32 @@
from app.extensions import db
from datetime import datetime
class Account(db.Model):
__tablename__ = 'accounts'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(100), nullable=False)
account_type = db.Column(
db.Enum('checking', 'savings', 'cash', 'credit_card', 'crypto', 'investment', 'other'),
nullable=False,
default='checking'
)
balance = db.Column(db.Numeric(15, 2), default=0.00, nullable=False)
credit_limit = db.Column(db.Numeric(15, 2), nullable=True) # credit cards
due_date = db.Column(db.Integer, nullable=True) # day of month bill due
color = db.Column(db.String(7), default='#4F81C7') # hex color for UI
icon = db.Column(db.String(50), default='bi-bank') # bootstrap icon name
is_active = db.Column(db.Boolean, default=True)
notes = db.Column(db.Text, nullable=True)
created_at = db.Column(db.DateTime, default=datetime.utcnow)
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
# Relationships
transactions = db.relationship('Transaction', back_populates='account',
lazy='dynamic', foreign_keys='Transaction.account_id')
transfer_transactions = db.relationship('Transaction', back_populates='to_account',
lazy='dynamic', foreign_keys='Transaction.to_account_id')
def __repr__(self):
return f'<Account {self.name}>'