Files
HouseholdBudgetBook/backend/model/asset.go
T

81 lines
3.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
type Asset struct {
ID int64 `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Value int64 `json:"value"` // 绑定账户时为派生值;手工资产为录入值
AccountID *int64 `json:"account_id"` // 若不为 NULL,value 由该账户的 current_balance 派生
AccountName string `json:"account_name"` // 仅响应字段
IsDerived bool `json:"is_derived"` // 仅响应字段:account_id 是否绑定
Note string `json:"note"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
type CreateAssetRequest struct {
Name string `json:"name"`
Type string `json:"type"`
Value int64 `json:"value"`
AccountID *int64 `json:"account_id,omitempty"`
Note string `json:"note"`
}
type UpdateAssetRequest struct {
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
Value *int64 `json:"value,omitempty"`
AccountID NullableInt64 `json:"account_id,omitempty"`
Note *string `json:"note,omitempty"`
}
type Liability struct {
ID int64 `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Principal int64 `json:"principal"`
InterestRate float64 `json:"interest_rate"`
MonthlyPayment int64 `json:"monthly_payment"`
RemainingTerms int `json:"remaining_terms"`
Note string `json:"note"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
type CreateLiabilityRequest struct {
Name string `json:"name"`
Type string `json:"type"`
Principal int64 `json:"principal"`
InterestRate float64 `json:"interest_rate"`
MonthlyPayment int64 `json:"monthly_payment"`
RemainingTerms int `json:"remaining_terms"`
Note string `json:"note"`
}
type UpdateLiabilityRequest struct {
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
Principal *int64 `json:"principal,omitempty"`
InterestRate *float64 `json:"interest_rate,omitempty"`
MonthlyPayment *int64 `json:"monthly_payment,omitempty"`
RemainingTerms *int `json:"remaining_terms,omitempty"`
Note *string `json:"note,omitempty"`
}
type NetWorthSummary struct {
TotalAssets int64 `json:"total_assets"` // assets 表手工录入项汇总
TotalDebt int64 `json:"total_debt"` // liabilities 表手工录入项汇总
LiquidAssets int64 `json:"liquid_assets"` // 由活跃账户当前余额派生:非信用卡且 current_balance > 0
LiquidDebt int64 `json:"liquid_debt"` // 由活跃账户当前余额派生:信用卡且 current_balance < 0 时的欠款绝对值
NetWorth int64 `json:"net_worth"` // = total_assets + liquid_assets - total_debt - liquid_debt
}
type AssetSnapshot struct {
ID int64 `json:"id"`
Date string `json:"date"`
TotalAsset int64 `json:"total_asset"`
TotalDebt int64 `json:"total_debt"`
NetWorth int64 `json:"net_worth"`
CreatedAt string `json:"created_at"`
}