Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Bugfix/fix functionality to delete asset profile of custom currency (#4354)
csehatt7413a09996ca143
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 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-28diff --git a/apps/api/src/app/admin/admin.service.ts b/apps/api/src/app/admin/admin.service.tsindex 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<AdminData> {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.tsindex 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.tsindex 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;