From 3696b38666d0aecf5ba83e637d5c3ffd6256e730 Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Sun, 29 Mar 2026 15:15:25 +0200 Subject: [PATCH] fix: force 2 decimal places for NW/GW/weight/kg columns before exclusion logic Co-Authored-By: Claude Sonnet 4.6 --- src/components/MatrixView.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/MatrixView.tsx b/src/components/MatrixView.tsx index 3aa0215..86e5ed3 100644 --- a/src/components/MatrixView.tsx +++ b/src/components/MatrixView.tsx @@ -21,10 +21,18 @@ export function MatrixView({ data, headers }: MatrixViewProps) { // Convert header to lowercase for checks const h = header.toLowerCase(); + // Always format weight/NW/GW/kg columns to 2 decimals — checked before any exclusion logic + if (h.includes('nw') || h.includes('gw') || h.includes('weight') || h.includes('kg')) { + if (typeof val === 'number') return val.toFixed(2); + if (typeof val === 'string') { + const num = parseFloat(val.trim().replace(',', '.')); + if (!isNaN(num)) return num.toFixed(2); + } + return val; + } + // Do NOT format columns that are clearly IDs, barcodes, or codes - // But allow if it's a weight/measure column (e.g. Article NW (kg)) - if ((h.includes('id') || h.includes('no') || h.includes('code') || h.includes('art.') || h.includes('barcode') || h.includes('article')) && - !(h.includes('nw') || h.includes('gw') || h.includes('weight') || h.includes('kg'))) { + if (h.includes('id') || h.includes('no') || h.includes('code') || h.includes('art.') || h.includes('barcode') || h.includes('article')) { return val; }