feat: 添加核心财务模型、账户存储库和存钱罐服务

This commit is contained in:
2026-02-01 18:54:05 +08:00
parent 6cf8fd04f4
commit 49fcce531d
3 changed files with 157 additions and 37 deletions

View File

@@ -286,11 +286,16 @@ func (Account) TableName() string {
return "accounts"
}
// TotalBalance calculates the total balance including sub-accounts
// Feature: financial-core-upgrade
// Validates: Requirements 1.3
// TotalBalance calculates the total balance including sub-accounts
// Feature: financial-core-upgrade
// Validates: Requirements 1.3
func (a *Account) TotalBalance() float64 {
total := a.AvailableBalance + a.FrozenBalance
// Balance is treated as Available Balance (liquid funds)
// FrozenBalance represents funds locked in savings pots/piggy banks
total := a.Balance + a.FrozenBalance
for _, sub := range a.SubAccounts {
if sub.SubAccountType != nil && *sub.SubAccountType != SubAccountTypeSavingsPot {
total += sub.Balance