fix the wrong account balance in transaction edit page due to #a0e3a269a0098d05fa1a17eee4cce393869fc5cc

This commit is contained in:
MaysWind
2025-02-12 01:25:46 +08:00
parent 2e01e5530c
commit 0ca2f8b4a7
2 changed files with 32 additions and 2 deletions
+31
View File
@@ -235,6 +235,27 @@ export class Account implements AccountInfoResponse {
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 {
return new Account(
'', // id
@@ -315,6 +336,16 @@ export class Account implements AccountInfoResponse {
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[] {
if (!accounts || !accounts.length) {
return accounts;