From bb1faf3854b5c2936a0206208be1c26373b70d24 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Tue, 30 Jan 2024 20:55:59 +0100 Subject: [PATCH] Add investment value to chart --- apps/api/src/app/portfolio/portfolio-calculator.ts | 4 ++++ apps/api/src/app/portfolio/portfolio.service.ts | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/apps/api/src/app/portfolio/portfolio-calculator.ts b/apps/api/src/app/portfolio/portfolio-calculator.ts index 93474ffa5..af076f6f0 100644 --- a/apps/api/src/app/portfolio/portfolio-calculator.ts +++ b/apps/api/src/app/portfolio/portfolio-calculator.ts @@ -248,6 +248,7 @@ export class PortfolioCalculator { const accumulatedValuesByDate: { [date: string]: { + investmentValue: Big; totalCurrentValue: Big; totalCurrentValueWithCurrencyEffect: Big; totalInvestmentValue: Big; @@ -341,6 +342,7 @@ export class PortfolioCalculator { ] ?? new Big(0); accumulatedValuesByDate[dateString] = { + investmentValue, totalCurrentValue: ( accumulatedValuesByDate[dateString]?.totalCurrentValue ?? new Big(0) ).add(currentValue), @@ -378,6 +380,7 @@ export class PortfolioCalculator { return Object.entries(accumulatedValuesByDate).map(([date, values]) => { const { + investmentValue, totalCurrentValue, totalCurrentValueWithCurrencyEffect, totalInvestmentValue, @@ -407,6 +410,7 @@ export class PortfolioCalculator { date, netPerformanceInPercentage, netPerformanceInPercentageWithCurrencyEffect, + investment: investmentValue.toNumber(), netPerformance: totalNetPerformanceValue.toNumber(), netPerformanceWithCurrencyEffect: totalNetPerformanceValueWithCurrencyEffect.toNumber(), diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index 580068e7a..3267fc490 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -293,6 +293,17 @@ export class PortfolioService { portfolioCalculator.setTransactionPoints(transactionPoints); + const chartData = await this.getChart({ + dateRange, + impersonationId, + portfolioOrders, + transactionPoints, + userId, + userCurrency: this.request.user.Settings.settings.baseCurrency + }); + + console.log(chartData.items); + let investments: InvestmentItem[]; if (groupBy) {