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 => {