Skip to content

Commit

Permalink
(fix) Fixed broken config for currency
Browse files Browse the repository at this point in the history
  • Loading branch information
CynthiaKamau committed Feb 21, 2024
1 parent ee49206 commit a5dd5e2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/helpers/functions.ts
Original file line number Diff line number Diff line change
@@ -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<Payment>) {
Expand Down Expand Up @@ -34,11 +35,11 @@ export function calculateTotalAmount(lineItems: Array<LineItem>) {

export const convertToCurrency = (amountToConvert: number) => {
const locale = window.i18next?.language?.substring(0, 2) ?? '';
const currencySymbol = configSchema.defaultCurrency._default;

const { defaultCurrency } = useConfig<ConfigObject>();
const currencyCode = defaultCurrency || 'KES';
const formatter = new Intl.NumberFormat(locale, {
style: 'currency',
currency: currencySymbol,
currency: currencyCode,
minimumFractionDigits: 2,
});

Expand Down

0 comments on commit a5dd5e2

Please sign in to comment.