Feature/extend asset profile for currency (#3495)

* Extend asset profile for currency

* Update changelog
This commit is contained in:
Eduardo Marinho
2024-06-22 08:54:23 +01:00
committed by GitHub
parent 70e633b997
commit ff121243e4
6 changed files with 80 additions and 21 deletions

View File

@@ -13,7 +13,12 @@ import {
} from 'date-fns';
import { de, es, fr, it, nl, pl, pt, tr, zhCN } from 'date-fns/locale';
import { ghostfolioScraperApiSymbolPrefix, locale } from './config';
import {
DEFAULT_CURRENCY,
DERIVED_CURRENCIES,
ghostfolioScraperApiSymbolPrefix,
locale
} from './config';
import { Benchmark, UniqueAsset } from './interfaces';
import { BenchmarkTrend, ColorScheme } from './types';
@@ -161,6 +166,10 @@ export function getCssVariable(aCssVariable: string) {
);
}
export function getCurrencyFromSymbol(aSymbol = '') {
return aSymbol.replace(DEFAULT_CURRENCY, '');
}
export function getDateFnsLocale(aLanguageCode: string) {
if (aLanguageCode === 'de') {
return de;
@@ -322,8 +331,18 @@ export function interpolate(template: string, context: any) {
});
}
export function isCurrency(aSymbol = '') {
return currencies[aSymbol];
export function isCurrency(aCurrency = '') {
return currencies[aCurrency] || isDerivedCurrency(aCurrency);
}
export function isDerivedCurrency(aCurrency: string) {
if (aCurrency === 'USX') {
return true;
}
return DERIVED_CURRENCIES.find(({ currency }) => {
return currency === aCurrency;
});
}
export function parseDate(date: string): Date | null {