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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
34 additions and
2 deletions
-
CHANGELOG.md
-
apps/api/src/app/admin/admin.service.ts
-
apps/client/src/app/components/admin-market-data/admin-market-data.service.ts
-
libs/common/src/lib/helper.ts
|
|
@ -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 |
|
|
|
|
|
|
|
|
|
@ -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,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) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
@ -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; |
|
|
|