fix(buybox): show BB Lost badge for ES ASINs with missing or empty reason

- Force reasonIdx to column N (13) for BB_ES sheet, same as DE/FR/UK, so dynamic header detection can't override to a wrong column
- Fall back to 'BB Lost' when reason cell is empty instead of skipping the ASIN entirely
- Add B095K8948Z to debug logging alongside B0D3874WSD

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Christian Vidal Wolf
2026-03-03 13:39:04 +01:00
co-authored by Claude Sonnet 4.6
parent 4afae59de9
commit 93c2a699ea
+7 -7
View File
@@ -2598,13 +2598,13 @@ export const processBuyBoxExcel = async (fileOrBuffer: File | ArrayBuffer): Prom
}
// 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) || (config.country === 'DE' && reasonIdx !== 13)) {
if (reasonIdx === -1 || (config.country === 'FR' && reasonIdx !== 18) || (config.country === 'UK' && reasonIdx !== 9) || (config.country === 'DE' && reasonIdx !== 13) || (config.country === 'ES' && reasonIdx !== 13)) {
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 === 'DE') reasonIdx = 13; // Force Column N for DE (Index 13)
else if (config.country === 'ES') reasonIdx = 13; // Force Column N for ES (Index 13)
else if (reasonIdx === -1) {
if (config.country === 'IT') reasonIdx = 12;
else if (config.country === 'ES') reasonIdx = 13;
else reasonIdx = 13;
}
}
@@ -2623,19 +2623,19 @@ export const processBuyBoxExcel = async (fileOrBuffer: File | ArrayBuffer): Prom
const rawAsin = String(row[finalAsinIdx] || '').trim().toUpperCase();
if (!rawAsin || rawAsin.length < 5) continue;
const rawReason = String(row[reasonIdx] || '').trim();
const rawReason = String(row[reasonIdx] || '').trim() || 'BB Lost';
// Debug specific ASIN reported by user
const isTargetAsin = rawAsin === 'B0D3874WSD' || rawAsin.includes('B0D3874WSD');
const isTargetAsin = rawAsin === 'B0D3874WSD' || rawAsin === 'B095K8948Z';
if (isTargetAsin) {
console.log(`[BuyBox Debug] Found ASIN ${rawAsin} in ${config.country}. Row data at reasonIdx (${reasonIdx}): "${row[reasonIdx]}", Processed Reason: "${rawReason}"`);
}
// Only consider as BB lost if there is an Issue Type / Reason specified
// Only consider as BB lost if not marked as resolved
const lowReason = rawReason.toLowerCase();
if (!rawReason || lowReason === 'fixed' || lowReason === 'ok' || lowReason === 'hecho' || lowReason === 'solucionado' || lowReason === 'corrected') {
if (lowReason === 'fixed' || lowReason === 'ok' || lowReason === 'hecho' || lowReason === 'solucionado' || lowReason === 'corrected') {
if (isTargetAsin) {
console.log(`[BuyBox Debug] SKIPPING ASIN ${rawAsin} in ${config.country} because reason is empty or matches positive status list ("${rawReason}")`);
console.log(`[BuyBox Debug] SKIPPING ASIN ${rawAsin} in ${config.country} because reason matches resolved status ("${rawReason}")`);
}
continue;
}