feat: Add standalone script for enhanced Bygma CSV import with validation test: Create simple database test to show current state and product counts test: Develop enhanced validation demo to simulate problematic CSV data handling test: Implement price validation tests with higher limits for edge cases test: Conduct real enhanced validation test with actual Bygma CSV file test: Test validation improvements with known problematic data test: Validate logic of cleaning and validating CSV rows without database test: Test improved VareNr cleaning functionality to remove spaces
58 lines
3.2 KiB
JavaScript
58 lines
3.2 KiB
JavaScript
// Show the problematic test rows for analysis
|
|
const testData = [
|
|
{ line: 2, data: "9990;135865;JUNKBAG SÆKKE L M3/1300KG;STK;175,96;1;175,96;;;" },
|
|
{ line: 3, data: ";;;;;;;;" },
|
|
{ line: 4, data: "9990;;MISSING VARENR;STK;100,00;1;80,00;;;" },
|
|
{ line: 5, data: "9990;123456;;STK;50,00;1;40,00;;;" },
|
|
{ line: 6, data: "9990;789012;MISSING ENHED;;25,00;1;20,00;;;" },
|
|
{ line: 7, data: "9990;TOOLONGVARENUMBERHERE123456789;NORMAL PRODUCT;STK;30,00;1;25,00;;;" },
|
|
{ line: 8, data: "9990;999999;PRODUCT WITH SEMICOLONS;;STK;15,00;1;12,00;;;" },
|
|
{ line: 9, data: "9990;111111;NORMAL PRODUCT;STK;abc,def;1;invalid;;;" },
|
|
{ line: 10, data: "9990;222222;ANOTHER GOOD PRODUCT;STK;200,50;1;160,40;;;" },
|
|
{ line: 11, data: "9990;333333;PRODUCT WITH VERY LONG TEXT THAT GOES ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON AND ON;STK;100,00;1;80,00;;;" },
|
|
{ line: 12, data: ";;;\t;;;;;;" },
|
|
{ line: 13, data: "9990;444444;GOOD PRODUCT AFTER PROBLEMS;STK;75,25;1;60,20;;;" }
|
|
];
|
|
|
|
console.log("📋 Test Data Analysis - CSV Rows and Validation Results:\n");
|
|
|
|
testData.forEach((item) => {
|
|
const fields = item.data.split(';');
|
|
const varegrp = fields[0] || '';
|
|
const vareNr = fields[1] || '';
|
|
const tekst = fields[2] || '';
|
|
const enhed = fields[3] || '';
|
|
const bruttoPris = fields[4] || '';
|
|
const nettoPris = fields[6] || '';
|
|
|
|
console.log(`Line ${item.line}:`);
|
|
console.log(`Raw: ${item.data}`);
|
|
console.log(`Parsed:`);
|
|
console.log(` - Varegrp: "${varegrp}"`);
|
|
console.log(` - VareNr: "${vareNr}" (length: ${vareNr.length})`);
|
|
console.log(` - Tekst: "${tekst}" (length: ${tekst.length})`);
|
|
console.log(` - Enhed: "${enhed}"`);
|
|
console.log(` - BruttoPris: "${bruttoPris}"`);
|
|
console.log(` - NettoPris: "${nettoPris}"`);
|
|
|
|
// Analysis
|
|
console.log(`Analysis:`);
|
|
if (!vareNr) console.log(` ❌ VareNr is empty`);
|
|
if (!tekst) console.log(` ❌ Tekst is empty`);
|
|
if (!enhed) console.log(` ❌ Enhed is empty`);
|
|
if (vareNr.length > 20) console.log(` ❌ VareNr too long (${vareNr.length} chars)`);
|
|
if (tekst.length > 500) console.log(` ❌ Tekst too long (${tekst.length} chars)`);
|
|
if (!bruttoPris && !nettoPris) console.log(` ❌ Both prices missing`);
|
|
if (bruttoPris === 'abc,def') console.log(` ❌ Invalid price format`);
|
|
|
|
console.log('');
|
|
});
|
|
|
|
console.log("🤔 Questions for you to consider:");
|
|
console.log("1. Should we accept products with missing VareNr? (Line 4)");
|
|
console.log("2. Should we accept products with missing Tekst? (Line 5)");
|
|
console.log("3. Should we accept products with missing Enhed? (Line 6)");
|
|
console.log("4. Is 20 character limit for VareNr reasonable? (Line 7 has 30 chars)");
|
|
console.log("5. Should we accept products where both prices are invalid? (Line 9)");
|
|
console.log("6. Is 500 character limit for Tekst reasonable? (Line 11 is very long)");
|