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 Wolf
2026-03-03 15:38:39 +01:00
co-authored by Claude Sonnet 4.6
parent d1510bb76a
commit 916c349126
+8 -6
View File
@@ -2525,14 +2525,16 @@ export const processBuyBoxExcel = async (fileOrBuffer: File | ArrayBuffer): Prom
console.log('[BuyBox] Available sheets:', workbook.SheetNames.join(', ')); 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 detectCountry = (name: string): string | null => {
const n = name.toUpperCase().replace(/[_\- ]/g, ''); const n = name.toUpperCase().replace(/[_\- ]/g, '');
if (n.includes('FRANCE') || n.includes('FRANC') || n.includes('BBFR') || n === 'FR') return 'FR'; // Require "BB" prefix to avoid matching inventory/other sheets (e.g. INV ITALY)
if (n.includes('UNITEDKINGDOM') || n.includes('REINOUNIDO') || n.includes('BBUK') || n === 'UK' || n === 'GB') return 'UK'; if (!n.startsWith('BB')) return null;
if (n.includes('GERMANY') || n.includes('DEUTSCH') || n.includes('ALEMAN') || n.includes('BBDE') || n === 'DE') return 'DE'; if (n.includes('FR') || n.includes('FRANCE')) return 'FR';
if (n.includes('ITALY') || n.includes('ITALIA') || n.includes('BBIT') || n === 'IT') return 'IT'; if (n.includes('UK') || n.includes('GB')) return 'UK';
if (n.includes('SPAIN') || n.includes('ESPAÑA') || n.includes('ESPANA') || n.includes('BBES') || n === 'ES') return 'ES'; 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; return null;
}; };