fix: relax data filters and marketplace mapping to restore sales visibility

This commit is contained in:
Christian Vidal Wolf
2026-04-16 11:37:33 +02:00
parent d2ee6c3bf0
commit 8c0401f3d5
+11 -5
View File
@@ -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<SalesRecord[]>
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) {