account edit page displays the debt amount instead of the balance for credit card and debt accounts

This commit is contained in:
MaysWind
2025-02-11 00:45:23 +08:00
parent 18a6d25ed6
commit ab58109e5e
12 changed files with 133 additions and 28 deletions
+33 -4
View File
@@ -18,11 +18,12 @@ export class Account implements AccountInfoResponse {
public comment: string;
public creditCardStatementDate?: number;
public displayOrder: number;
public isAsset?: boolean;
public isLiability?: boolean;
public visible: boolean;
public subAccounts?: Account[];
private readonly _isAsset?: boolean;
private readonly _isLiability?: boolean;
protected constructor(id: string, name: string, parentId: string, category: number, type: number, icon: string, color: string, currency: string, balance: number, comment: string, displayOrder: number, visible: boolean, balanceTime?: number, creditCardStatementDate?: number, isAsset?: boolean, isLiability?: boolean, subAccounts?: Account[]) {
this.id = id;
this.name = name;
@@ -38,8 +39,8 @@ export class Account implements AccountInfoResponse {
this.displayOrder = displayOrder;
this.visible = visible;
this.creditCardStatementDate = creditCardStatementDate;
this.isAsset = isAsset;
this.isLiability = isLiability;
this._isAsset = isAsset;
this._isLiability = isLiability;
if (typeof(subAccounts) !== 'undefined') {
this.subAccounts = subAccounts;
@@ -48,6 +49,34 @@ export class Account implements AccountInfoResponse {
}
}
public get isAsset(): boolean {
if (typeof(this._isAsset) !== 'undefined') {
return this._isAsset;
}
const accountCategory = AccountCategory.valueOf(this.category);
if (accountCategory) {
return accountCategory.isAsset;
}
return false;
}
public get isLiability(): boolean {
if (typeof(this._isLiability) !== 'undefined') {
return this._isLiability;
}
const accountCategory = AccountCategory.valueOf(this.category);
if (accountCategory) {
return accountCategory.isLiability;
}
return false;
}
public get hidden(): boolean {
return !this.visible;
}