From c5c11929008ac5bf6c4e56bcf9fe337f3a99d4f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20G=C3=BCnther?= Date: Sat, 11 Oct 2025 17:07:42 +0200 Subject: [PATCH] Bugfix/import of custom asset profiles (#5670) * Import of custom asset profiles * Update changelog --- CHANGELOG.md | 1 + apps/api/src/app/import/import.service.ts | 38 ++++++++++++++++ test/import/ok/penthouse-apartment.json | 53 +++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 test/import/ok/penthouse-apartment.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 58a7b3b48..c7472e421 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed the server startup message to properly display IPv6 addresses +- Fixed an issue where importing custom asset profiles failed due to validation errors ## 2.207.0 - 2025-10-08 diff --git a/apps/api/src/app/import/import.service.ts b/apps/api/src/app/import/import.service.ts index 82231d237..69ec781c3 100644 --- a/apps/api/src/app/import/import.service.ts +++ b/apps/api/src/app/import/import.service.ts @@ -373,6 +373,7 @@ export class ImportService { const assetProfiles = await this.validateActivities({ activitiesDto, + assetProfilesWithMarketDataDto, maxActivitiesToImport, user }); @@ -698,10 +699,12 @@ export class ImportService { private async validateActivities({ activitiesDto, + assetProfilesWithMarketDataDto, maxActivitiesToImport, user }: { activitiesDto: Partial[]; + assetProfilesWithMarketDataDto: ImportDataDto['assetProfiles']; maxActivitiesToImport: number; user: UserWithSettings; }) { @@ -749,6 +752,41 @@ export class ImportService { )?.[symbol] }; + if (!assetProfile?.name) { + const assetProfileInImport = assetProfilesWithMarketDataDto?.find( + (profile) => { + return ( + profile.dataSource === dataSource && profile.symbol === symbol + ); + } + ); + + if (assetProfileInImport) { + // Merge all fields of custom asset profiles into the validation object + Object.assign(assetProfile, { + assetClass: assetProfileInImport.assetClass, + assetSubClass: assetProfileInImport.assetSubClass, + comment: assetProfileInImport.comment, + countries: assetProfileInImport.countries, + currency: assetProfileInImport.currency, + cusip: assetProfileInImport.cusip, + dataSource: assetProfileInImport.dataSource, + figi: assetProfileInImport.figi, + figiComposite: assetProfileInImport.figiComposite, + figiShareClass: assetProfileInImport.figiShareClass, + holdings: assetProfileInImport.holdings, + isActive: assetProfileInImport.isActive, + isin: assetProfileInImport.isin, + name: assetProfileInImport.name, + scraperConfiguration: assetProfileInImport.scraperConfiguration, + sectors: assetProfileInImport.sectors, + symbol: assetProfileInImport.symbol, + symbolMapping: assetProfileInImport.symbolMapping, + url: assetProfileInImport.url + }); + } + } + if ( (dataSource !== 'MANUAL' && type === 'BUY') || type === 'DIVIDEND' || diff --git a/test/import/ok/penthouse-apartment.json b/test/import/ok/penthouse-apartment.json new file mode 100644 index 000000000..3b230cf76 --- /dev/null +++ b/test/import/ok/penthouse-apartment.json @@ -0,0 +1,53 @@ +{ + "meta": { + "date": "2023-02-05T00:00:00.000Z", + "version": "dev" + }, + "accounts": [], + "assetProfiles": [ + { + "assetClass": null, + "assetSubClass": null, + "comment": null, + "countries": [], + "currency": "USD", + "cusip": null, + "dataSource": "MANUAL", + "figi": null, + "figiComposite": null, + "figiShareClass": null, + "holdings": [], + "isActive": true, + "isin": null, + "marketData": [], + "name": "Penthouse Apartment", + "scraperConfiguration": null, + "sectors": [], + "symbol": "7e91b7d4-1430-4212-8380-289a06c9bbc1", + "symbolMapping": {}, + "url": null + } + ], + "platforms": [], + "tags": [], + "activities": [ + { + "accountId": null, + "comment": null, + "currency": "USD", + "dataSource": "MANUAL", + "date": "2022-01-01T00:00:00.000Z", + "fee": 0, + "quantity": 1, + "symbol": "7e91b7d4-1430-4212-8380-289a06c9bbc1", + "tags": [], + "type": "BUY", + "unitPrice": 500000, + } + ], + "user": { + "settings": { + "currency": "USD" + } + } +}