From a11ff0400ecad8be627fb6025bcf528d09dfb276 Mon Sep 17 00:00:00 2001 From: Daniel Devaud Date: Tue, 20 Feb 2024 22:01:50 +0100 Subject: [PATCH] Fix empty transaction point error --- .../src/app/portfolio/portfolio-calculator.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/api/src/app/portfolio/portfolio-calculator.ts b/apps/api/src/app/portfolio/portfolio-calculator.ts index 823545c5a..08b350598 100644 --- a/apps/api/src/app/portfolio/portfolio-calculator.ts +++ b/apps/api/src/app/portfolio/portfolio-calculator.ts @@ -669,13 +669,15 @@ export class PortfolioCalculator { currencies: { [symbol: string]: string }, symbols: { [symbol: string]: boolean } ) { - for (const item of transactionPointsBeforeEndDate[firstIndex - 1].items) { - dataGatheringItems.push({ - dataSource: item.dataSource, - symbol: item.symbol - }); - currencies[item.symbol] = item.currency; - symbols[item.symbol] = true; + if (transactionPointsBeforeEndDate.length > 0) { + for (const item of transactionPointsBeforeEndDate[firstIndex - 1].items) { + dataGatheringItems.push({ + dataSource: item.dataSource, + symbol: item.symbol + }); + currencies[item.symbol] = item.currency; + symbols[item.symbol] = true; + } } }