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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
14 additions and
5 deletions
-
apps/api/src/app/portfolio/portfolio-calculator.ts
-
apps/api/src/app/portfolio/portfolio.service.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]) |
|
|
|
|
|
})), |
|
|
{} |
|
|
{} |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
@ -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']; |
|
|
|
|
|
|
|
|