From d56d6f944fb060fb802f76852c51001606645eb8 Mon Sep 17 00:00:00 2001 From: Daniel Devaud Date: Sat, 23 Mar 2024 08:54:21 +0100 Subject: [PATCH] Fix GroupBy for investment --- apps/api/src/app/portfolio/portfolio.service.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index d0baa06b8..082721701 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -317,14 +317,21 @@ export class PortfolioService { withDataDecimation: false }); - let investments = items.map( - ({ date, investmentValueWithCurrencyEffect }) => { + let investments: InvestmentItem[]; + + if (groupBy) { + investments = portfolioCalculator.getInvestmentsByGroup({ + groupBy, + data: items + }); + } else { + investments = items.map(({ date, investmentValueWithCurrencyEffect }) => { return { date, investment: investmentValueWithCurrencyEffect }; - } - ); + }); + } let streaks: PortfolioInvestments['streaks'];