Browse Source

Fix return of TotalDaysInvested

pull/5027/head
Daniel Devaud 1 year ago
parent
commit
f6d8d759c9
  1. 15
      apps/api/src/app/portfolio/portfolio-calculator.ts

15
apps/api/src/app/portfolio/portfolio-calculator.ts

@ -422,7 +422,6 @@ export class PortfolioCalculator {
accumulatedValuesByDate accumulatedValuesByDate
); );
} }
let values;
const { const {
investmentValueWithCurrencyEffect, investmentValueWithCurrencyEffect,
@ -1443,7 +1442,8 @@ export class PortfolioCalculator {
averagePriceAtEndDate, averagePriceAtEndDate,
initialValue, initialValue,
fees, fees,
netPerformanceValuesPercentage netPerformanceValuesPercentage,
totalInvestmentDays
} = this.handleOrders( } = this.handleOrders(
orders, orders,
indexOfStartOrder, indexOfStartOrder,
@ -1757,7 +1757,8 @@ export class PortfolioCalculator {
grossPerformance.WithCurrencyEffect; grossPerformance.WithCurrencyEffect;
} }
this.calculatePerformancesForDate( totalInvestmentDays =
this.calculatePerformancesForDateAndReturnTotalInvestmentDays(
isChartMode, isChartMode,
i, i,
indexOfStartOrder, indexOfStartOrder,
@ -1811,7 +1812,8 @@ export class PortfolioCalculator {
averagePriceAtEndDate, averagePriceAtEndDate,
initialValue, initialValue,
fees, fees,
netPerformanceValuesPercentage netPerformanceValuesPercentage,
totalInvestmentDays
}; };
} }
@ -2147,7 +2149,7 @@ export class PortfolioCalculator {
}; };
} }
private calculatePerformancesForDate( private calculatePerformancesForDateAndReturnTotalInvestmentDays(
isChartMode: boolean, isChartMode: boolean,
i: number, i: number,
indexOfStartOrder: number, indexOfStartOrder: number,
@ -2171,7 +2173,7 @@ export class PortfolioCalculator {
investmentAtStartDate: WithCurrencyEffect<Big>, investmentAtStartDate: WithCurrencyEffect<Big>,
totalInvestmentBeforeTransaction: WithCurrencyEffect<Big>, totalInvestmentBeforeTransaction: WithCurrencyEffect<Big>,
transactionInvestmentWithCurrencyEffect: Big transactionInvestmentWithCurrencyEffect: Big
) { ): number {
if (i > indexOfStartOrder) { if (i > indexOfStartOrder) {
if (valueOfInvestmentBeforeTransaction.Value.gt(0)) { if (valueOfInvestmentBeforeTransaction.Value.gt(0)) {
// Calculate the number of days since the previous order // Calculate the number of days since the previous order
@ -2246,6 +2248,7 @@ export class PortfolioCalculator {
: new Big(0); : new Big(0);
} }
} }
return totalInvestmentDays;
} }
private calculateSellOrders( private calculateSellOrders(

Loading…
Cancel
Save