Bugfix/improve account calculations (#737)

* Improve account calculations

* Update changelog
This commit is contained in:
Thomas Kaul
2022-03-04 21:31:31 +01:00
committed by GitHub
parent 63ed227f3f
commit 3de7d3f60e
12 changed files with 128 additions and 84 deletions

View File

@@ -86,7 +86,7 @@
class="d-inline-block justify-content-end"
[isCurrency]="true"
[locale]="locale"
[value]="element.convertedBalance"
[value]="element.balance"
></gf-value>
</td>
<td *matFooterCellDef class="px-1 text-right" mat-footer-cell>
@@ -94,7 +94,7 @@
class="d-inline-block justify-content-end"
[isCurrency]="true"
[locale]="locale"
[value]="totalBalance"
[value]="totalBalanceInBaseCurrency"
></gf-value>
</td>
</ng-container>
@@ -116,7 +116,7 @@
class="d-inline-block justify-content-end"
[isCurrency]="true"
[locale]="locale"
[value]="totalValue"
[value]="totalValueInBaseCurrency"
></gf-value>
</td>
</ng-container>

View File

@@ -24,8 +24,8 @@ export class AccountsTableComponent implements OnChanges, OnDestroy, OnInit {
@Input() deviceType: string;
@Input() locale: string;
@Input() showActions: boolean;
@Input() totalBalance: number;
@Input() totalValue: number;
@Input() totalBalanceInBaseCurrency: number;
@Input() totalValueInBaseCurrency: number;
@Input() transactionCount: number;
@Output() accountDeleted = new EventEmitter<string>();

View File

@@ -28,8 +28,8 @@ export class AccountsPageComponent implements OnDestroy, OnInit {
public hasPermissionToCreateAccount: boolean;
public hasPermissionToDeleteAccount: boolean;
public routeQueryParams: Subscription;
public totalBalance = 0;
public totalValue = 0;
public totalBalanceInBaseCurrency = 0;
public totalValueInBaseCurrency = 0;
public transactionCount = 0;
public user: User;
@@ -106,18 +106,25 @@ export class AccountsPageComponent implements OnDestroy, OnInit {
this.dataService
.fetchAccounts()
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe(({ accounts, totalBalance, totalValue, transactionCount }) => {
this.accounts = accounts;
this.totalBalance = totalBalance;
this.totalValue = totalValue;
this.transactionCount = transactionCount;
.subscribe(
({
accounts,
totalBalanceInBaseCurrency,
totalValueInBaseCurrency,
transactionCount
}) => {
this.accounts = accounts;
this.totalBalanceInBaseCurrency = totalBalanceInBaseCurrency;
this.totalValueInBaseCurrency = totalValueInBaseCurrency;
this.transactionCount = transactionCount;
if (this.accounts?.length <= 0) {
this.router.navigate([], { queryParams: { createDialog: true } });
if (this.accounts?.length <= 0) {
this.router.navigate([], { queryParams: { createDialog: true } });
}
this.changeDetectorRef.markForCheck();
}
this.changeDetectorRef.markForCheck();
});
);
}
public onDeleteAccount(aId: string) {

View File

@@ -9,8 +9,8 @@
[deviceType]="deviceType"
[locale]="user?.settings?.locale"
[showActions]="!hasImpersonationId && hasPermissionToDeleteAccount && !user.settings.isRestrictedView"
[totalBalance]="totalBalance"
[totalValue]="totalValue"
[totalBalanceInBaseCurrency]="totalBalanceInBaseCurrency"
[totalValueInBaseCurrency]="totalValueInBaseCurrency"
[transactionCount]="transactionCount"
(accountDeleted)="onDeleteAccount($event)"
(accountToUpdate)="onUpdateAccount($event)"