From cba0c7e8eef5c71d77830cfcfebc200dde8c57b5 Mon Sep 17 00:00:00 2001 From: Thomas <4159106+dtslvr@users.noreply.github.com> Date: Tue, 28 Dec 2021 20:50:24 +0100 Subject: [PATCH] Filter order types --- .../src/app/portfolio/portfolio.service.ts | 32 +++++++++++-------- .../portfolio-summary.component.html | 28 ++++++++-------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index 738846680..e9be3d0a2 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -369,9 +369,9 @@ export class PortfolioService { ): Promise { 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,17 +401,21 @@ export class PortfolioService { const positionCurrency = orders[0].currency; const name = orders[0].SymbolProfile?.name ?? ''; - const portfolioOrders: PortfolioOrder[] = orders.map((order) => ({ - currency: order.currency, - dataSource: order.dataSource, - date: format(order.date, DATE_FORMAT), - fee: new Big(order.fee), - name: order.SymbolProfile?.name, - quantity: new Big(order.quantity), - symbol: order.symbol, - type: order.type, - unitPrice: new Big(order.unitPrice) - })); + 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), + fee: new Big(order.fee), + name: order.SymbolProfile?.name, + quantity: new Big(order.quantity), + symbol: order.symbol, + type: order.type, + unitPrice: new Big(order.unitPrice) + })); const portfolioCalculator = new PortfolioCalculator( this.currentRateService, diff --git a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html index 69fc2111c..c9c34cd03 100644 --- a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html +++ b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html @@ -48,20 +48,6 @@ > -
-
Dividend
-
- + - -
-
Absolute Gross Performance
@@ -183,4 +169,18 @@ >
+
+

+
+
+
Dividend
+
+ +
+