diff --git a/services/dataProcessor.ts b/services/dataProcessor.ts index 9c92c56..7bbf088 100644 --- a/services/dataProcessor.ts +++ b/services/dataProcessor.ts @@ -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); }