Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Bugfix/fix activities import for manual data source (#2923)
Thomas Kaul9fdbd22cb55d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9b16b7b8f4..1933423269 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Fixed+- Fixed the import for activities with `MANUAL` data source and type `FEE`, `INTEREST`, `ITEM` or `LIABILITY`- Removed holdings with incomplete data from the _Top 3_ and _Bottom 3_ performers on the analysis page## 2.44.0 - 2024-01-24diff --git a/apps/api/src/app/import/import.service.ts b/apps/api/src/app/import/import.service.tsindex d564f497b1..d2daa4338e 100644--- a/apps/api/src/app/import/import.service.ts+++ b/apps/api/src/app/import/import.service.ts@@ -575,7 +575,7 @@ export class ImportService {for (const [index,- { currency, dataSource, symbol }+ { currency, dataSource, symbol, type }] of uniqueActivitiesDto.entries()) {if (!this.configurationService.get('DATA_SOURCES').includes(dataSource)) {throw new Error(@@ -583,28 +583,33 @@ export class ImportService {);}- const assetProfile = (- await this.dataProviderService.getAssetProfiles([- { dataSource, symbol }- ])- )?.[symbol];+ const assetProfile = {+ currency,+ ...(+ await this.dataProviderService.getAssetProfiles([+ { dataSource, symbol }+ ])+ )?.[symbol]+ };- if (!assetProfile?.name) {- throw new Error(- `activities.${index}.symbol ("${symbol}") is not valid for the specified data source ("${dataSource}")`- );- }+ if (type === 'BUY' || type === 'DIVIDEND' || type === 'SELL') {+ if (!assetProfile?.name) {+ throw new Error(+ `activities.${index}.symbol ("${symbol}") is not valid for the specified data source ("${dataSource}")`+ );+ }- if (- 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}"`- );+ if (+ 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 })] =diff --git a/apps/api/src/services/data-provider/manual/manual.service.ts b/apps/api/src/services/data-provider/manual/manual.service.tsindex f5b2850161..74acc48e1b 100644--- a/apps/api/src/services/data-provider/manual/manual.service.ts+++ b/apps/api/src/services/data-provider/manual/manual.service.ts@@ -42,10 +42,21 @@ export class ManualService implements DataProviderInterface {public async getAssetProfile(aSymbol: string): Promise<Partial<SymbolProfile>> {- return {+ const assetProfile: Partial<SymbolProfile> = {dataSource: this.getName(),symbol: aSymbol};++ const [symbolProfile] = await this.symbolProfileService.getSymbolProfiles([+ { dataSource: this.getName(), symbol: aSymbol }+ ]);++ if (symbolProfile) {+ assetProfile.currency = symbolProfile.currency;+ assetProfile.name = symbolProfile.name;+ }++ return assetProfile;}public async getDividends({}: GetDividendsParams) {