diff --git a/CHANGELOG.md b/CHANGELOG.md index 43a43371f..fc62f026b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Improved the activities import by `isin` in the _Yahoo Finance_ service +## 2.58.0 - 2024-02-27 + +### Changed + +- Improved the handling of activities without account + +### Fixed + +- Fixed the query to filter activities of excluded accounts +- Improved the asset profile validation in the activities import + ## 2.57.0 - 2024-02-25 ### Changed diff --git a/apps/api/src/app/import/import.service.ts b/apps/api/src/app/import/import.service.ts index e33bab347..a4895cf73 100644 --- a/apps/api/src/app/import/import.service.ts +++ b/apps/api/src/app/import/import.service.ts @@ -570,17 +570,10 @@ export class ImportService { [assetProfileIdentifier: string]: Partial; } = {}; - const uniqueActivitiesDto = uniqBy( - activitiesDto, - ({ dataSource, symbol }) => { - return getAssetProfileIdentifier({ dataSource, symbol }); - } - ); - for (const [ index, { currency, dataSource, symbol, type } - ] of uniqueActivitiesDto.entries()) { + ] of activitiesDto.entries()) { if (!this.configurationService.get('DATA_SOURCES').includes(dataSource)) { throw new Error( `activities.${index}.dataSource ("${dataSource}") is not valid` @@ -602,37 +595,33 @@ export class ImportService { } } - const assetProfile = { - currency, - ...( - await this.dataProviderService.getAssetProfiles([ - { dataSource, symbol } - ]) - )?.[symbol] - }; + if (!assetProfiles[getAssetProfileIdentifier({ dataSource, symbol })]) { + const assetProfile = { + currency, + ...( + await this.dataProviderService.getAssetProfiles([ + { dataSource, symbol } + ]) + )?.[symbol] + }; - 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 (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) { + throw new Error( + `activities.${index}.currency ("${currency}") does not match with currency of ${assetProfile.symbol} ("${assetProfile.currency}")` + ); + } } - } - assetProfiles[getAssetProfileIdentifier({ dataSource, symbol })] = - assetProfile; + assetProfiles[getAssetProfileIdentifier({ dataSource, symbol })] = + assetProfile; + } } return assetProfiles; diff --git a/apps/api/src/app/order/order.service.ts b/apps/api/src/app/order/order.service.ts index e60309856..a88aa4462 100644 --- a/apps/api/src/app/order/order.service.ts +++ b/apps/api/src/app/order/order.service.ts @@ -292,19 +292,14 @@ export class OrderService { } if (types) { - where.OR = types.map((type) => { - return { - type: { - equals: type - } - }; - }); + where.type = { in: types }; } if (withExcludedAccounts === false) { - where.Account = { - NOT: { isExcluded: true } - }; + where.OR = [ + { Account: null }, + { Account: { NOT: { isExcluded: true } } } + ]; } const [orders, count] = await Promise.all([ diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index 3fafa6795..92461dce8 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -749,7 +749,9 @@ export class PortfolioService { } = position; const accounts: PortfolioPositionDetail['accounts'] = uniqBy( - orders, + orders.filter(({ Account }) => { + return Account; + }), 'Account.id' ).map(({ Account }) => { return Account; diff --git a/package.json b/package.json index c85458bd2..8f0b18ba9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ghostfolio", - "version": "2.57.0", + "version": "2.58.0", "homepage": "https://ghostfol.io", "license": "AGPL-3.0", "repository": "https://github.com/ghostfolio/ghostfolio",