19 lines
820 B
Python
19 lines
820 B
Python
from app.extensions import db
|
|
from datetime import datetime
|
|
|
|
|
|
class NetWorthSnapshot(db.Model):
|
|
__tablename__ = 'net_worth_snapshots'
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
snapshot_date = db.Column(db.Date, nullable=False, unique=True, index=True)
|
|
total_assets = db.Column(db.Numeric(15, 2), nullable=False, default=0)
|
|
total_liabilities = db.Column(db.Numeric(15, 2), nullable=False, default=0)
|
|
net_worth = db.Column(db.Numeric(15, 2), nullable=False, default=0)
|
|
account_balances = db.Column(db.JSON, nullable=True) # snapshot of each account balance
|
|
investment_value = db.Column(db.Numeric(15, 2), default=0)
|
|
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
|
|
|
def __repr__(self):
|
|
return f'<NetWorthSnapshot {self.snapshot_date} nw={self.net_worth}>'
|