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;
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 ---