not need balance time field in parent account
This commit is contained in:
@@ -169,6 +169,11 @@ func (a *AccountsApi) AccountCreateHandler(c *core.WebContext) (any, *errs.Error
|
||||
log.Warnf(c, "[accounts.AccountCreateHandler] account cannot set currency placeholder")
|
||||
return nil, errs.ErrAccountCurrencyInvalid
|
||||
}
|
||||
|
||||
if accountCreateReq.Balance != 0 && accountCreateReq.BalanceTime <= 0 {
|
||||
log.Warnf(c, "[accounts.AccountCreateHandler] account balance time is not set")
|
||||
return nil, errs.ErrAccountBalanceTimeNotSet
|
||||
}
|
||||
} else if accountCreateReq.Type == models.ACCOUNT_TYPE_MULTI_SUB_ACCOUNTS {
|
||||
if len(accountCreateReq.SubAccounts) < 1 {
|
||||
log.Warnf(c, "[accounts.AccountCreateHandler] account does not have any sub-accounts")
|
||||
@@ -202,6 +207,11 @@ func (a *AccountsApi) AccountCreateHandler(c *core.WebContext) (any, *errs.Error
|
||||
log.Warnf(c, "[accounts.AccountCreateHandler] sub-account cannot set currency placeholder")
|
||||
return nil, errs.ErrAccountCurrencyInvalid
|
||||
}
|
||||
|
||||
if subAccount.Balance != 0 && subAccount.BalanceTime <= 0 {
|
||||
log.Warnf(c, "[accounts.AccountCreateHandler] sub-account balance time is not set")
|
||||
return nil, errs.ErrAccountBalanceTimeNotSet
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.Warnf(c, "[accounts.AccountCreateHandler] account type invalid, type is %d", accountCreateReq.Type)
|
||||
|
||||
@@ -19,4 +19,5 @@ var (
|
||||
ErrDestinationAccountNotFound = NewNormalError(NormalSubcategoryAccount, 12, http.StatusBadRequest, "destination account not found")
|
||||
ErrAccountInUseCannotBeDeleted = NewNormalError(NormalSubcategoryAccount, 13, http.StatusBadRequest, "account is in use and cannot be deleted")
|
||||
ErrAccountCategoryInvalid = NewNormalError(NormalSubcategoryAccount, 14, http.StatusBadRequest, "account category is invalid")
|
||||
ErrAccountBalanceTimeNotSet = NewNormalError(NormalSubcategoryAccount, 15, http.StatusBadRequest, "account balance time is not set")
|
||||
)
|
||||
|
||||
@@ -82,7 +82,7 @@ type AccountCreateRequest struct {
|
||||
Color string `json:"color" binding:"required,len=6,validHexRGBColor"`
|
||||
Currency string `json:"currency" binding:"required,len=3,validCurrency"`
|
||||
Balance int64 `json:"balance"`
|
||||
BalanceTime int64 `json:"balanceTime" binding:"required,min=1"`
|
||||
BalanceTime int64 `json:"balanceTime"`
|
||||
Comment string `json:"comment" binding:"max=255"`
|
||||
SubAccounts []*AccountCreateRequest `json:"subAccounts" binding:"omitempty"`
|
||||
ClientSessionId string `json:"clientSessionId"`
|
||||
|
||||
@@ -1058,6 +1058,7 @@
|
||||
"destination account not found": "Destination account is not found",
|
||||
"account is in use and cannot be deleted": "Account is in use and it cannot be deleted",
|
||||
"account category is invalid": "Account category is invalid",
|
||||
"account balance time is not set": "Account balance time is not set",
|
||||
"transaction id is invalid": "Transaction ID is invalid",
|
||||
"transaction not found": "Transaction is not found",
|
||||
"transaction type is invalid": "Transaction type is invalid",
|
||||
|
||||
@@ -1058,6 +1058,7 @@
|
||||
"destination account not found": "目标账户不存在",
|
||||
"account is in use and cannot be deleted": "账户正在被使用,无法删除",
|
||||
"account category is invalid": "账户分类无效",
|
||||
"account balance time is not set": "账户余额时间没有设置",
|
||||
"transaction id is invalid": "交易ID无效",
|
||||
"transaction not found": "交易不存在",
|
||||
"transaction type is invalid": "交易类型无效",
|
||||
|
||||
@@ -791,7 +791,9 @@ export const useAccountsStore = defineStore('accounts', {
|
||||
submitAccount.id = account.id;
|
||||
submitAccount.hidden = !account.visible;
|
||||
} else {
|
||||
submitAccount.balanceTime = account.balanceTime;
|
||||
if (account.type === accountConstants.allAccountTypes.SingleAccount) {
|
||||
submitAccount.balanceTime = account.balanceTime;
|
||||
}
|
||||
}
|
||||
|
||||
const oldAccount = submitAccount.id ? self.allAccountsMap[submitAccount.id] : null;
|
||||
|
||||
Reference in New Issue
Block a user