support last reconciled time for account

This commit is contained in:
MaysWind
2026-05-07 01:17:00 +08:00
parent 39ee47e05a
commit de132dd7fd
43 changed files with 648 additions and 110 deletions
+19 -1
View File
@@ -90,7 +90,8 @@ type Account struct {
// AccountExtend represents account extend data stored in database
type AccountExtend struct {
CreditCardStatementDate *int `json:"creditCardStatementDate"`
LastReconciledTime *int64 `json:"lastReconciledTime"`
CreditCardStatementDate *int `json:"creditCardStatementDate"`
}
// AccountCreateRequest represents all parameters of account creation request
@@ -119,6 +120,7 @@ type AccountModifyRequest struct {
Currency *string `json:"currency" binding:"omitempty,len=3,validCurrency"`
Balance *int64 `json:"balance" binding:"omitempty"`
BalanceTime *int64 `json:"balanceTime" binding:"omitempty"`
LastReconciledTime *int64 `json:"lastReconciledTime" binding:"omitempty"`
Comment string `json:"comment" binding:"max=255"`
CreditCardStatementDate int `json:"creditCardStatementDate" binding:"min=0,max=28"`
Hidden bool `json:"hidden"`
@@ -169,6 +171,7 @@ type AccountInfoResponse struct {
Color string `json:"color"`
Currency string `json:"currency"`
Balance int64 `json:"balance"`
LastReconciledTime *int64 `json:"lastReconciledTime,omitempty"`
Comment string `json:"comment"`
CreditCardStatementDate *int `json:"creditCardStatementDate,omitempty"`
DisplayOrder int32 `json:"displayOrder"`
@@ -178,10 +181,24 @@ type AccountInfoResponse struct {
SubAccounts AccountInfoResponseSlice `json:"subAccounts,omitempty"`
}
// GetLastReconciledTime returns the last reconciled time of the account
func (a *Account) GetLastReconciledTime() int64 {
if a.Extend != nil && a.Extend.LastReconciledTime != nil {
return *a.Extend.LastReconciledTime
}
return 0
}
// ToAccountInfoResponse returns a view-object according to database model
func (a *Account) ToAccountInfoResponse() *AccountInfoResponse {
var lastReconciledTime *int64
var creditCardStatementDate *int
if a.Extend != nil {
lastReconciledTime = a.Extend.LastReconciledTime
}
if a.ParentAccountId == LevelOneAccountParentId && a.Category == ACCOUNT_CATEGORY_CREDIT_CARD {
if a.Extend != nil {
creditCardStatementDate = a.Extend.CreditCardStatementDate
@@ -201,6 +218,7 @@ func (a *Account) ToAccountInfoResponse() *AccountInfoResponse {
Currency: a.Currency,
Balance: a.Balance,
Comment: a.Comment,
LastReconciledTime: lastReconciledTime,
CreditCardStatementDate: creditCardStatementDate,
DisplayOrder: a.DisplayOrder,
IsAsset: assetAccountCategory[a.Category],