Browse Source

Filter order types

pull/547/head
Thomas 4 years ago
parent
commit
cba0c7e8ee
  1. 12
      apps/api/src/app/portfolio/portfolio.service.ts
  2. 28
      apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html

12
apps/api/src/app/portfolio/portfolio.service.ts

@ -369,9 +369,9 @@ export class PortfolioService {
): Promise<PortfolioPositionDetail> {
const userId = await this.getUserId(aImpersonationId, this.request.user.id);
const orders = (
await this.orderService.getOrders({ userId, types: ['BUY', 'SELL'] })
).filter((order) => order.symbol === aSymbol);
const orders = (await this.orderService.getOrders({ userId })).filter(
(order) => order.symbol === aSymbol
);
if (orders.length <= 0) {
return {
@ -401,7 +401,11 @@ export class PortfolioService {
const positionCurrency = orders[0].currency;
const name = orders[0].SymbolProfile?.name ?? '';
const portfolioOrders: PortfolioOrder[] = orders.map((order) => ({
const portfolioOrders: PortfolioOrder[] = orders
.filter((order) => {
return order.type === 'BUY' || order.type === 'SELL';
})
.map((order) => ({
currency: order.currency,
dataSource: order.dataSource,
date: format(order.date, DATE_FORMAT),

28
apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html

@ -48,20 +48,6 @@
></gf-value>
</div>
</div>
<div class="row px-3 py-1">
<div class="d-flex flex-grow-1" i18n>Dividend</div>
<div class="d-flex justify-content-end">
<span *ngIf="summary?.dividend || summary?.dividend === 0" class="mr-1"
>+</span
>
<gf-value
class="justify-content-end"
[currency]="baseCurrency"
[locale]="locale"
[value]="isLoading ? undefined : summary?.dividend"
></gf-value>
</div>
</div>
<div class="row px-3 py-1">
<div class="d-flex flex-grow-1" i18n>Absolute Gross Performance</div>
<div class="d-flex justify-content-end">
@ -183,4 +169,18 @@
></gf-value>
</div>
</div>
<div class="row">
<div class="col"><hr /></div>
</div>
<div class="row px-3 py-1">
<div class="d-flex flex-grow-1" i18n>Dividend</div>
<div class="d-flex justify-content-end">
<gf-value
class="justify-content-end"
[currency]="baseCurrency"
[locale]="locale"
[value]="isLoading ? undefined : summary?.dividend"
></gf-value>
</div>
</div>
</div>

Loading…
Cancel
Save