mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 11:45:23 +02:00
fix: relax data filters and marketplace mapping to restore sales visibility
This commit is contained in:
@@ -300,13 +300,19 @@ const getColumnValue = (row: any, aliases: (string | RegExp)[]): string => {
|
|||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
// Allowed Customers Whitelist
|
// Allowed Customers Whitelist
|
||||||
export const PAN_EU_COUNTRIES = ['Amazon DE', 'Amazon IT', 'Amazon FR', 'Amazon ES'];
|
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'];
|
const ALLOWED_CUSTOMERS = [...PAN_EU_COUNTRIES, 'Amazon UK', 'Amazon SC', 'Pan-EU'];
|
||||||
|
|
||||||
const isAllowedCustomer = (customer: string): boolean => {
|
const isAllowedCustomer = (customer: string): boolean => {
|
||||||
if (!customer) return false;
|
if (!customer) return false;
|
||||||
const normCustomer = customer.trim().toLowerCase();
|
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 ---
|
// --- 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) => {
|
const data: SalesRecord[] = results.data.map((row: any, index: number) => {
|
||||||
return mapRowToRecord(row, index);
|
return mapRowToRecord(row, index);
|
||||||
})
|
})
|
||||||
// Filter: Valid Year > 2023 (exclude incomplete 2023 data) AND Allowed Customer
|
// Filter: Valid Year >= 2023 (include full historical data) AND Allowed Customer
|
||||||
.filter((r: SalesRecord) => r.year > 2023 && isAllowedCustomer(r.customer));
|
.filter((r: SalesRecord) => r.year >= 2023 && isAllowedCustomer(r.customer));
|
||||||
|
|
||||||
resolve(data);
|
resolve(data);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user