mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 17:35:23 +02:00
fix: format Article NW (kg) and weight columns to 2 decimal places
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
co-authored by
Qwen-Coder
parent
034640c869
commit
912fb16cb0
+8
-2
@@ -90,6 +90,9 @@ export default function App() {
|
|||||||
const priceKeywords = ['price', 'eur', 'cost', 'msrp', 'net', 'gross', 'netto', 'brutto', 'pp', 'pph', 'uvp', 'vpe', 'stk'];
|
const priceKeywords = ['price', 'eur', 'cost', 'msrp', 'net', 'gross', 'netto', 'brutto', 'pp', 'pph', 'uvp', 'vpe', 'stk'];
|
||||||
const isPriceCol = priceKeywords.some(kw => header.includes(kw));
|
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') {
|
if (typeof val === 'number') {
|
||||||
return Number(val.toFixed(2));
|
return Number(val.toFixed(2));
|
||||||
}
|
}
|
||||||
@@ -97,7 +100,7 @@ export default function App() {
|
|||||||
if (typeof val === 'string') {
|
if (typeof val === 'string') {
|
||||||
const normalized = val.trim().replace(',', '.');
|
const normalized = val.trim().replace(',', '.');
|
||||||
const num = parseFloat(normalized);
|
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);
|
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 priceKeywords = ['price', 'eur', 'cost', 'msrp', 'net', 'gross', 'netto', 'brutto', 'pp', 'pph', 'uvp', 'vpe', 'stk'];
|
||||||
const isPriceCol = priceKeywords.some(kw => header.includes(kw));
|
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') {
|
if (typeof val === 'number') {
|
||||||
return Number(val.toFixed(2));
|
return Number(val.toFixed(2));
|
||||||
}
|
}
|
||||||
@@ -168,7 +174,7 @@ export default function App() {
|
|||||||
if (typeof val === 'string') {
|
if (typeof val === 'string') {
|
||||||
const normalized = val.trim().replace(',', '.');
|
const normalized = val.trim().replace(',', '.');
|
||||||
const num = parseFloat(normalized);
|
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);
|
return num.toFixed(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 priceKeywords = ['price', 'eur', 'cost', 'msrp', 'net', 'gross', 'netto', 'brutto', 'pp', 'pph', 'uvp', 'vpe', 'stk'];
|
||||||
const isPriceCol = priceKeywords.some(kw => h.includes(kw));
|
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
|
// Handle numbers
|
||||||
if (typeof val === 'number') {
|
if (typeof val === 'number') {
|
||||||
return val.toFixed(2);
|
return val.toFixed(2);
|
||||||
@@ -42,8 +45,8 @@ export function MatrixView({ data, headers }: MatrixViewProps) {
|
|||||||
const num = parseFloat(normalized);
|
const num = parseFloat(normalized);
|
||||||
|
|
||||||
if (!isNaN(num)) {
|
if (!isNaN(num)) {
|
||||||
// Format if it's a price column OR if it already has a decimal separator (.)
|
// Format if it's a price column, weight column, OR if it already has a decimal separator (.)
|
||||||
if (isPriceCol || val.includes('.') || val.includes(',')) {
|
if (isPriceCol || isWeightCol || val.includes('.') || val.includes(',')) {
|
||||||
return num.toFixed(2);
|
return num.toFixed(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user