diff --git a/CHANGELOG.md b/CHANGELOG.md index e76ae0198..09d2f8d75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -426,6 +426,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Fixed a crash on the _Overview_, _Portfolio_ and _Holdings_ pages when exchange rate data is missing (e.g. before the data gathering job completes) - Fixed an issue with the detection of the thousand separator for the `de-CH` locale - Fixed an issue in the _Storybook_ stories of the symbol autocomplete component caused by a circular dependency diff --git a/apps/api/src/app/activities/activities.service.ts b/apps/api/src/app/activities/activities.service.ts index f57507e3d..34e4df7fc 100644 --- a/apps/api/src/app/activities/activities.service.ts +++ b/apps/api/src/app/activities/activities.service.ts @@ -750,32 +750,34 @@ export class ActivitiesService { feeInBaseCurrency, unitPriceInAssetProfileCurrency, valueInBaseCurrency - ] = await Promise.all([ - this.exchangeRateDataService.toCurrencyAtDate( - order.fee, - order.currency ?? order.SymbolProfile.currency, - order.SymbolProfile.currency, - order.date - ), - this.exchangeRateDataService.toCurrencyAtDate( - order.fee, - order.currency ?? order.SymbolProfile.currency, - userCurrency, - order.date - ), - this.exchangeRateDataService.toCurrencyAtDate( - order.unitPrice, - order.currency ?? order.SymbolProfile.currency, - order.SymbolProfile.currency, - order.date - ), - this.exchangeRateDataService.toCurrencyAtDate( - value, - order.currency ?? order.SymbolProfile.currency, - userCurrency, - order.date - ) - ]); + ] = ( + await Promise.all([ + this.exchangeRateDataService.toCurrencyAtDate( + order.fee, + order.currency ?? order.SymbolProfile.currency, + order.SymbolProfile.currency, + order.date + ), + this.exchangeRateDataService.toCurrencyAtDate( + order.fee, + order.currency ?? order.SymbolProfile.currency, + userCurrency, + order.date + ), + this.exchangeRateDataService.toCurrencyAtDate( + order.unitPrice, + order.currency ?? order.SymbolProfile.currency, + order.SymbolProfile.currency, + order.date + ), + this.exchangeRateDataService.toCurrencyAtDate( + value, + order.currency ?? order.SymbolProfile.currency, + userCurrency, + order.date + ) + ]) + ).map((result) => result ?? 0); return { ...order, diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index 418e60401..77cbb5b49 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -205,21 +205,21 @@ export class PortfolioService { switch (type) { case ActivityType.DIVIDEND: dividendInBaseCurrency += - await this.exchangeRateDataService.toCurrencyAtDate( + (await this.exchangeRateDataService.toCurrencyAtDate( new Big(quantity).mul(unitPrice).toNumber(), currency ?? SymbolProfile.currency, userCurrency, date - ); + )) ?? 0; break; case ActivityType.INTEREST: interestInBaseCurrency += - await this.exchangeRateDataService.toCurrencyAtDate( + (await this.exchangeRateDataService.toCurrencyAtDate( unitPrice, currency ?? SymbolProfile.currency, userCurrency, date - ); + )) ?? 0; break; } diff --git a/apps/api/src/services/exchange-rate-data/exchange-rate-data.service.ts b/apps/api/src/services/exchange-rate-data/exchange-rate-data.service.ts index 3b48ce292..054430b8b 100644 --- a/apps/api/src/services/exchange-rate-data/exchange-rate-data.service.ts +++ b/apps/api/src/services/exchange-rate-data/exchange-rate-data.service.ts @@ -365,7 +365,7 @@ export class ExchangeRateDataService { )}` ); - return undefined; + return 0; } private async getExchangeRates({