diff --git a/services/dataProcessor.ts b/services/dataProcessor.ts index b275d87..71a047c 100644 --- a/services/dataProcessor.ts +++ b/services/dataProcessor.ts @@ -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; };