From 7ba6340a788555fd3600f6444f7d05210d456fb2 Mon Sep 17 00:00:00 2001 From: Thomas <4159106+dtslvr@users.noreply.github.com> Date: Tue, 1 Aug 2023 08:47:17 +0200 Subject: [PATCH] Refactoring --- apps/api/src/app/import/import.service.ts | 24 +++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/apps/api/src/app/import/import.service.ts b/apps/api/src/app/import/import.service.ts index 96d0262bf..b3456c115 100644 --- a/apps/api/src/app/import/import.service.ts +++ b/apps/api/src/app/import/import.service.ts @@ -255,10 +255,20 @@ export class ImportService { error, fee, quantity, - SymbolProfile: assetProfile, + SymbolProfile, type, unitPrice } of activitiesExtendedWithErrors) { + const assetProfile = assetProfiles[ + getAssetProfileIdentifier({ + dataSource: SymbolProfile.dataSource, + symbol: SymbolProfile.symbol + }) + ] ?? { + currency: SymbolProfile.currency, + dataSource: SymbolProfile.dataSource, + symbol: SymbolProfile.symbol + }; const validatedAccount = accounts.find(({ id }) => { return id === accountId; }); @@ -296,16 +306,10 @@ export class ImportService { name: assetProfile.name, scraperConfiguration: assetProfile.scraperConfiguration, sectors: assetProfile.sectors, - symbol: assetProfile.currency, + symbol: assetProfile.symbol, symbolMapping: assetProfile.symbolMapping, updatedAt: assetProfile.updatedAt, - url: assetProfile.url, - ...assetProfiles[ - getAssetProfileIdentifier({ - dataSource: assetProfile.dataSource, - symbol: assetProfile.symbol - }) - ] + url: assetProfile.url }, Account: validatedAccount, symbolProfileId: undefined, @@ -347,7 +351,6 @@ export class ImportService { const value = new Big(quantity).mul(unitPrice).toNumber(); - //@ts-ignore activities.push({ ...order, error, @@ -357,6 +360,7 @@ export class ImportService { assetProfile.currency, userCurrency ), + //@ts-ignore SymbolProfile: assetProfile, valueInBaseCurrency: this.exchangeRateDataService.toCurrency( value,