From 7d57bd2e3f8e9c3a5ea11d378e1a5ebdc8dc57a6 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 19 Apr 2026 21:52:41 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/routes/settings.import.tsx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/routes/settings.import.tsx b/src/routes/settings.import.tsx index cb0af55..dab5b7a 100644 --- a/src/routes/settings.import.tsx +++ b/src/routes/settings.import.tsx @@ -84,8 +84,25 @@ const toBool = (v: any) => { const toNum = (v: any) => { if (v === "" || v == null) return null; - const n = Number(String(v).replace(/[$,]/g, "")); - return isNaN(n) ? null : n; + if (typeof v === "number") return isNaN(v) ? null : v; + let s = String(v).trim(); + if (!s) return null; + // Accounting negatives: (123.45) → -123.45 + let negative = false; + if (/^\(.*\)$/.test(s)) { + negative = true; + s = s.slice(1, -1); + } + // Strip currency symbols, commas, spaces, and stray non-numeric chars (keep . and -) + s = s.replace(/[$£€¥,\s]/g, ""); + if (s.endsWith("-")) { + // trailing minus (e.g. "100-") + negative = true; + s = s.slice(0, -1); + } + const n = Number(s); + if (isNaN(n)) return null; + return negative ? -n : n; }; const toDate = (v: any): string | null => {