mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-18 16:54:25 +08:00
fix the wrong account balance in transaction edit page due to #a0e3a269a0098d05fa1a17eee4cce393869fc5cc
This commit is contained in:
@@ -111,7 +111,6 @@ import {
|
|||||||
isString,
|
isString,
|
||||||
isNumber,
|
isNumber,
|
||||||
isBoolean,
|
isBoolean,
|
||||||
copyObjectTo,
|
|
||||||
copyArrayTo
|
copyArrayTo
|
||||||
} from '@/lib/common.ts';
|
} from '@/lib/common.ts';
|
||||||
|
|
||||||
@@ -1471,7 +1470,7 @@ export function useI18n() {
|
|||||||
const ret: CategorizedAccountWithDisplayBalance[] = [];
|
const ret: CategorizedAccountWithDisplayBalance[] = [];
|
||||||
const defaultCurrency = userStore.currentUserDefaultCurrency;
|
const defaultCurrency = userStore.currentUserDefaultCurrency;
|
||||||
const allCategories = AccountCategory.values();
|
const allCategories = AccountCategory.values();
|
||||||
const categorizedAccounts: Record<number, CategorizedAccount> = copyObjectTo(getCategorizedAccountsMap(allVisibleAccounts), {}) as Record<number, CategorizedAccount>;
|
const categorizedAccounts: Record<number, CategorizedAccount> = getCategorizedAccountsMap(Account.cloneAccounts(allVisibleAccounts));
|
||||||
|
|
||||||
for (let i = 0; i < allCategories.length; i++) {
|
for (let i = 0; i < allCategories.length; i++) {
|
||||||
const category = allCategories[i];
|
const category = allCategories[i];
|
||||||
|
|||||||
@@ -235,6 +235,27 @@ export class Account implements AccountInfoResponse {
|
|||||||
return subAccountCurrencies;
|
return subAccountCurrencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public clone(): Account {
|
||||||
|
return new Account(
|
||||||
|
this.id,
|
||||||
|
this.name,
|
||||||
|
this.parentId,
|
||||||
|
this.category,
|
||||||
|
this.type,
|
||||||
|
this.icon,
|
||||||
|
this.color,
|
||||||
|
this.currency,
|
||||||
|
this.balance,
|
||||||
|
this.comment,
|
||||||
|
this.displayOrder,
|
||||||
|
this.visible,
|
||||||
|
this.balanceTime,
|
||||||
|
this.creditCardStatementDate,
|
||||||
|
this.isAsset,
|
||||||
|
this.isLiability,
|
||||||
|
typeof(this.subAccounts) !== 'undefined' ? Account.cloneAccounts(this.subAccounts) : undefined);
|
||||||
|
}
|
||||||
|
|
||||||
public createNewSubAccount(currency: string, balanceTime: number): Account {
|
public createNewSubAccount(currency: string, balanceTime: number): Account {
|
||||||
return new Account(
|
return new Account(
|
||||||
'', // id
|
'', // id
|
||||||
@@ -315,6 +336,16 @@ export class Account implements AccountInfoResponse {
|
|||||||
return defaultName;
|
return defaultName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static cloneAccounts(accounts: Account[]): Account[] {
|
||||||
|
const clonedAccounts: Account[] = [];
|
||||||
|
|
||||||
|
for (const account of accounts) {
|
||||||
|
clonedAccounts.push(account.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
return clonedAccounts;
|
||||||
|
}
|
||||||
|
|
||||||
public static sortAccounts(accounts: Account[]): Account[] {
|
public static sortAccounts(accounts: Account[]): Account[] {
|
||||||
if (!accounts || !accounts.length) {
|
if (!accounts || !accounts.length) {
|
||||||
return accounts;
|
return accounts;
|
||||||
|
|||||||
Reference in New Issue
Block a user