fix: restore customer field in grid by normalizing CombinedKPIs fields

This commit is contained in:
Christian Vidal Wolf
2026-01-21 11:04:53 +01:00
parent b6573ebe15
commit c7cef7954b
2 changed files with 8 additions and 2 deletions
+7 -2
View File
@@ -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 : '',
+1
View File
@@ -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;