Browse Source

Improve asset profile validation for MANUAL data source

pull/2886/head
Thomas Kaul 2 years ago
parent
commit
54baaa532a
  1. 48
      apps/api/src/app/import/import.service.ts

48
apps/api/src/app/import/import.service.ts

@ -583,34 +583,32 @@ export class ImportService {
); );
} }
if (dataSource !== 'MANUAL') { const assetProfile = (
const assetProfile = ( await this.dataProviderService.getAssetProfiles([
await this.dataProviderService.getAssetProfiles([ { dataSource, symbol }
{ dataSource, symbol } ])
]) )?.[symbol];
)?.[symbol];
if (!assetProfile?.name) {
throw new Error(
`activities.${index}.symbol ("${symbol}") is not valid for the specified data source ("${dataSource}")`
);
}
if ( if (!assetProfile?.name) {
assetProfile.currency !== currency && throw new Error(
!this.exchangeRateDataService.hasCurrencyPair( `activities.${index}.symbol ("${symbol}") is not valid for the specified data source ("${dataSource}")`
currency, );
assetProfile.currency }
)
) {
throw new Error(
`activities.${index}.currency ("${currency}") does not match with "${assetProfile.currency}" and no exchange rate is available from "${currency}" to "${assetProfile.currency}"`
);
}
assetProfiles[getAssetProfileIdentifier({ dataSource, symbol })] = if (
assetProfile; assetProfile.currency !== currency &&
!this.exchangeRateDataService.hasCurrencyPair(
currency,
assetProfile.currency
)
) {
throw new Error(
`activities.${index}.currency ("${currency}") does not match with "${assetProfile.currency}" and no exchange rate is available from "${currency}" to "${assetProfile.currency}"`
);
} }
assetProfiles[getAssetProfileIdentifier({ dataSource, symbol })] =
assetProfile;
} }
return assetProfiles; return assetProfiles;

Loading…
Cancel
Save