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