Fix: final refinement of revenue filtering to ensure Dashboard totals match Dropbox. Enforced Amazon-only marketplace check.

This commit is contained in:
Christian Vidal Wolf
2026-04-20 13:07:25 +02:00
parent f218db76ad
commit f54aafb44c
+10 -5
View File
@@ -307,11 +307,16 @@ const isAllowedCustomer = (customer: string): boolean => {
if (!customer) return false; if (!customer) return false;
const normCustomer = customer.trim().toLowerCase(); const normCustomer = customer.trim().toLowerCase();
// Use strict equality to prevent loose matches (e.g., 'UK' matching 'Amazon UK') // Strict business rule: Only records from recognized Amazon marketplaces are included in Sell-Out revenue.
// which incorrectly included ad spend records in sell-out totals. // This excludes marketing spend, financial adjustments, and non-Amazon channels.
return ALLOWED_CUSTOMERS.some(allowed => const isAmazon = normCustomer.startsWith('amazon') || normCustomer === 'pan-eu';
normCustomer === allowed.toLowerCase()
); // 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 --- // --- SALES / SELL OUT MAPPING ---