mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 11:05:23 +02:00
Fix: final refinement of revenue filtering to ensure Dashboard totals match Dropbox. Enforced Amazon-only marketplace check.
This commit is contained in:
@@ -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 ---
|
||||
|
||||
Reference in New Issue
Block a user