Browse Source

code review changes

pull/5335/head
Attila Cseh 2 weeks ago
parent
commit
7774a6333e
  1. 21
      apps/api/src/app/portfolio/portfolio.service.ts

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

@ -176,31 +176,37 @@ export class PortfolioService {
const userCurrency = this.request.user.settings.settings.baseCurrency; const userCurrency = this.request.user.settings.settings.baseCurrency;
return accounts.map((account) => { return Promise.all(
accounts.map(async (account) => {
let dividendInBaseCurrency = 0; let dividendInBaseCurrency = 0;
let interestInBaseCurrency = 0; let interestInBaseCurrency = 0;
let transactionCount = 0; let transactionCount = 0;
for (const { for (const {
isDraft,
currency, currency,
date,
isDraft,
SymbolProfile, SymbolProfile,
type, type,
unitPrice unitPrice
} of account.activities) { } of account.activities) {
switch (type) { switch (type) {
case ActivityType.DIVIDEND: case ActivityType.DIVIDEND:
dividendInBaseCurrency += this.exchangeRateDataService.toCurrency( dividendInBaseCurrency +=
await this.exchangeRateDataService.toCurrencyAtDate(
unitPrice, unitPrice,
currency ?? SymbolProfile.currency, currency ?? SymbolProfile.currency,
userCurrency userCurrency,
date
); );
break; break;
case ActivityType.INTEREST: case ActivityType.INTEREST:
interestInBaseCurrency += this.exchangeRateDataService.toCurrency( interestInBaseCurrency +=
await this.exchangeRateDataService.toCurrencyAtDate(
unitPrice, unitPrice,
currency ?? SymbolProfile.currency, currency ?? SymbolProfile.currency,
userCurrency userCurrency,
date
); );
break; break;
} }
@ -235,7 +241,8 @@ export class PortfolioService {
delete result.activities; delete result.activities;
return result; return result;
}); })
);
} }
public async getAccountsWithAggregations({ public async getAccountsWithAggregations({

Loading…
Cancel
Save