Bugfix/fix functionality to delete asset profile of custom currency (#4354)

* Fix functionality to delete asset profile of custom currency

* Update changelog
This commit is contained in:
csehatt741 2025-03-05 20:25:32 +01:00 committed by GitHub
parent d923e6f2e2
commit 3a09996ca1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 34 additions and 2 deletions

View File

@ -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

View File

@ -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> {

View File

@ -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)
);
}

View File

@ -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;