Fix: correctly filter Dashboard revenue by enforcing Marketplace and Unit rules in filterData

This commit is contained in:
Christian Vidal Wolf
2026-04-20 13:04:41 +02:00
parent 8e81fc8500
commit f218db76ad
+7 -1
View File
@@ -1155,7 +1155,13 @@ export const filterData = (
}
// 2. Standard Filters
return result.filter(item => { // Apply remaining filters to the 'result'
return result.filter(item => {
// 0. Core Business Rules (Revenue Integrity)
// These filters ensure that only valid Amazon sales are aggregated,
// excluding ad spend and marketing records that might be present in the raw source.
if (!isAllowedCustomer(item.customer)) return false;
if (item.units === 0) return false;
// 1. Month Logic: Handle "Apr-23" matching "Apr" filter
const recordMonth = item.month; // e.g. "Apr-23"
const pureMonth = recordMonth.split('-')[0]; // "Apr"