Browse Source

Do not show total value if sell activity

pull/826/head
Thomas 3 years ago
parent
commit
80132ba267
  1. 32
      libs/ui/src/lib/activities-table/activities-table.component.html
  2. 20
      libs/ui/src/lib/activities-table/activities-table.component.ts

32
libs/ui/src/lib/activities-table/activities-table.component.html

@ -268,11 +268,17 @@
></gf-value>
</div>
</td>
<td
*matFooterCellDef
class="d-none d-lg-table-cell px-1"
mat-footer-cell
></td>
<td *matFooterCellDef class="d-none d-lg-table-cell px-1" mat-footer-cell>
<div class="d-flex justify-content-end">
<gf-value
*ngIf="totalValue !== null"
[isAbsolute]="true"
[isCurrency]="true"
[locale]="locale"
[value]="isLoading ? undefined : totalValue"
></gf-value>
</div>
</td>
</ng-container>
<ng-container matColumnDef="valueInBaseCurrency">
@ -294,11 +300,17 @@
></gf-value>
</div>
</td>
<td
*matFooterCellDef
class="d-lg-none d-xl-none px-1"
mat-footer-cell
></td>
<td *matFooterCellDef class="d-lg-none d-xl-none px-1" mat-footer-cell>
<div class="d-flex justify-content-end">
<gf-value
*ngIf="totalValue !== null"
[isAbsolute]="true"
[isCurrency]="true"
[locale]="locale"
[value]="isLoading ? undefined : totalValue"
></gf-value>
</div>
</td>
</ng-container>
<ng-container matColumnDef="account">

20
libs/ui/src/lib/activities-table/activities-table.component.ts

@ -79,6 +79,7 @@ export class ActivitiesTableComponent implements OnChanges, OnDestroy {
public searchKeywords: string[] = [];
public separatorKeysCodes: number[] = [ENTER, COMMA];
public totalFees: number;
public totalValue: number;
private allFilters: string[];
private unsubscribeSubject = new Subject<void>();
@ -251,6 +252,7 @@ export class ActivitiesTableComponent implements OnChanges, OnDestroy {
return activity.isDraft === true;
});
this.totalFees = this.getTotalFees();
this.totalValue = this.getTotalValue();
}
private getSearchableFieldValues(activities: OrderWithAccount[]): string[] {
@ -314,4 +316,22 @@ export class ActivitiesTableComponent implements OnChanges, OnDestroy {
return totalFees.toNumber();
}
private getTotalValue() {
let totalValue = new Big(0);
for (const activity of this.dataSource.filteredData) {
if (isNumber(activity.valueInBaseCurrency)) {
if (activity.type === 'BUY' || activity.type === 'ITEM') {
totalValue = totalValue.plus(activity.valueInBaseCurrency);
} else if (activity.type === 'SELL') {
return null;
}
} else {
return null;
}
}
return totalValue.toNumber();
}
}

Loading…
Cancel
Save