diff --git a/services/dataProcessor.ts b/services/dataProcessor.ts index ccff8e1..6a59e7e 100644 --- a/services/dataProcessor.ts +++ b/services/dataProcessor.ts @@ -325,17 +325,17 @@ export const validateSellOutHeaders = (headers: string[]) => { const hasYear = normHeaders.includes('year') || hasDateCol; const hasTime = normHeaders.includes('month') || normHeaders.includes('week') || hasDateCol; const hasCustomerRef = normHeaders.includes('customer reference') || normHeaders.includes('asin'); - const hasEan = normHeaders.includes('ean'); - const hasUnits = normHeaders.includes('units'); - const hasAmount = normHeaders.includes('amount_eur') || normHeaders.includes('amount'); + const hasEan = normHeaders.includes('ean') || normHeaders.includes('isbn'); + const hasUnits = normHeaders.includes('units') || normHeaders.includes('qty') || normHeaders.includes('cantidad'); + const hasAmount = ['amount_eur', 'amount', 'sell out', 'sellout', 'revenue', 'sales', 'valor'].some(a => normHeaders.includes(a)); const missing = []; if (!hasYear) missing.push('YEAR'); if (!hasTime) missing.push('MONTH or WEEK'); - if (!hasCustomerRef) missing.push('CUSTOMER REFERENCE'); - if (!hasEan) missing.push('EAN'); + if (!hasCustomerRef) missing.push('CUSTOMER REFERENCE / ASIN'); + // EAN is optional now to prevent crashes with different report formats if (!hasUnits) missing.push('UNITS'); - if (!hasAmount) missing.push('AMOUNT_EUR'); + if (!hasAmount) missing.push('AMOUNT / SALES'); if (missing.length > 0) { throw new Error(`Invalid or missing critical columns in Sell-Out Report. Missing: ${missing.join(', ')}`); @@ -1057,7 +1057,7 @@ export const filterAdsData = ( // Country/Customer match (ads use 'country', sales use 'customer') const countryMatch = filters.customer.length === 0 - ? PAN_EU_COUNTRIES.some(c => c.toUpperCase() === ad.country.toUpperCase()) + ? true // Show all countries by default : filters.customer.some(c => c.toUpperCase() === ad.country.toUpperCase()); // Year match @@ -1162,7 +1162,7 @@ export const filterData = ( // 2. Filter Checks const customerMatch = filters.customer.length === 0 - ? (PAN_EU_COUNTRIES.includes(item.customer) || item.customer === 'Pan-EU') + ? true // When no filter is selected, show EVERYTHING by default : filters.customer.includes(item.customer); const yearMatch = filters.year.length === 0 || filters.year.includes(item.year.toString());