From 3a09996ca1432b2a33eaa7a335ddabe4360b0fc9 Mon Sep 17 00:00:00 2001 From: csehatt741 <77381875+csehatt741@users.noreply.github.com> Date: Wed, 5 Mar 2025 20:25:32 +0100 Subject: [PATCH 1/2] Bugfix/fix functionality to delete asset profile of custom currency (#4354) * Fix functionality to delete asset profile of custom currency * Update changelog --- CHANGELOG.md | 1 + apps/api/src/app/admin/admin.service.ts | 21 ++++++++++++++++++- .../admin-market-data.service.ts | 4 +++- libs/common/src/lib/helper.ts | 10 +++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e11471a63a..f2b076369b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Handled an exception in the export functionality related to platforms - Handled an exception in the benchmark service related to unnamed asset profiles +- Fixed the functionality to delete an asset profile of a custom currency ## 2.142.0 - 2025-02-28 diff --git a/apps/api/src/app/admin/admin.service.ts b/apps/api/src/app/admin/admin.service.ts index ee79059f9e..7f2b0da5a5 100644 --- a/apps/api/src/app/admin/admin.service.ts +++ b/apps/api/src/app/admin/admin.service.ts @@ -109,7 +109,26 @@ export class AdminService { symbol }: AssetProfileIdentifier) { await this.marketDataService.deleteMany({ dataSource, symbol }); - await this.symbolProfileService.delete({ dataSource, symbol }); + + const currency = getCurrencyFromSymbol(symbol); + const customCurrencies = (await this.propertyService.getByKey( + PROPERTY_CURRENCIES + )) as string[]; + + if (customCurrencies.includes(currency)) { + const updatedCustomCurrencies = customCurrencies.filter( + (customCurrency) => { + return customCurrency !== currency; + } + ); + + await this.putSetting( + PROPERTY_CURRENCIES, + JSON.stringify(updatedCustomCurrencies) + ); + } else { + await this.symbolProfileService.delete({ dataSource, symbol }); + } } public async get(): Promise { diff --git a/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts b/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts index 86965cd8ab..0e2cb7ef3f 100644 --- a/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts +++ b/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts @@ -4,7 +4,8 @@ import { AdminService } from '@ghostfolio/client/services/admin.service'; import { ghostfolioScraperApiSymbolPrefix } from '@ghostfolio/common/config'; import { getCurrencyFromSymbol, - isDerivedCurrency + isDerivedCurrency, + isRootCurrency } from '@ghostfolio/common/helper'; import { AssetProfileIdentifier, @@ -77,6 +78,7 @@ export class AdminMarketDataService { activitiesCount === 0 && !isBenchmark && !isDerivedCurrency(getCurrencyFromSymbol(symbol)) && + !isRootCurrency(getCurrencyFromSymbol(symbol)) && !symbol.startsWith(ghostfolioScraperApiSymbolPrefix) ); } diff --git a/libs/common/src/lib/helper.ts b/libs/common/src/lib/helper.ts index bd0c741894..e5104a991f 100644 --- a/libs/common/src/lib/helper.ts +++ b/libs/common/src/lib/helper.ts @@ -354,6 +354,16 @@ export function isDerivedCurrency(aCurrency: string) { }); } +export function isRootCurrency(aCurrency: string) { + if (aCurrency === 'USD') { + return true; + } + + return DERIVED_CURRENCIES.find(({ rootCurrency }) => { + return rootCurrency === aCurrency; + }); +} + export function parseDate(date: string): Date { if (!date) { return undefined; From ddb50295b262d1123c808cdc2db47923d3a993c2 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 5 Mar 2025 20:54:32 +0100 Subject: [PATCH 2/2] Bugfix/fix changelog (#4400) * Fix changelog --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2b076369b..44b6c720a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- Fixed the functionality to delete an asset profile of a custom currency in the admin control panel + ## 2.143.0 - 2025-03-02 ### Added @@ -25,7 +31,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Handled an exception in the export functionality related to platforms - Handled an exception in the benchmark service related to unnamed asset profiles -- Fixed the functionality to delete an asset profile of a custom currency ## 2.142.0 - 2025-02-28