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, });