Browse Source

Merge pull request #80 from dandevaud/bugfix/fix-GroupBy-for-investment

Bugfix/fix group by for investment
pull/5027/head
dandevaud 1 year ago
committed by GitHub
parent
commit
dfee21dc3c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      apps/api/src/app/portfolio/portfolio-calculator.ts
  2. 13
      apps/api/src/app/portfolio/portfolio.service.ts

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

@ -1382,7 +1382,9 @@ export class PortfolioCalculator {
let unitPrices = Object.keys(marketSymbolMap).reduce(
(obj, date) =>
(obj = Object.assign(obj, { [date]: marketSymbolMap[date][symbol] })),
(obj = Object.assign(obj, {
[date]: marketSymbolMap[date][symbol]?.mul(exchangeRates[date])
})),
{}
);

13
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'];

Loading…
Cancel
Save