fix: force ASIN column B and Reason column N for BB_DE

This commit is contained in:
Christian Vidal Wolf
2026-02-06 10:57:03 +01:00
parent bd8f86007c
commit 827135a517
+7 -6
View File
@@ -2244,7 +2244,7 @@ export const processBuyBoxExcel = async (fileOrBuffer: File | ArrayBuffer): Prom
const s = String(h || '').toUpperCase().trim(); const s = String(h || '').toUpperCase().trim();
return s === 'ASIN' || s.includes('AMAZON ASIN') || s.includes('CHILD ASIN') || s.includes('IDENTIFIER') || s.includes('PRODUCT ID') || s.includes('SKU'); return s === 'ASIN' || s.includes('AMAZON ASIN') || s.includes('CHILD ASIN') || s.includes('IDENTIFIER') || s.includes('PRODUCT ID') || s.includes('SKU');
}); });
const finalAsinIdx = asinIdx !== -1 ? asinIdx : 1; // Default to Col B if not found let finalAsinIdx = asinIdx !== -1 ? asinIdx : 1; // Default to Col B if not found
// Dynamically find the "Issue Type" or "Reason" column // Dynamically find the "Issue Type" or "Reason" column
let reasonIdx = headers.findIndex(h => { let reasonIdx = headers.findIndex(h => {
@@ -2261,18 +2261,19 @@ export const processBuyBoxExcel = async (fileOrBuffer: File | ArrayBuffer): Prom
} }
// Fallback to previous hardcoded indices if header search fails or for specific known sheet structures // Fallback to previous hardcoded indices if header search fails or for specific known sheet structures
if (reasonIdx === -1 || (config.country === 'FR' && reasonIdx !== 18) || (config.country === 'UK' && reasonIdx !== 9)) { if (reasonIdx === -1 || (config.country === 'FR' && reasonIdx !== 18) || (config.country === 'UK' && reasonIdx !== 9) || (config.country === 'DE' && reasonIdx !== 13)) {
if (config.country === 'FR') reasonIdx = 18; // Force Column S for FR (Index 18) if (config.country === 'FR') reasonIdx = 18; // Force Column S for FR (Index 18)
else if (config.country === 'UK') reasonIdx = 9; // Force Column J for UK (Index 9) else if (config.country === 'UK') reasonIdx = 9; // Force Column J for UK (Index 9)
else if (config.country === 'DE') reasonIdx = 13; // Force Column N for DE (Index 13)
else if (reasonIdx === -1) { else if (reasonIdx === -1) {
if (config.country === 'DE') reasonIdx = 13; if (config.country === 'IT') reasonIdx = 12;
else if (config.country === 'IT') reasonIdx = 12;
else if (config.country === 'ES') reasonIdx = 13; else if (config.country === 'ES') reasonIdx = 13;
else reasonIdx = 13; else reasonIdx = 13;
} }
} }
console.log(`[BuyBox] Sheet "${sheetName}" (Country: ${config.country}): HeaderRow=${headerRowIdx}, ASIN Col=${finalAsinIdx} ("${headers[finalAsinIdx]}"), Reason Col=${reasonIdx} ("${headers[reasonIdx] || 'N/A'}")`); // Also force ASIN column for DE if not correctly detected
if (config.country === 'DE') finalAsinIdx = 1; // Force Column B for Germany (Index 1)
if (config.country === 'ES') { if (config.country === 'ES') {
console.log(`[BuyBox Debug] ES Headers found:`, headers); console.log(`[BuyBox Debug] ES Headers found:`, headers);
} }