fix(buybox): restrict sheet detection to BB_* sheets only

Inventory sheets like 'INV ITALY' were being incorrectly matched as
buybox sheets, adding all their ASINs as false BB lost entries.
Now only sheets starting with 'BB' are processed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Christian Vidal WolfandClaude Sonnet 4.6 committed 2026-03-03 15:38:39 +01:00
1 parent d1510bb76a
commit 916c349126
1 file changed
+8 -6
+8 -6
View File
@@ -2525,14 +2525,16 @@ export const processBuyBoxExcel = async (fileOrBuffer: File | ArrayBuffer): Prom
console.log('[BuyBox] Available sheets:', workbook.SheetNames.join(', '));
// Detect country code from sheet name (flexible matching)
// Detect country code from sheet name — only BB_* sheets to avoid false positives
const detectCountry = (name: string): string | null => {
const n = name.toUpperCase().replace(/[_\- ]/g, '');
if (n.includes('FRANCE') || n.includes('FRANC') || n.includes('BBFR') || n === 'FR') return 'FR';
if (n.includes('UNITEDKINGDOM') || n.includes('REINOUNIDO') || n.includes('BBUK') || n === 'UK' || n === 'GB') return 'UK';
if (n.includes('GERMANY') || n.includes('DEUTSCH') || n.includes('ALEMAN') || n.includes('BBDE') || n === 'DE') return 'DE';
if (n.includes('ITALY') || n.includes('ITALIA') || n.includes('BBIT') || n === 'IT') return 'IT';
if (n.includes('SPAIN') || n.includes('ESPAÑA') || n.includes('ESPANA') || n.includes('BBES') || n === 'ES') return 'ES';
// Require "BB" prefix to avoid matching inventory/other sheets (e.g. INV ITALY)
if (!n.startsWith('BB')) return null;
if (n.includes('FR') || n.includes('FRANCE')) return 'FR';
if (n.includes('UK') || n.includes('GB')) return 'UK';
if (n.includes('DE') || n.includes('GERMANY') || n.includes('DEUTSCH')) return 'DE';
if (n.includes('IT') || n.includes('ITALY') || n.includes('ITALIA')) return 'IT';
if (n.includes('ES') || n.includes('SPAIN') || n.includes('ESPANA')) return 'ES';
return null;
};