Browse Source

Fix issue with undefined currencies after creating an activity

pull/731/head
Thomas 3 years ago
parent
commit
29fc2bbfe5
  1. 14
      apps/api/src/app/order/order.service.ts
  2. 6
      apps/api/src/services/exchange-rate-data.service.ts

14
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;

6
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[]) {

Loading…
Cancel
Save