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 { return {
id: sale.id, id: sale.id,
marketplace: sale.customer, marketplace: sale.customer,
customer: sale.customer,
month: sale.month, month: sale.month,
year: sale.year, year: sale.year,
asin: sale.asin, asin: sale.asin,
@@ -1022,13 +1023,17 @@ export const pivotSalesData = (data: any[], dimensions: string[] = ['title', 'cu
data.forEach(record => { data.forEach(record => {
// Group by Dynamic Dimensions // 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('||'); const key = keyParts.join('||');
if (!map.has(key)) { if (!map.has(key)) {
map.set(key, { map.set(key, {
id: key, id: key,
customer: dimensions.includes('customer') ? record.customer : '', customer: dimensions.includes('customer') ? (record.customer || record.marketplace || '') : '',
line: dimensions.includes('line') ? record.line : '', line: dimensions.includes('line') ? record.line : '',
title: dimensions.includes('title') ? record.title : '', title: dimensions.includes('title') ? record.title : '',
articleName: dimensions.includes('articleName') ? record.articleName : '', articleName: dimensions.includes('articleName') ? record.articleName : '',
+1
View File
@@ -153,6 +153,7 @@ export interface AdsRecord {
export interface CombinedKPIs { export interface CombinedKPIs {
id: string; id: string;
marketplace: string; marketplace: string;
customer: string; // Added for consistency with SalesRecord
month: string; month: string;
year: number; year: number;
asin: string; asin: string;