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. 15
      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( let unitPrices = Object.keys(marketSymbolMap).reduce(
(obj, date) => (obj, date) =>
(obj = Object.assign(obj, { [date]: marketSymbolMap[date][symbol] })), (obj = Object.assign(obj, {
[date]: marketSymbolMap[date][symbol]?.mul(exchangeRates[date])
})),
{} {}
); );

15
apps/api/src/app/portfolio/portfolio.service.ts

@ -317,14 +317,21 @@ export class PortfolioService {
withDataDecimation: false withDataDecimation: false
}); });
let investments = items.map( let investments: InvestmentItem[];
({ date, investmentValueWithCurrencyEffect }) => {
if (groupBy) {
investments = portfolioCalculator.getInvestmentsByGroup({
groupBy,
data: items
});
} else {
investments = items.map(({ date, investmentValueWithCurrencyEffect }) => {
return { return {
date, date,
investment: investmentValueWithCurrencyEffect investment: investmentValueWithCurrencyEffect
}; };
} });
); }
let streaks: PortfolioInvestments['streaks']; let streaks: PortfolioInvestments['streaks'];

Loading…
Cancel
Save