release: Elysia ToDo v1.0.0

鍏ㄦ爤涓汉淇℃伅绠$悊搴旂敤锛岄泦鎴愬緟鍔炰换鍔°€佷範鎯墦鍗°€佺邯蹇垫棩鎻愰啋銆佽祫浜ф€昏鍔熻兘銆

Made-with: Cursor
This commit is contained in:
祀梦
2026-03-14 22:21:26 +08:00
commit 2979197b1c
104 changed files with 21737 additions and 0 deletions

61
api/app/models/account.py Normal file
View File

@@ -0,0 +1,61 @@
from sqlalchemy import Column, Integer, String, Text, Boolean, Float, DateTime, ForeignKey, Date
from sqlalchemy.orm import relationship
from app.database import Base
from app.utils.datetime import utcnow
class FinancialAccount(Base):
"""财务账户模型"""
__tablename__ = "financial_accounts"
id = Column(Integer, primary_key=True, index=True)
name = Column(String(100), nullable=False)
account_type = Column(String(20), nullable=False, default="savings") # savings / debt
balance = Column(Float, default=0.0)
icon = Column(String(50), default="wallet")
color = Column(String(20), default="#FFB7C5")
sort_order = Column(Integer, default=0)
is_active = Column(Boolean, default=True)
description = Column(Text, nullable=True)
created_at = Column(DateTime, default=utcnow)
updated_at = Column(DateTime, default=utcnow, onupdate=utcnow)
# 关联关系
history_records = relationship("AccountHistory", back_populates="account", cascade="all, delete-orphan")
debt_installments = relationship("DebtInstallment", back_populates="account", cascade="all, delete-orphan")
class AccountHistory(Base):
"""余额变更历史"""
__tablename__ = "account_history"
id = Column(Integer, primary_key=True, index=True)
account_id = Column(Integer, ForeignKey("financial_accounts.id"), nullable=False)
change_amount = Column(Float, nullable=False)
balance_before = Column(Float, nullable=False)
balance_after = Column(Float, nullable=False)
note = Column(String(200), nullable=True)
created_at = Column(DateTime, default=utcnow)
# 关联关系
account = relationship("FinancialAccount", back_populates="history_records")
class DebtInstallment(Base):
"""分期还款计划"""
__tablename__ = "debt_installments"
id = Column(Integer, primary_key=True, index=True)
account_id = Column(Integer, ForeignKey("financial_accounts.id"), nullable=False)
total_amount = Column(Float, nullable=False)
total_periods = Column(Integer, nullable=False)
current_period = Column(Integer, nullable=False, default=1) # 1-based, 指向下一期待还
payment_day = Column(Integer, nullable=False) # 每月还款日 1-31
payment_amount = Column(Float, nullable=False)
start_date = Column(Date, nullable=False)
is_completed = Column(Boolean, default=False)
created_at = Column(DateTime, default=utcnow)
updated_at = Column(DateTime, default=utcnow, onupdate=utcnow)
# 关联关系
account = relationship("FinancialAccount", back_populates="debt_installments")