mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 13:05:24 +02:00
fix: Weekly Sales Evolution chart now correctly supports CombinedKPIs data structure
This commit is contained in:
@@ -1367,8 +1367,9 @@ export const aggregateForTimeSeries = (data: SalesRecord[]): TimeSeriesData[] =>
|
|||||||
const key = `${record.year}-${weekStr}`;
|
const key = `${record.year}-${weekStr}`;
|
||||||
|
|
||||||
const current = map.get(key) || { sellOut: 0, units: 0 };
|
const current = map.get(key) || { sellOut: 0, units: 0 };
|
||||||
current.sellOut += record.sellOut;
|
// Support both SalesRecord (sellOut/units) and CombinedKPIs (salesTotal/unitsTotal)
|
||||||
current.units += record.units;
|
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);
|
map.set(key, current);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1408,8 +1409,12 @@ export const aggregateForComparisonTimeSeries = (data: SalesRecord[]): Compariso
|
|||||||
const sellOutKey = `${record.year}_sellOut`;
|
const sellOutKey = `${record.year}_sellOut`;
|
||||||
const unitsKey = `${record.year}_units`;
|
const unitsKey = `${record.year}_units`;
|
||||||
|
|
||||||
weekData[sellOutKey] = (weekData[sellOutKey] || 0) + record.sellOut;
|
// Support both SalesRecord (sellOut/units) and CombinedKPIs (salesTotal/unitsTotal)
|
||||||
weekData[unitsKey] = (weekData[unitsKey] || 0) + record.units;
|
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);
|
map.set(record.week, weekData);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user