fix(buybox): hardcode reason column for FR/UK/DE, remove STATUS keyword

FR/UK/DE sheets have a 'Status' column that appears before 'Reason',
causing the dynamic detector to pick the wrong column.
Use confirmed indices: FR=col S(18), UK=col J(9), DE=col N(13).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Christian Vidal Wolf
2026-03-03 15:47:56 +01:00
co-authored by Claude Sonnet 4.6
parent 916c349126
commit 1fb9956a15
+16 -12
View File
@@ -2582,18 +2582,22 @@ export const processBuyBoxExcel = async (fileOrBuffer: File | ArrayBuffer): Prom
continue;
}
// Detect reason column from header row keywords
let reasonColIdx = -1;
for (let r = 0; r < Math.min(rows.length, 15); r++) {
const idx = (rows[r] || []).findIndex((cell: any) => {
const s = String(cell || '').toUpperCase();
return s.includes('ISSUE') || s.includes('REASON') || s.includes('STATUS') ||
s.includes('MOTIVO') || s.includes('CAUSA') || s.includes('ESTADO') ||
s.includes('COMMENT') || s.includes('OBSERV') || s.includes('SITUAC') ||
s.includes('LBB') || s.includes('PROBLEMA') || s.includes('NOTE') ||
s.includes('JUSTIF') || s.includes('DETALL');
});
if (idx !== -1) { reasonColIdx = idx; break; }
// Known reason column overrides (confirmed by user): FR=S(18), UK=J(9), DE=N(13)
const REASON_COL_OVERRIDE: Record<string, number> = { FR: 18, UK: 9, DE: 13 };
let reasonColIdx = REASON_COL_OVERRIDE[country] ?? -1;
// For countries without a hardcoded override, detect from header keywords
if (reasonColIdx === -1) {
for (let r = 0; r < Math.min(rows.length, 15); r++) {
const idx = (rows[r] || []).findIndex((cell: any) => {
const s = String(cell || '').toUpperCase();
return s.includes('ISSUE') || s.includes('REASON') ||
s.includes('MOTIVO') || s.includes('CAUSA') || s.includes('ESTADO') ||
s.includes('COMMENT') || s.includes('OBSERV') || s.includes('SITUAC') ||
s.includes('LBB') || s.includes('PROBLEMA') || s.includes('JUSTIF') || s.includes('DETALL');
});
if (idx !== -1) { reasonColIdx = idx; break; }
}
}
console.log(`[BuyBox] Sheet "${sheetName}" → ${country}: asinCol=${asinColIdx} (${maxHits} ASINs found), reasonCol=${reasonColIdx}`);