diff --git a/services/dataProcessor.ts b/services/dataProcessor.ts index 55c8992..237f3a6 100644 --- a/services/dataProcessor.ts +++ b/services/dataProcessor.ts @@ -300,13 +300,19 @@ const getColumnValue = (row: any, aliases: (string | RegExp)[]): string => { return ''; }; // Allowed Customers Whitelist -export const PAN_EU_COUNTRIES = ['Amazon DE', 'Amazon IT', 'Amazon FR', 'Amazon ES']; -const ALLOWED_CUSTOMERS = [...PAN_EU_COUNTRIES, 'Amazon UK', 'Amazon SC']; +export const PAN_EU_COUNTRIES = ['Amazon DE', 'Amazon IT', 'Amazon FR', 'Amazon ES', 'Amazon NL', 'Amazon PL', 'Amazon BE', 'Amazon SE']; +const ALLOWED_CUSTOMERS = [...PAN_EU_COUNTRIES, 'Amazon UK', 'Amazon SC', 'Pan-EU']; const isAllowedCustomer = (customer: string): boolean => { if (!customer) return false; const normCustomer = customer.trim().toLowerCase(); - return ALLOWED_CUSTOMERS.some(allowed => allowed.toLowerCase() === normCustomer); + + // Check if the customer string includes any of our allowed market names + return ALLOWED_CUSTOMERS.some(allowed => + normCustomer === allowed.toLowerCase() || + normCustomer.includes(allowed.toLowerCase()) || + allowed.toLowerCase().includes(normCustomer) + ); }; // --- SALES / SELL OUT MAPPING --- @@ -405,8 +411,8 @@ export const processCSV = (fileOrContent: File | string): Promise const data: SalesRecord[] = results.data.map((row: any, index: number) => { return mapRowToRecord(row, index); }) - // Filter: Valid Year > 2023 (exclude incomplete 2023 data) AND Allowed Customer - .filter((r: SalesRecord) => r.year > 2023 && isAllowedCustomer(r.customer)); + // Filter: Valid Year >= 2023 (include full historical data) AND Allowed Customer + .filter((r: SalesRecord) => r.year >= 2023 && isAllowedCustomer(r.customer)); resolve(data); } catch (err) {