06/03 Optimize codes, Schwab account

This commit is contained in:
2026-06-03 14:46:30 -04:00
parent f59f9aa44c
commit 302fbf5fe2
5 changed files with 204 additions and 97 deletions
+4
View File
@@ -6,6 +6,9 @@ class Investment(db.Model):
__tablename__ = 'investments'
id = db.Column(db.Integer, primary_key=True)
# Optional link to a PFM account (e.g. Schwab Individual, Schwab Roth IRA).
# NULL means the holding is not tied to a specific account.
account_id = db.Column(db.Integer, db.ForeignKey('accounts.id'), nullable=True, index=True)
asset_name = db.Column(db.String(100), nullable=False)
ticker = db.Column(db.String(20), nullable=True)
asset_type = db.Column(
@@ -22,6 +25,7 @@ class Investment(db.Model):
created_at = db.Column(db.DateTime, default=datetime.utcnow)
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
account = db.relationship('Account', foreign_keys=[account_id])
inv_transactions = db.relationship('InvestmentTransaction', back_populates='investment',
lazy='dynamic', cascade='all, delete-orphan')