From 916c349126e9e66e2da15d5a2d6e692bb8f209b8 Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Tue, 3 Mar 2026 15:38:39 +0100 Subject: [PATCH] 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 --- services/dataProcessor.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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; };