modify the name of debit card to checking account, add savings account and certificate of deposit

This commit is contained in:
MaysWind
2024-09-20 00:00:19 +08:00
parent 1e8a27612f
commit 220f9f15e5
10 changed files with 84 additions and 41 deletions
+2 -2
View File
@@ -154,7 +154,7 @@ func (a *AccountsApi) AccountCreateHandler(c *core.WebContext) (any, *errs.Error
return nil, errs.ErrClientTimezoneOffsetInvalid return nil, errs.ErrClientTimezoneOffsetInvalid
} }
if accountCreateReq.Category < models.ACCOUNT_CATEGORY_CASH || accountCreateReq.Category > models.ACCOUNT_CATEGORY_INVESTMENT { if accountCreateReq.Category < models.ACCOUNT_CATEGORY_CASH || accountCreateReq.Category > models.ACCOUNT_CATEGORY_CERTIFICATE_OF_DEPOSIT {
log.Warnf(c, "[accounts.AccountCreateHandler] account category invalid, category is %d", accountCreateReq.Category) log.Warnf(c, "[accounts.AccountCreateHandler] account category invalid, category is %d", accountCreateReq.Category)
return nil, errs.ErrAccountCategoryInvalid return nil, errs.ErrAccountCategoryInvalid
} }
@@ -288,7 +288,7 @@ func (a *AccountsApi) AccountModifyHandler(c *core.WebContext) (any, *errs.Error
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err) return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
} }
if accountModifyReq.Category < models.ACCOUNT_CATEGORY_CASH || accountModifyReq.Category > models.ACCOUNT_CATEGORY_INVESTMENT { if accountModifyReq.Category < models.ACCOUNT_CATEGORY_CASH || accountModifyReq.Category > models.ACCOUNT_CATEGORY_CERTIFICATE_OF_DEPOSIT {
log.Warnf(c, "[accounts.AccountModifyHandler] account category invalid, category is %d", accountModifyReq.Category) log.Warnf(c, "[accounts.AccountModifyHandler] account category invalid, category is %d", accountModifyReq.Category)
return nil, errs.ErrAccountCategoryInvalid return nil, errs.ErrAccountCategoryInvalid
} }
+27 -21
View File
@@ -8,33 +8,39 @@ type AccountCategory byte
// Account categories // Account categories
const ( const (
ACCOUNT_CATEGORY_CASH AccountCategory = 1 ACCOUNT_CATEGORY_CASH AccountCategory = 1
ACCOUNT_CATEGORY_DEBIT_CARD AccountCategory = 2 ACCOUNT_CATEGORY_CHECKING_ACCOUNT AccountCategory = 2
ACCOUNT_CATEGORY_CREDIT_CARD AccountCategory = 3 ACCOUNT_CATEGORY_CREDIT_CARD AccountCategory = 3
ACCOUNT_CATEGORY_VIRTUAL AccountCategory = 4 ACCOUNT_CATEGORY_VIRTUAL AccountCategory = 4
ACCOUNT_CATEGORY_DEBT AccountCategory = 5 ACCOUNT_CATEGORY_DEBT AccountCategory = 5
ACCOUNT_CATEGORY_RECEIVABLES AccountCategory = 6 ACCOUNT_CATEGORY_RECEIVABLES AccountCategory = 6
ACCOUNT_CATEGORY_INVESTMENT AccountCategory = 7 ACCOUNT_CATEGORY_INVESTMENT AccountCategory = 7
ACCOUNT_CATEGORY_SAVINGS_ACCOUNT AccountCategory = 8
ACCOUNT_CATEGORY_CERTIFICATE_OF_DEPOSIT AccountCategory = 9
) )
var assetAccountCategory = map[AccountCategory]bool{ var assetAccountCategory = map[AccountCategory]bool{
ACCOUNT_CATEGORY_CASH: true, ACCOUNT_CATEGORY_CASH: true,
ACCOUNT_CATEGORY_DEBIT_CARD: true, ACCOUNT_CATEGORY_CHECKING_ACCOUNT: true,
ACCOUNT_CATEGORY_CREDIT_CARD: false, ACCOUNT_CATEGORY_CREDIT_CARD: false,
ACCOUNT_CATEGORY_VIRTUAL: true, ACCOUNT_CATEGORY_VIRTUAL: true,
ACCOUNT_CATEGORY_DEBT: false, ACCOUNT_CATEGORY_DEBT: false,
ACCOUNT_CATEGORY_RECEIVABLES: true, ACCOUNT_CATEGORY_RECEIVABLES: true,
ACCOUNT_CATEGORY_INVESTMENT: true, ACCOUNT_CATEGORY_INVESTMENT: true,
ACCOUNT_CATEGORY_SAVINGS_ACCOUNT: true,
ACCOUNT_CATEGORY_CERTIFICATE_OF_DEPOSIT: true,
} }
var liabilityAccountCategory = map[AccountCategory]bool{ var liabilityAccountCategory = map[AccountCategory]bool{
ACCOUNT_CATEGORY_CASH: false, ACCOUNT_CATEGORY_CASH: false,
ACCOUNT_CATEGORY_DEBIT_CARD: false, ACCOUNT_CATEGORY_CHECKING_ACCOUNT: false,
ACCOUNT_CATEGORY_CREDIT_CARD: true, ACCOUNT_CATEGORY_CREDIT_CARD: true,
ACCOUNT_CATEGORY_VIRTUAL: false, ACCOUNT_CATEGORY_VIRTUAL: false,
ACCOUNT_CATEGORY_DEBT: true, ACCOUNT_CATEGORY_DEBT: true,
ACCOUNT_CATEGORY_RECEIVABLES: false, ACCOUNT_CATEGORY_RECEIVABLES: false,
ACCOUNT_CATEGORY_INVESTMENT: false, ACCOUNT_CATEGORY_INVESTMENT: false,
ACCOUNT_CATEGORY_SAVINGS_ACCOUNT: false,
ACCOUNT_CATEGORY_CERTIFICATE_OF_DEPOSIT: false,
} }
// AccountType represents account type // AccountType represents account type
+1 -1
View File
@@ -11,7 +11,7 @@ func TestAccountInfoResponseSliceLess(t *testing.T) {
var accountRespSlice AccountInfoResponseSlice var accountRespSlice AccountInfoResponseSlice
accountRespSlice = append(accountRespSlice, &AccountInfoResponse{ accountRespSlice = append(accountRespSlice, &AccountInfoResponse{
Id: 1, Id: 1,
Category: ACCOUNT_CATEGORY_DEBIT_CARD, Category: ACCOUNT_CATEGORY_CHECKING_ACCOUNT,
DisplayOrder: int32(1), DisplayOrder: int32(1),
}) })
accountRespSlice = append(accountRespSlice, &AccountInfoResponse{ accountRespSlice = append(accountRespSlice, &AccountInfoResponse{
+11 -1
View File
@@ -6,7 +6,12 @@ const allAccountCategories = [
}, },
{ {
id: 2, id: 2,
name: 'Debit Card', name: 'Checking Account',
defaultAccountIconId: '100'
},
{
id: 8,
name: 'Savings Account',
defaultAccountIconId: '100' defaultAccountIconId: '100'
}, },
{ {
@@ -29,6 +34,11 @@ const allAccountCategories = [
name: 'Receivables', name: 'Receivables',
defaultAccountIconId: '700' defaultAccountIconId: '700'
}, },
{
id: 9,
name: 'Certificate of Deposit',
defaultAccountIconId: '110'
},
{ {
id: 7, id: 7,
name: 'Investment Account', name: 'Investment Account',
+22 -4
View File
@@ -100,7 +100,7 @@ export function getSubAccountCurrencies(account, showHidden, subAccountId) {
return subAccountCurrencies; return subAccountCurrencies;
} }
export function getCategorizedAccounts(allAccounts) { export function getCategorizedAccountsMap(allAccounts) {
const ret = {}; const ret = {};
for (let i = 0; i < allAccounts.length; i++) { for (let i = 0; i < allAccounts.length; i++) {
@@ -128,8 +128,26 @@ export function getCategorizedAccounts(allAccounts) {
return ret; return ret;
} }
export function getCategorizedAccounts(allAccounts) {
const ret = [];
const categorizedAccounts = getCategorizedAccountsMap(allAccounts);
for (let i = 0; i < accountConstants.allCategories.length; i++) {
const category = accountConstants.allCategories[i];
if (!categorizedAccounts[category.id]) {
continue;
}
const accountCategory = categorizedAccounts[category.id];
ret.push(accountCategory);
}
return ret;
}
export function getCategorizedAccountsWithVisibleCount(categorizedAccounts) { export function getCategorizedAccountsWithVisibleCount(categorizedAccounts) {
const ret = {}; const ret = [];
for (let i = 0; i < accountConstants.allCategories.length; i++) { for (let i = 0; i < accountConstants.allCategories.length; i++) {
const accountCategory = accountConstants.allCategories[i]; const accountCategory = accountConstants.allCategories[i];
@@ -181,7 +199,7 @@ export function getCategorizedAccountsWithVisibleCount(categorizedAccounts) {
} }
if (allAccounts.length > 0) { if (allAccounts.length > 0) {
ret[accountCategory.id] = { ret.push({
category: accountCategory.id, category: accountCategory.id,
name: accountCategory.name, name: accountCategory.name,
icon: accountCategory.defaultAccountIconId, icon: accountCategory.defaultAccountIconId,
@@ -191,7 +209,7 @@ export function getCategorizedAccountsWithVisibleCount(categorizedAccounts) {
allSubAccounts: allSubAccounts, allSubAccounts: allSubAccounts,
allVisibleSubAccountCounts: allVisibleSubAccountCounts, allVisibleSubAccountCounts: allVisibleSubAccountCounts,
allFirstVisibleSubAccountIndexes: allFirstVisibleSubAccountIndexes allFirstVisibleSubAccountIndexes: allFirstVisibleSubAccountIndexes
}; });
} }
} }
+11 -6
View File
@@ -55,7 +55,7 @@ import {
} from './currency.js'; } from './currency.js';
import { import {
getCategorizedAccounts, getCategorizedAccountsMap,
getAllFilteredAccountsBalance getAllFilteredAccountsBalance
} from './account.js'; } from './account.js';
@@ -1280,14 +1280,17 @@ function getEnableDisableOptions(translateFn) {
} }
function getCategorizedAccountsWithDisplayBalance(allVisibleAccounts, showAccountBalance, defaultCurrency, userStore, settingsStore, exchangeRatesStore, translateFn) { function getCategorizedAccountsWithDisplayBalance(allVisibleAccounts, showAccountBalance, defaultCurrency, userStore, settingsStore, exchangeRatesStore, translateFn) {
const categorizedAccounts = copyObjectTo(getCategorizedAccounts(allVisibleAccounts), {}); const ret = [];
const categorizedAccounts = copyObjectTo(getCategorizedAccountsMap(allVisibleAccounts), {});
for (let category in categorizedAccounts) { for (let i = 0; i < accountConstants.allCategories.length; i++) {
if (!Object.prototype.hasOwnProperty.call(categorizedAccounts, category)) { const category = accountConstants.allCategories[i];
if (!categorizedAccounts[category.id]) {
continue; continue;
} }
const accountCategory = categorizedAccounts[category]; const accountCategory = categorizedAccounts[category.id];
if (accountCategory.accounts) { if (accountCategory.accounts) {
for (let i = 0; i < accountCategory.accounts.length; i++) { for (let i = 0; i < accountCategory.accounts.length; i++) {
@@ -1339,9 +1342,11 @@ function getCategorizedAccountsWithDisplayBalance(allVisibleAccounts, showAccoun
} else { } else {
accountCategory.displayBalance = '***'; accountCategory.displayBalance = '***';
} }
ret.push(accountCategory);
} }
return categorizedAccounts; return ret;
} }
function joinMultiText(textArray, translateFn) { function joinMultiText(textArray, translateFn) {
+3 -1
View File
@@ -1395,12 +1395,14 @@
"Income": "Income", "Income": "Income",
"Transfer": "Transfer", "Transfer": "Transfer",
"Cash": "Cash", "Cash": "Cash",
"Debit Card": "Debit Card", "Checking Account": "Checking Account",
"Credit Card": "Credit Card", "Credit Card": "Credit Card",
"Virtual Account": "Virtual Account", "Virtual Account": "Virtual Account",
"Debt Account": "Debt Account", "Debt Account": "Debt Account",
"Receivables": "Receivables", "Receivables": "Receivables",
"Investment Account": "Investment Account", "Investment Account": "Investment Account",
"Savings Account": "Savings Account",
"Certificate of Deposit": "Certificate of Deposit",
"Balance": "Balance", "Balance": "Balance",
"Unable to retrieve account list": "Unable to retrieve account list", "Unable to retrieve account list": "Unable to retrieve account list",
"Account list is up to date": "Account list is up to date", "Account list is up to date": "Account list is up to date",
+3 -1
View File
@@ -1395,12 +1395,14 @@
"Income": "收入", "Income": "收入",
"Transfer": "转账", "Transfer": "转账",
"Cash": "现金", "Cash": "现金",
"Debit Card": "借记", "Checking Account": "借记账户",
"Credit Card": "信用卡", "Credit Card": "信用卡",
"Virtual Account": "虚拟账户", "Virtual Account": "虚拟账户",
"Debt Account": "负债账户", "Debt Account": "负债账户",
"Receivables": "应收款项", "Receivables": "应收款项",
"Investment Account": "投资账户", "Investment Account": "投资账户",
"Savings Account": "储蓄账户",
"Certificate of Deposit": "定期存款",
"Balance": "余额", "Balance": "余额",
"Unable to retrieve account list": "无法获取账户列表", "Unable to retrieve account list": "无法获取账户列表",
"Account list is up to date": "账户列表已是最新", "Account list is up to date": "账户列表已是最新",
+3 -3
View File
@@ -10,7 +10,7 @@ import colorConstants from '@/consts/color.js';
import services from '@/lib/services.js'; import services from '@/lib/services.js';
import logger from '@/lib/logger.js'; import logger from '@/lib/logger.js';
import { isNumber, isEquals } from '@/lib/common.js'; import { isNumber, isEquals } from '@/lib/common.js';
import { getCategorizedAccounts, getAllFilteredAccountsBalance } from '@/lib/account.js'; import { getCategorizedAccountsMap, getAllFilteredAccountsBalance } from '@/lib/account.js';
function loadAccountList(state, accounts) { function loadAccountList(state, accounts) {
state.allAccounts = accounts; state.allAccounts = accounts;
@@ -28,7 +28,7 @@ function loadAccountList(state, accounts) {
} }
} }
state.allCategorizedAccounts = getCategorizedAccounts(accounts); state.allCategorizedAccounts = getCategorizedAccountsMap(accounts);
} }
function addAccountToAccountList(state, account) { function addAccountToAccountList(state, account) {
@@ -56,7 +56,7 @@ function addAccountToAccountList(state, account) {
const accountList = state.allCategorizedAccounts[account.category].accounts; const accountList = state.allCategorizedAccounts[account.category].accounts;
accountList.push(account); accountList.push(account);
} else { } else {
state.allCategorizedAccounts = getCategorizedAccounts(state.allAccounts); state.allCategorizedAccounts = getCategorizedAccountsMap(state.allAccounts);
} }
} }
+1 -1
View File
@@ -47,7 +47,7 @@
<v-main> <v-main>
<v-window class="d-flex flex-grow-1 disable-tab-transition w-100-window-container" v-model="activeTab"> <v-window class="d-flex flex-grow-1 disable-tab-transition w-100-window-container" v-model="activeTab">
<v-window-item value="accountPage"> <v-window-item value="accountPage">
<v-card variant="flat" min-height="680"> <v-card variant="flat" min-height="780">
<template #title> <template #title>
<div class="title-and-toolbar d-flex align-center"> <div class="title-and-toolbar d-flex align-center">
<v-btn class="mr-3 d-md-none" density="compact" color="default" variant="plain" <v-btn class="mr-3 d-md-none" density="compact" color="default" variant="plain"