diff --git a/client/src/utils/parsing.ts b/client/src/utils/parsing.ts index 452a77f..965c817 100644 --- a/client/src/utils/parsing.ts +++ b/client/src/utils/parsing.ts @@ -6,5 +6,15 @@ export function numberFormatter(value: number | undefined) { // Number parser that supports both comma and dot as decimal separator export function numberParser(value: string | undefined) { - return Number(value?.replace(",", ".") ?? 0); + // Convert comma to dot + const decimalSeparator = (1.1).toLocaleString().charAt(1); + if (decimalSeparator === ",") { + value = value?.replace(",", "."); + } + + // Remove all non-digit characters + value = value?.replace(/[^\d.-]/g, ""); + + // Parse as float + return parseFloat(value || "0"); }