From 41654058426dc8e7302e51cdf428e0cd11f45072 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Thu, 29 May 2025 20:06:32 +0200 Subject: [PATCH] Change investment value to take currency effects into account --- apps/api/src/app/portfolio/portfolio.service.ts | 10 +++++++--- .../holding-detail-dialog.component.ts | 14 ++++++++------ .../holding-detail-dialog.html | 4 ++-- .../portfolio-holding-response.interface.ts | 3 ++- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index 7e373c4cc..5f1130a92 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -663,7 +663,8 @@ export class PortfolioService { grossPerformancePercentWithCurrencyEffect: undefined, grossPerformanceWithCurrencyEffect: undefined, historicalData: [], - investment: undefined, + investmentInBaseCurrency: undefined, + investmentInBaseCurrencyWithCurrencyEffect: undefined, marketPrice: undefined, marketPriceMax: undefined, marketPriceMin: undefined, @@ -853,7 +854,9 @@ export class PortfolioService { grossPerformanceWithCurrencyEffect: position.grossPerformanceWithCurrencyEffect?.toNumber(), historicalData: historicalDataArray, - investment: position.investment?.toNumber(), + investmentInBaseCurrency: position.investment?.toNumber(), + investmentInBaseCurrencyWithCurrencyEffect: + position.investmentWithCurrencyEffect?.toNumber(), netPerformance: position.netPerformance?.toNumber(), netPerformancePercent: position.netPerformancePercentage?.toNumber(), netPerformancePercentWithCurrencyEffect: @@ -952,7 +955,8 @@ export class PortfolioService { grossPerformancePercentWithCurrencyEffect: undefined, grossPerformanceWithCurrencyEffect: undefined, historicalData: historicalDataArray, - investment: 0, + investmentInBaseCurrency: 0, + investmentInBaseCurrencyWithCurrencyEffect: 0, netPerformance: undefined, netPerformancePercent: undefined, netPerformancePercentWithCurrencyEffect: undefined, diff --git a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts b/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts index 028866009..d866275c0 100644 --- a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts +++ b/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts @@ -102,8 +102,8 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit { public hasPermissionToCreateOwnTag: boolean; public hasPermissionToReadMarketDataOfOwnAssetProfile: boolean; public historicalDataItems: LineChartItem[]; - public investment: number; - public investmentPrecision = 2; + public investmentInBaseCurrencyWithCurrencyEffect: number; + public investmentInBaseCurrencyWithCurrencyEffectPrecision = 2; public marketDataItems: MarketData[] = []; public marketPrice: number; public marketPriceMax: number; @@ -233,7 +233,7 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit { feeInBaseCurrency, firstBuyDate, historicalData, - investment, + investmentInBaseCurrencyWithCurrencyEffect, marketPrice, marketPriceMax, marketPriceMin, @@ -288,13 +288,15 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit { } ); - this.investment = investment; + this.investmentInBaseCurrencyWithCurrencyEffect = + investmentInBaseCurrencyWithCurrencyEffect; if ( this.data.deviceType === 'mobile' && - this.investment >= NUMERICAL_PRECISION_THRESHOLD + this.investmentInBaseCurrencyWithCurrencyEffect >= + NUMERICAL_PRECISION_THRESHOLD ) { - this.investmentPrecision = 0; + this.investmentInBaseCurrencyWithCurrencyEffectPrecision = 0; } this.marketPrice = marketPrice; diff --git a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html b/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html index 11898c44e..55ebbcd78 100644 --- a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html +++ b/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html @@ -146,9 +146,9 @@ size="medium" [isCurrency]="true" [locale]="data.locale" - [precision]="investmentPrecision" + [precision]="investmentInBaseCurrencyWithCurrencyEffectPrecision" [unit]="data.baseCurrency" - [value]="investment" + [value]="investmentInBaseCurrencyWithCurrencyEffect" >Investment diff --git a/libs/common/src/lib/interfaces/responses/portfolio-holding-response.interface.ts b/libs/common/src/lib/interfaces/responses/portfolio-holding-response.interface.ts index b330e8baa..0010e2747 100644 --- a/libs/common/src/lib/interfaces/responses/portfolio-holding-response.interface.ts +++ b/libs/common/src/lib/interfaces/responses/portfolio-holding-response.interface.ts @@ -22,7 +22,8 @@ export interface PortfolioHoldingResponse { grossPerformancePercentWithCurrencyEffect: number; grossPerformanceWithCurrencyEffect: number; historicalData: HistoricalDataItem[]; - investment: number; + investmentInBaseCurrency: number; + investmentInBaseCurrencyWithCurrencyEffect: number; marketPrice: number; marketPriceMax: number; marketPriceMin: number;