mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 14:45:24 +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;
|
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 ---
|
||||||
|
|||||||
Reference in New Issue
Block a user