mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 12:35:25 +02:00
fix: force 2 decimal places for NW/GW/weight/kg columns before exclusion logic
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
27a161bfbb
commit
3696b38666
@@ -21,10 +21,18 @@ export function MatrixView({ data, headers }: MatrixViewProps) {
|
|||||||
// Convert header to lowercase for checks
|
// Convert header to lowercase for checks
|
||||||
const h = header.toLowerCase();
|
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
|
// 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')) {
|
||||||
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'))) {
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user