Browse Source

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

* Fix functionality to delete asset profile of custom currency

* Update changelog
pull/4400/head
csehatt741 2 weeks ago
committed by GitHub
parent
commit
3a09996ca1
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 21
      apps/api/src/app/admin/admin.service.ts
  3. 4
      apps/client/src/app/components/admin-market-data/admin-market-data.service.ts
  4. 10
      libs/common/src/lib/helper.ts

1
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

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

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

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

Loading…
Cancel
Save