Browse Source

Refactoring

pull/3039/head
Thomas Kaul 2 years ago
parent
commit
bde27116b3
  1. 12
      apps/api/src/app/portfolio/portfolio.controller.ts

12
apps/api/src/app/portfolio/portfolio.controller.ts

@ -117,7 +117,6 @@ export class PortfolioController {
hasReadRestrictedAccessPermission || hasReadRestrictedAccessPermission ||
this.userService.isRestrictedView(this.request.user) this.userService.isRestrictedView(this.request.user)
) { ) {
// TODO: Introduce calculations with currency effect
const totalInvestment = Object.values(holdings) const totalInvestment = Object.values(holdings)
.map(({ investment }) => { .map(({ investment }) => {
return investment; return investment;
@ -125,12 +124,11 @@ export class PortfolioController {
.reduce((a, b) => a + b, 0); .reduce((a, b) => a + b, 0);
const totalValue = Object.values(holdings) const totalValue = Object.values(holdings)
.map(({ currency, marketPrice, quantity }) => { .filter(({ assetClass, assetSubClass }) => {
return this.exchangeRateDataService.toCurrency( return assetClass !== 'CASH' && assetSubClass !== 'CASH';
quantity * marketPrice, })
currency, .map(({ valueInBaseCurrency }) => {
this.request.user.Settings.settings.baseCurrency return valueInBaseCurrency;
);
}) })
.reduce((a, b) => a + b, 0); .reduce((a, b) => a + b, 0);

Loading…
Cancel
Save