From fc32b392e38c81f5a93ada4536aa91553c9ef5e3 Mon Sep 17 00:00:00 2001 From: Daniel Devaud Date: Tue, 20 Feb 2024 21:36:22 +0100 Subject: [PATCH] FIx BALN Test --- .../src/app/portfolio/portfolio-calculator.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/apps/api/src/app/portfolio/portfolio-calculator.ts b/apps/api/src/app/portfolio/portfolio-calculator.ts index d0b126452..7aea93b71 100644 --- a/apps/api/src/app/portfolio/portfolio-calculator.ts +++ b/apps/api/src/app/portfolio/portfolio-calculator.ts @@ -1157,10 +1157,7 @@ export class PortfolioCalculator { Value: new Big(0), WithCurrencyEffect: new Big(0) }; - let investmentAtStartDate: WithCurrencyEffect = { - Value: new Big(0), - WithCurrencyEffect: new Big(0) - }; + let investmentAtStartDate; const investmentValuesAccumulated: WithCurrencyEffect<{ [date: string]: Big; }> = { @@ -2053,15 +2050,12 @@ export class PortfolioCalculator { order.unitPriceInBaseCurrencyWithCurrencyEffect ) }; - if ( - (investmentAtStartDate.Value?.eq(0) ?? true) && - i >= indexOfStartOrder - ) { - investmentAtStartDate.Value = totalInvestment.Value ?? new Big(0); + if (!investmentAtStartDate && i >= indexOfStartOrder) { + investmentAtStartDate = { + Value: totalInvestment.Value ?? new Big(0), + WithCurrencyEffect: totalInvestment.WithCurrencyEffect ?? new Big(0) + }; valueAtStartDate.Value = valueOfInvestmentBeforeTransaction.Value; - investmentAtStartDate.WithCurrencyEffect = - totalInvestment.WithCurrencyEffect ?? new Big(0); - valueAtStartDate.WithCurrencyEffect = valueOfInvestmentBeforeTransaction.WithCurrencyEffect; }