diff --git a/fyo/utils/format.ts b/fyo/utils/format.ts index 5cadb6a9..dfc5d142 100644 --- a/fyo/utils/format.ts +++ b/fyo/utils/format.ts @@ -1,9 +1,9 @@ import { Fyo } from 'fyo'; import { Doc } from 'fyo/model/doc'; import { DateTime } from 'luxon'; -import { Money } from 'pesa'; import { Field, FieldType, FieldTypeEnum } from 'schemas/types'; import { getIsNullOrUndef, safeParseFloat, titleCase } from 'utils'; +import { isPesa } from '.'; import { DEFAULT_CURRENCY, DEFAULT_DATE_FORMAT, @@ -138,8 +138,8 @@ function formatNumber(value: unknown, fyo: Fyo): string { value = fyo.pesa(value.toFixed(20)); } - if ((value as Money).round) { - const floatValue = safeParseFloat((value as Money).round()); + if (isPesa(value)) { + const floatValue = safeParseFloat(value.round()); return numberFormatter.format(floatValue); } diff --git a/src/components/Controls/Currency.vue b/src/components/Controls/Currency.vue index 13a2bae8..12e0f080 100644 --- a/src/components/Controls/Currency.vue +++ b/src/components/Controls/Currency.vue @@ -9,7 +9,7 @@ class="text-end" :class="[inputClasses, containerClasses]" :type="inputType" - :value="value?.round()" + :value="round(value)" :placeholder="inputPlaceholder" :readonly="isReadOnly" :tabindex="isReadOnly ? '-1' : '0'" @@ -29,13 +29,16 @@ - - diff --git a/src/components/Controls/Data.vue b/src/components/Controls/Data.vue index a5be68e8..664afccf 100644 --- a/src/components/Controls/Data.vue +++ b/src/components/Controls/Data.vue @@ -1,13 +1,14 @@ - diff --git a/src/components/Controls/Float.vue b/src/components/Controls/Float.vue index bde95f9e..5eeb964b 100644 --- a/src/components/Controls/Float.vue +++ b/src/components/Controls/Float.vue @@ -1,19 +1,20 @@ - diff --git a/src/components/Controls/Int.vue b/src/components/Controls/Int.vue index 4e2564a3..5f0970d1 100644 --- a/src/components/Controls/Int.vue +++ b/src/components/Controls/Int.vue @@ -1,7 +1,9 @@ - diff --git a/utils/index.ts b/utils/index.ts index c0ece896..bd0c6329 100644 --- a/utils/index.ts +++ b/utils/index.ts @@ -180,11 +180,11 @@ function safeParseNumber(value: unknown, parser: (v: string) => number) { } export function safeParseFloat(value: unknown): number { - return safeParseNumber(value, parseFloat); + return safeParseNumber(value, Number); } export function safeParseInt(value: unknown): number { - return safeParseNumber(value, parseInt); + return safeParseNumber(value, (v: string) => Math.trunc(Number(v))); } export function joinMapLists(