From 036e7b9a0a7a526b15b7e9acb6812499cfa215b6 Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Tue, 3 Mar 2026 14:23:08 +0100 Subject: [PATCH] fix: prioritize ASIN column detection over SKU in processBuyBoxExcel --- services/dataProcessor.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/services/dataProcessor.ts b/services/dataProcessor.ts index 949d588..78af947 100644 --- a/services/dataProcessor.ts +++ b/services/dataProcessor.ts @@ -2577,11 +2577,19 @@ export const processBuyBoxExcel = async (fileOrBuffer: File | ArrayBuffer): Prom } } - const asinIdx = headers.findIndex(h => { - const s = String(h || '').toUpperCase().trim(); - return s === 'ASIN' || s.includes('AMAZON ASIN') || s.includes('CHILD ASIN') || s.includes('IDENTIFIER') || s.includes('PRODUCT ID') || s.includes('SKU'); + let finalAsinIdx = headers.findIndex(h => { + const s = String(h || '').toUpperCase().replace(/[^A-Z]/g, ''); + return s === 'ASIN' || s.includes('AMAZONASIN') || s.includes('CHILDASIN'); }); - let finalAsinIdx = asinIdx !== -1 ? asinIdx : 1; // Default to Col B if not found + + if (finalAsinIdx === -1) { + finalAsinIdx = headers.findIndex(h => { + const s = String(h || '').toUpperCase().replace(/[^A-Z]/g, ''); + return s.includes('IDENTIFIER') || s.includes('PRODUCTID') || s.includes('SKU'); + }); + } + + if (finalAsinIdx === -1) finalAsinIdx = 1; // Default to Col B if not found // Dynamically find the "Issue Type" or "Reason" column let reasonIdx = headers.findIndex(h => {