diff --git a/src/App.tsx b/src/App.tsx index 0d73595..373eddc 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -90,6 +90,9 @@ export default function App() { const priceKeywords = ['price', 'eur', 'cost', 'msrp', 'net', 'gross', 'netto', 'brutto', 'pp', 'pph', 'uvp', 'vpe', 'stk']; const isPriceCol = priceKeywords.some(kw => header.includes(kw)); + // Format weight columns (NW = Net Weight, GW = Gross Weight, kg, etc.) + const isWeightCol = header.includes('nw') || header.includes('gw') || header.includes('weight') || header.includes('kg'); + if (typeof val === 'number') { return Number(val.toFixed(2)); } @@ -97,7 +100,7 @@ export default function App() { if (typeof val === 'string') { const normalized = val.trim().replace(',', '.'); const num = parseFloat(normalized); - if (!isNaN(num) && (isPriceCol || val.includes('.') || val.includes(','))) { + if (!isNaN(num) && (isPriceCol || isWeightCol || val.includes('.') || val.includes(','))) { return num.toFixed(2); } } @@ -161,6 +164,9 @@ export default function App() { const priceKeywords = ['price', 'eur', 'cost', 'msrp', 'net', 'gross', 'netto', 'brutto', 'pp', 'pph', 'uvp', 'vpe', 'stk']; const isPriceCol = priceKeywords.some(kw => header.includes(kw)); + // Format weight columns (NW = Net Weight, GW = Gross Weight, kg, etc.) + const isWeightCol = header.includes('nw') || header.includes('gw') || header.includes('weight') || header.includes('kg'); + if (typeof val === 'number') { return Number(val.toFixed(2)); } @@ -168,7 +174,7 @@ export default function App() { if (typeof val === 'string') { const normalized = val.trim().replace(',', '.'); const num = parseFloat(normalized); - if (!isNaN(num) && (isPriceCol || val.includes('.') || val.includes(','))) { + if (!isNaN(num) && (isPriceCol || isWeightCol || val.includes('.') || val.includes(','))) { return num.toFixed(2); } } diff --git a/src/components/MatrixView.tsx b/src/components/MatrixView.tsx index cc59dc1..717c1be 100644 --- a/src/components/MatrixView.tsx +++ b/src/components/MatrixView.tsx @@ -17,10 +17,10 @@ export function MatrixView({ data, headers }: MatrixViewProps) { const formatCellValue = (val: any, header: string = '') => { if (val === undefined || val === null || val === '') return ''; - + // Convert header to lowercase for checks const h = header.toLowerCase(); - + // Do NOT format columns that are clearly IDs, barcodes, or codes if (h.includes('id') || h.includes('no') || h.includes('code') || h.includes('art.') || h.includes('barcode') || h.includes('article')) { return val; @@ -30,6 +30,9 @@ export function MatrixView({ data, headers }: MatrixViewProps) { const priceKeywords = ['price', 'eur', 'cost', 'msrp', 'net', 'gross', 'netto', 'brutto', 'pp', 'pph', 'uvp', 'vpe', 'stk']; const isPriceCol = priceKeywords.some(kw => h.includes(kw)); + // Format weight columns (NW = Net Weight, GW = Gross Weight, kg, etc.) + const isWeightCol = h.includes('nw') || h.includes('gw') || h.includes('weight') || h.includes('kg'); + // Handle numbers if (typeof val === 'number') { return val.toFixed(2); @@ -40,10 +43,10 @@ export function MatrixView({ data, headers }: MatrixViewProps) { // Normalize decimals (handle comma as decimal separator) const normalized = val.trim().replace(',', '.'); const num = parseFloat(normalized); - + if (!isNaN(num)) { - // Format if it's a price column OR if it already has a decimal separator (.) - if (isPriceCol || val.includes('.') || val.includes(',')) { + // Format if it's a price column, weight column, OR if it already has a decimal separator (.) + if (isPriceCol || isWeightCol || val.includes('.') || val.includes(',')) { return num.toFixed(2); } }