mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-18 08:44:25 +08:00
support currency unit name
This commit is contained in:
+6
-4
@@ -2,7 +2,7 @@ import currencyConstants from '@/consts/currency.js';
|
||||
|
||||
import { isString, isNumber } from './common.js';
|
||||
|
||||
export function appendCurrencySymbol(value, currencyDisplayType, currencyCode, currencyName, isPlural) {
|
||||
export function appendCurrencySymbol(value, currencyDisplayType, currencyCode, currencyUnit, currencyName, isPlural) {
|
||||
if (isNumber(value)) {
|
||||
value = value.toString();
|
||||
}
|
||||
@@ -11,7 +11,7 @@ export function appendCurrencySymbol(value, currencyDisplayType, currencyCode, c
|
||||
return value;
|
||||
}
|
||||
|
||||
const symbol = getAmountPrependAndAppendCurrencySymbol(currencyDisplayType, currencyCode, currencyName, isPlural);
|
||||
const symbol = getAmountPrependAndAppendCurrencySymbol(currencyDisplayType, currencyCode, currencyUnit, currencyName, isPlural);
|
||||
|
||||
if (!symbol) {
|
||||
return value;
|
||||
@@ -30,7 +30,7 @@ export function appendCurrencySymbol(value, currencyDisplayType, currencyCode, c
|
||||
return value;
|
||||
}
|
||||
|
||||
export function getAmountPrependAndAppendCurrencySymbol(currencyDisplayType, currencyCode, currencyName, isPlural) {
|
||||
export function getAmountPrependAndAppendCurrencySymbol(currencyDisplayType, currencyCode, currencyUnit, currencyName, isPlural) {
|
||||
if (!currencyDisplayType) {
|
||||
return null;
|
||||
}
|
||||
@@ -53,7 +53,9 @@ export function getAmountPrependAndAppendCurrencySymbol(currencyDisplayType, cur
|
||||
}
|
||||
} else if (currencyDisplayType.symbol === currencyConstants.allCurrencyDisplaySymbol.Code) {
|
||||
symbol = currencyCode;
|
||||
}else if (currencyDisplayType.symbol === currencyConstants.allCurrencyDisplaySymbol.Name) {
|
||||
} else if (currencyDisplayType.symbol === currencyConstants.allCurrencyDisplaySymbol.Unit) {
|
||||
symbol = currencyUnit;
|
||||
} else if (currencyDisplayType.symbol === currencyConstants.allCurrencyDisplaySymbol.Name) {
|
||||
symbol = currencyName;
|
||||
}
|
||||
|
||||
|
||||
+19
-3
@@ -201,7 +201,21 @@ function getDefaultFirstDayOfWeek(translateFn) {
|
||||
}
|
||||
|
||||
function getCurrencyName(currencyCode, translateFn) {
|
||||
return translateFn(`currency.${currencyCode}`);
|
||||
return translateFn(`currency.name.${currencyCode}`);
|
||||
}
|
||||
|
||||
function getCurrencyUnitName(currencyCode, isPlural, translateFn) {
|
||||
const currencyInfo = currencyConstants.all[currencyCode];
|
||||
|
||||
if (currencyInfo && currencyInfo.unit) {
|
||||
if (isPlural) {
|
||||
return translateFn(`currency.unit.${currencyInfo.unit}.plural`);
|
||||
} else {
|
||||
return translateFn(`currency.unit.${currencyInfo.unit}.normal`);
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function getAllMeridiemIndicatorNames(translateFn) {
|
||||
@@ -886,8 +900,9 @@ function getFormatedAmountWithCurrency(value, currencyCode, translateFn, userSto
|
||||
currencyDisplayType = getCurrentCurrencyDisplayType(translateFn, userStore);
|
||||
}
|
||||
|
||||
const currencyUnit = getCurrencyUnitName(currencyCode, isPlural, translateFn);
|
||||
const currencyName = getCurrencyName(currencyCode, translateFn);
|
||||
return appendCurrencySymbol(value, currencyDisplayType, currencyCode, currencyName, isPlural);
|
||||
return appendCurrencySymbol(value, currencyDisplayType, currencyCode, currencyUnit, currencyName, isPlural);
|
||||
}
|
||||
|
||||
function getFormatedExchangeRateAmount(value, translateFn, userStore) {
|
||||
@@ -902,8 +917,9 @@ function getAdaptiveAmountRate(amount1, amount2, fromExchangeRate, toExchangeRat
|
||||
|
||||
function getAmountPrependAndAppendText(currencyCode, userStore, settingsStore, isPlural, translateFn) {
|
||||
const currencyDisplayType = getCurrentCurrencyDisplayType(translateFn, userStore);
|
||||
const currencyUnit = getCurrencyUnitName(currencyCode, isPlural, translateFn);
|
||||
const currencyName = getCurrencyName(currencyCode, translateFn);
|
||||
return getAmountPrependAndAppendCurrencySymbol(currencyDisplayType, currencyCode, currencyName, isPlural);
|
||||
return getAmountPrependAndAppendCurrencySymbol(currencyDisplayType, currencyCode, currencyUnit, currencyName, isPlural);
|
||||
}
|
||||
|
||||
function getAllExpenseIncomeAmountColors(translateFn, expenseOrIncome) {
|
||||
|
||||
Reference in New Issue
Block a user