From 8f8e53089714382858e54fcf6c67f0c0c51b63aa Mon Sep 17 00:00:00 2001 From: lorretheboy Date: Mon, 22 Sep 2025 02:11:16 +0800 Subject: [PATCH] fix: local symbol --- src/libs/CurrencyUtils.ts | 16 +++++++++++++++- src/libs/Violations/ViolationsUtils.ts | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/libs/CurrencyUtils.ts b/src/libs/CurrencyUtils.ts index 2587e3610eb7..dd687f8c8093 100644 --- a/src/libs/CurrencyUtils.ts +++ b/src/libs/CurrencyUtils.ts @@ -105,7 +105,7 @@ function convertToFrontendAmountAsString(amountAsInt: number | null | undefined, * @param amountInCents – should be an integer. Anything after a decimal place will be dropped. * @param currency - IOU currency */ -function convertToDisplayString(amountInCents = 0, currency: string = CONST.CURRENCY.USD): string { +function convertToDisplayString(amountInCents = 0, currency: string = CONST.CURRENCY.USD, shouldUseLocalCurrencySymbol = false): string { const convertedAmount = convertToFrontendAmountAsInteger(amountInCents, currency); /** * Fallback currency to USD if it empty string or undefined @@ -114,6 +114,20 @@ function convertToDisplayString(amountInCents = 0, currency: string = CONST.CURR if (!currency) { currencyWithFallback = CONST.CURRENCY.USD; } + + if (shouldUseLocalCurrencySymbol) { + const currencySymbol = getCurrencySymbol(currencyWithFallback); + + if (currencySymbol) { + const formattedNumber = format(IntlStore.getCurrentLocale(), convertedAmount, { + style: 'decimal', + minimumFractionDigits: getCurrencyDecimals(currency), + maximumFractionDigits: 2, + }); + return `${currencySymbol}${formattedNumber}`; + } + } + return format(IntlStore.getCurrentLocale(), convertedAmount, { style: 'currency', currency: currencyWithFallback, diff --git a/src/libs/Violations/ViolationsUtils.ts b/src/libs/Violations/ViolationsUtils.ts index efd8931f9aee..148a6d8444fd 100644 --- a/src/libs/Violations/ViolationsUtils.ts +++ b/src/libs/Violations/ViolationsUtils.ts @@ -385,7 +385,7 @@ const ViolationsUtils = { shouldShowCategoryReceiptRequiredViolation || !policy.maxExpenseAmountNoReceipt ? undefined : { - formattedLimit: CurrencyUtils.convertToDisplayString(policy.maxExpenseAmountNoReceipt, policy.outputCurrency), + formattedLimit: CurrencyUtils.convertToDisplayString(policy.maxExpenseAmountNoReceipt, policy.outputCurrency, true), }, type: CONST.VIOLATION_TYPES.VIOLATION, showInReview: true,