From b3b732dacce4e972dfb1cdbaf9251a6d0af85af1 Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Wed, 21 Feb 2024 19:34:49 +0300 Subject: [PATCH] (fix) Fixed broken config for currency (#9) --- src/helpers/functions.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/helpers/functions.ts b/src/helpers/functions.ts index 1370b41..a443a68 100644 --- a/src/helpers/functions.ts +++ b/src/helpers/functions.ts @@ -1,5 +1,6 @@ import { type Payment, type LineItem } from '../types'; -import { configSchema } from '../config-schema'; +import {type ConfigObject } from '../config-schema'; +import { useConfig } from '@openmrs/esm-framework'; // amount already paid export function calculateTotalAmountTendered(payments: Array) { @@ -34,11 +35,11 @@ export function calculateTotalAmount(lineItems: Array) { export const convertToCurrency = (amountToConvert: number) => { const locale = window.i18next?.language?.substring(0, 2) ?? ''; - const currencySymbol = configSchema.defaultCurrency._default; - + const { defaultCurrency } = useConfig(); + const currencyCode = defaultCurrency || 'KES'; const formatter = new Intl.NumberFormat(locale, { style: 'currency', - currency: currencySymbol, + currency: currencyCode, minimumFractionDigits: 2, });