From 5bb20f6d5f3ccefd0a524be22cb495e2b1d5979b Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Tue, 1 Mar 2022 21:32:19 +0100 Subject: [PATCH] Bugfix/fix undefined currencies after creating an activity (#731) * Fix issue with undefined currencies after creating an activity * Update changelog --- CHANGELOG.md | 4 ++++ apps/api/src/app/order/order.service.ts | 14 +++++++------- .../api/src/services/exchange-rate-data.service.ts | 6 +++++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 267584c2..8b9c2b0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added support for click in the portfolio proportion chart component +### Fixed + +- Fixed an issue with undefined currencies after creating an activity + ## 1.121.0 - 27.02.2022 ### Added diff --git a/apps/api/src/app/order/order.service.ts b/apps/api/src/app/order/order.service.ts index 16971ee3..2613c2c1 100644 --- a/apps/api/src/app/order/order.service.ts +++ b/apps/api/src/app/order/order.service.ts @@ -93,6 +93,13 @@ export class OrderService { data.SymbolProfile.connectOrCreate.create.symbol.toUpperCase(); } + await this.dataGatheringService.gatherProfileData([ + { + dataSource: data.dataSource, + symbol: data.SymbolProfile.connectOrCreate.create.symbol + } + ]); + const isDraft = isAfter(data.date as Date, endOfToday()); if (!isDraft) { @@ -106,13 +113,6 @@ export class OrderService { ]); } - this.dataGatheringService.gatherProfileData([ - { - dataSource: data.dataSource, - symbol: data.SymbolProfile.connectOrCreate.create.symbol - } - ]); - await this.cacheService.flush(); delete data.accountId; diff --git a/apps/api/src/services/exchange-rate-data.service.ts b/apps/api/src/services/exchange-rate-data.service.ts index 0770cf0c..8e639e7c 100644 --- a/apps/api/src/services/exchange-rate-data.service.ts +++ b/apps/api/src/services/exchange-rate-data.service.ts @@ -114,6 +114,10 @@ export class ExchangeRateDataService { aFromCurrency: string, aToCurrency: string ) { + if (aValue === 0) { + return 0; + } + const hasNaN = Object.values(this.exchangeRates).some((exchangeRate) => { return isNaN(exchangeRate); }); @@ -206,7 +210,7 @@ export class ExchangeRateDataService { currencies = currencies.concat(customCurrencies); } - return uniq(currencies).sort(); + return uniq(currencies).filter(Boolean).sort(); } private prepareCurrencyPairs(aCurrencies: string[]) {