diff --git a/services/dataProcessor.ts b/services/dataProcessor.ts index 72430cf..b3386cd 100644 --- a/services/dataProcessor.ts +++ b/services/dataProcessor.ts @@ -507,6 +507,7 @@ export const mergeSalesAndAdsData = (salesData: SalesRecord[], adsData: AdsRecor return { id: sale.id, marketplace: sale.customer, + customer: sale.customer, month: sale.month, year: sale.year, asin: sale.asin, @@ -1022,13 +1023,17 @@ export const pivotSalesData = (data: any[], dimensions: string[] = ['title', 'cu data.forEach(record => { // Group by Dynamic Dimensions - const keyParts = dimensions.map(dim => String(record[dim] || '')); + // Use a fallback for 'customer' dimension as some records use 'marketplace' + const keyParts = dimensions.map(dim => { + if (dim === 'customer') return String(record.customer || record.marketplace || ''); + return String(record[dim] || ''); + }); const key = keyParts.join('||'); if (!map.has(key)) { map.set(key, { id: key, - customer: dimensions.includes('customer') ? record.customer : '', + customer: dimensions.includes('customer') ? (record.customer || record.marketplace || '') : '', line: dimensions.includes('line') ? record.line : '', title: dimensions.includes('title') ? record.title : '', articleName: dimensions.includes('articleName') ? record.articleName : '', diff --git a/types.ts b/types.ts index 9788884..f1a52cc 100644 --- a/types.ts +++ b/types.ts @@ -153,6 +153,7 @@ export interface AdsRecord { export interface CombinedKPIs { id: string; marketplace: string; + customer: string; // Added for consistency with SalesRecord month: string; year: number; asin: string;