diff --git a/services/dataProcessor.ts b/services/dataProcessor.ts index 2a8168d..b1ac171 100644 --- a/services/dataProcessor.ts +++ b/services/dataProcessor.ts @@ -307,11 +307,16 @@ const isAllowedCustomer = (customer: string): boolean => { if (!customer) return false; const normCustomer = customer.trim().toLowerCase(); - // Use strict equality to prevent loose matches (e.g., 'UK' matching 'Amazon UK') - // which incorrectly included ad spend records in sell-out totals. - return ALLOWED_CUSTOMERS.some(allowed => - normCustomer === allowed.toLowerCase() - ); + // Strict business rule: Only records from recognized Amazon marketplaces are included in Sell-Out revenue. + // This excludes marketing spend, financial adjustments, and non-Amazon channels. + const isAmazon = normCustomer.startsWith('amazon') || normCustomer === 'pan-eu'; + + // Additional check: Ensure it's not JUST a country code (often used in ad-spend records) + const isOnlyCountryCode = ['uk', 'de', 'it', 'fr', 'es', 'nl', 'se', 'pl', 'be'].includes(normCustomer); + + if (isOnlyCountryCode && !normCustomer.startsWith('amazon')) return false; + + return isAmazon; }; // --- SALES / SELL OUT MAPPING ---