mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 12:45:23 +02:00
fix: exhaustive visibility fix for Sales/Ads data including inclusive filtering and permissive header validation
This commit is contained in:
@@ -325,17 +325,17 @@ export const validateSellOutHeaders = (headers: string[]) => {
|
|||||||
const hasYear = normHeaders.includes('year') || hasDateCol;
|
const hasYear = normHeaders.includes('year') || hasDateCol;
|
||||||
const hasTime = normHeaders.includes('month') || normHeaders.includes('week') || hasDateCol;
|
const hasTime = normHeaders.includes('month') || normHeaders.includes('week') || hasDateCol;
|
||||||
const hasCustomerRef = normHeaders.includes('customer reference') || normHeaders.includes('asin');
|
const hasCustomerRef = normHeaders.includes('customer reference') || normHeaders.includes('asin');
|
||||||
const hasEan = normHeaders.includes('ean');
|
const hasEan = normHeaders.includes('ean') || normHeaders.includes('isbn');
|
||||||
const hasUnits = normHeaders.includes('units');
|
const hasUnits = normHeaders.includes('units') || normHeaders.includes('qty') || normHeaders.includes('cantidad');
|
||||||
const hasAmount = normHeaders.includes('amount_eur') || normHeaders.includes('amount');
|
const hasAmount = ['amount_eur', 'amount', 'sell out', 'sellout', 'revenue', 'sales', 'valor'].some(a => normHeaders.includes(a));
|
||||||
|
|
||||||
const missing = [];
|
const missing = [];
|
||||||
if (!hasYear) missing.push('YEAR');
|
if (!hasYear) missing.push('YEAR');
|
||||||
if (!hasTime) missing.push('MONTH or WEEK');
|
if (!hasTime) missing.push('MONTH or WEEK');
|
||||||
if (!hasCustomerRef) missing.push('CUSTOMER REFERENCE');
|
if (!hasCustomerRef) missing.push('CUSTOMER REFERENCE / ASIN');
|
||||||
if (!hasEan) missing.push('EAN');
|
// EAN is optional now to prevent crashes with different report formats
|
||||||
if (!hasUnits) missing.push('UNITS');
|
if (!hasUnits) missing.push('UNITS');
|
||||||
if (!hasAmount) missing.push('AMOUNT_EUR');
|
if (!hasAmount) missing.push('AMOUNT / SALES');
|
||||||
|
|
||||||
if (missing.length > 0) {
|
if (missing.length > 0) {
|
||||||
throw new Error(`Invalid or missing critical columns in Sell-Out Report. Missing: ${missing.join(', ')}`);
|
throw new Error(`Invalid or missing critical columns in Sell-Out Report. Missing: ${missing.join(', ')}`);
|
||||||
@@ -1057,7 +1057,7 @@ export const filterAdsData = (
|
|||||||
|
|
||||||
// Country/Customer match (ads use 'country', sales use 'customer')
|
// Country/Customer match (ads use 'country', sales use 'customer')
|
||||||
const countryMatch = filters.customer.length === 0
|
const countryMatch = filters.customer.length === 0
|
||||||
? PAN_EU_COUNTRIES.some(c => c.toUpperCase() === ad.country.toUpperCase())
|
? true // Show all countries by default
|
||||||
: filters.customer.some(c => c.toUpperCase() === ad.country.toUpperCase());
|
: filters.customer.some(c => c.toUpperCase() === ad.country.toUpperCase());
|
||||||
|
|
||||||
// Year match
|
// Year match
|
||||||
@@ -1162,7 +1162,7 @@ export const filterData = (
|
|||||||
|
|
||||||
// 2. Filter Checks
|
// 2. Filter Checks
|
||||||
const customerMatch = filters.customer.length === 0
|
const customerMatch = filters.customer.length === 0
|
||||||
? (PAN_EU_COUNTRIES.includes(item.customer) || item.customer === 'Pan-EU')
|
? true // When no filter is selected, show EVERYTHING by default
|
||||||
: filters.customer.includes(item.customer);
|
: filters.customer.includes(item.customer);
|
||||||
const yearMatch = filters.year.length === 0 || filters.year.includes(item.year.toString());
|
const yearMatch = filters.year.length === 0 || filters.year.includes(item.year.toString());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user