diff --git a/src/stores/globalStore.ts b/src/stores/globalStore.ts index 6b9f278..bf6ec84 100644 --- a/src/stores/globalStore.ts +++ b/src/stores/globalStore.ts @@ -116,7 +116,10 @@ export const useGlobalStore = defineStore('globalStore', () => { var val: string var opt: Record = {} if (prec) { - if (prec) opt.minimumFractionDigits = prec + if (prec) { + opt.minimumFractionDigits = prec + opt.maximumFractionDigits = prec + } if (curr) { opt.style = 'currency' opt.currency = curr @@ -130,6 +133,9 @@ export const useGlobalStore = defineStore('globalStore', () => { return String(val) } + const roundMoney = (value: number): number => + Math.round((value + Number.EPSILON) * 100) / 100 + const floatEnLocale = (num: number | string): string => { return num.toString().replace('.', '').replace(',', '.') } @@ -196,6 +202,7 @@ export const useGlobalStore = defineStore('globalStore', () => { docFormats, allowFormats, toTrLocale, + roundMoney, floatEnLocale, trToLower, trToEngLower,