From 72067459d621f8cda85e6049d59bce9b0f85e5a6 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 27 Nov 2021 09:51:08 +0100 Subject: [PATCH] Feature/add value to position detail dialog (#492) * Add value to position detail dialog * Update changelog --- CHANGELOG.md | 4 ++++ .../portfolio-position-detail.interface.ts | 1 + .../src/app/portfolio/portfolio.controller.ts | 3 ++- .../src/app/portfolio/portfolio.service.ts | 13 ++++++++++--- .../dialog-header.component.html | 6 +++++- .../dialog-header/dialog-header.component.ts | 1 + .../position-detail-dialog.component.ts | 5 ++++- .../position-detail-dialog.html | 12 ++++++++++++ libs/ui/src/lib/value/value.component.html | 19 +++++++++++++++---- libs/ui/src/lib/value/value.component.ts | 2 +- 10 files changed, 55 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46a940772..3bdae6e2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Added the value to the position detail dialog + ### Changed - Upgraded `angular` from version `12.2.4` to `13.0.2` diff --git a/apps/api/src/app/portfolio/interfaces/portfolio-position-detail.interface.ts b/apps/api/src/app/portfolio/interfaces/portfolio-position-detail.interface.ts index 336e5a2d4..069230983 100644 --- a/apps/api/src/app/portfolio/interfaces/portfolio-position-detail.interface.ts +++ b/apps/api/src/app/portfolio/interfaces/portfolio-position-detail.interface.ts @@ -19,6 +19,7 @@ export interface PortfolioPositionDetail { quantity: number; symbol: string; transactionCount: number; + value: number; } export interface HistoricalDataContainer { diff --git a/apps/api/src/app/portfolio/portfolio.controller.ts b/apps/api/src/app/portfolio/portfolio.controller.ts index 362badb8e..f4578e070 100644 --- a/apps/api/src/app/portfolio/portfolio.controller.ts +++ b/apps/api/src/app/portfolio/portfolio.controller.ts @@ -370,7 +370,8 @@ export class PortfolioController { 'grossPerformance', 'investment', 'netPerformance', - 'quantity' + 'quantity', + 'value' ]); } diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index e6279d1f4..76bf34f14 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -391,7 +391,8 @@ export class PortfolioService { netPerformancePercent: undefined, quantity: undefined, symbol: aSymbol, - transactionCount: undefined + transactionCount: undefined, + value: undefined }; } @@ -527,7 +528,12 @@ export class PortfolioService { historicalData: historicalDataArray, netPerformancePercent: position.netPerformancePercentage.toNumber(), quantity: quantity.toNumber(), - symbol: aSymbol + symbol: aSymbol, + value: this.exchangeRateDataService.toCurrency( + quantity.mul(marketPrice).toNumber(), + currency, + userCurrency + ) }; } else { const currentData = await this.dataProviderService.get([ @@ -584,7 +590,8 @@ export class PortfolioService { netPerformancePercent: undefined, quantity: 0, symbol: aSymbol, - transactionCount: undefined + transactionCount: undefined, + value: 0 }; } } diff --git a/apps/client/src/app/components/dialog-header/dialog-header.component.html b/apps/client/src/app/components/dialog-header/dialog-header.component.html index 0b683f9b9..c39c2ca7b 100644 --- a/apps/client/src/app/components/dialog-header/dialog-header.component.html +++ b/apps/client/src/app/components/dialog-header/dialog-header.component.html @@ -1,4 +1,8 @@ -{{ title }} +{{ title }}