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> ></gf-value>
</div> </div>
</td> </td>
<td <td *matFooterCellDef class="d-none d-lg-table-cell px-1" mat-footer-cell>
*matFooterCellDef <div class="d-flex justify-content-end">
class="d-none d-lg-table-cell px-1" <gf-value
mat-footer-cell *ngIf="totalValue !== null"
></td> [isAbsolute]="true"
[isCurrency]="true"
[locale]="locale"
[value]="isLoading ? undefined : totalValue"
></gf-value>
</div>
</td>
</ng-container> </ng-container>
<ng-container matColumnDef="valueInBaseCurrency"> <ng-container matColumnDef="valueInBaseCurrency">
@ -294,11 +300,17 @@
></gf-value> ></gf-value>
</div> </div>
</td> </td>
<td <td *matFooterCellDef class="d-lg-none d-xl-none px-1" mat-footer-cell>
*matFooterCellDef <div class="d-flex justify-content-end">
class="d-lg-none d-xl-none px-1" <gf-value
mat-footer-cell *ngIf="totalValue !== null"
></td> [isAbsolute]="true"
[isCurrency]="true"
[locale]="locale"
[value]="isLoading ? undefined : totalValue"
></gf-value>
</div>
</td>
</ng-container> </ng-container>
<ng-container matColumnDef="account"> <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 searchKeywords: string[] = [];
public separatorKeysCodes: number[] = [ENTER, COMMA]; public separatorKeysCodes: number[] = [ENTER, COMMA];
public totalFees: number; public totalFees: number;
public totalValue: number;
private allFilters: string[]; private allFilters: string[];
private unsubscribeSubject = new Subject<void>(); private unsubscribeSubject = new Subject<void>();
@ -251,6 +252,7 @@ export class ActivitiesTableComponent implements OnChanges, OnDestroy {
return activity.isDraft === true; return activity.isDraft === true;
}); });
this.totalFees = this.getTotalFees(); this.totalFees = this.getTotalFees();
this.totalValue = this.getTotalValue();
} }
private getSearchableFieldValues(activities: OrderWithAccount[]): string[] { private getSearchableFieldValues(activities: OrderWithAccount[]): string[] {
@ -314,4 +316,22 @@ export class ActivitiesTableComponent implements OnChanges, OnDestroy {
return totalFees.toNumber(); 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