fix: Weekly Sales Evolution chart now correctly supports CombinedKPIs data structure

This commit is contained in:
Christian Vidal Wolf
2026-01-26 14:36:42 +01:00
parent 1f1077edcd
commit 48f185e3bc
+9 -4
View File
@@ -1367,8 +1367,9 @@ export const aggregateForTimeSeries = (data: SalesRecord[]): TimeSeriesData[] =>
const key = `${record.year}-${weekStr}`;
const current = map.get(key) || { sellOut: 0, units: 0 };
current.sellOut += record.sellOut;
current.units += record.units;
// Support both SalesRecord (sellOut/units) and CombinedKPIs (salesTotal/unitsTotal)
current.sellOut += (record as any).sellOut ?? (record as any).salesTotal ?? 0;
current.units += (record as any).units ?? (record as any).unitsTotal ?? 0;
map.set(key, current);
});
@@ -1408,8 +1409,12 @@ export const aggregateForComparisonTimeSeries = (data: SalesRecord[]): Compariso
const sellOutKey = `${record.year}_sellOut`;
const unitsKey = `${record.year}_units`;
weekData[sellOutKey] = (weekData[sellOutKey] || 0) + record.sellOut;
weekData[unitsKey] = (weekData[unitsKey] || 0) + record.units;
// Support both SalesRecord (sellOut/units) and CombinedKPIs (salesTotal/unitsTotal)
const sellOut = (record as any).sellOut ?? (record as any).salesTotal ?? 0;
const units = (record as any).units ?? (record as any).unitsTotal ?? 0;
weekData[sellOutKey] = (weekData[sellOutKey] || 0) + sellOut;
weekData[unitsKey] = (weekData[unitsKey] || 0) + units;
map.set(record.week, weekData);
}