Browse Source

Add investment value to chart

pull/2948/head
Thomas Kaul 2 years ago
parent
commit
bb1faf3854
  1. 4
      apps/api/src/app/portfolio/portfolio-calculator.ts
  2. 11
      apps/api/src/app/portfolio/portfolio.service.ts

4
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(),

11
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) {

Loading…
Cancel
Save