feat: show ad spend and remove grouping in weekly sales tab

This commit is contained in:
Christian Vidal Wolf
2026-01-21 15:05:59 +01:00
parent ecfa3ee9ec
commit e93da747a3
2 changed files with 60 additions and 62 deletions
+7 -4
View File
@@ -1262,11 +1262,12 @@ export interface WeeklyPivotRow {
line: string;
customer: string;
unitsByWeek: { [weekKey: string]: number }; // Key: "YYYY-WW"
spendByWeek: { [weekKey: string]: number }; // Key: "YYYY-WW"
}
export const pivotWeeklySalesData = (data: CombinedKPIs[]): {
rows: WeeklyPivotRow[],
weeks: string[]
export const pivotWeeklySalesData = (data: CombinedKPIs[]): {
rows: WeeklyPivotRow[],
weeks: string[]
} => {
// 1. Identify all unique weeks and sort descending (YYYY-WW)
const weekKeys = new Set<string>();
@@ -1292,7 +1293,8 @@ export const pivotWeeklySalesData = (data: CombinedKPIs[]): {
asin: record.asin || '',
line: record.line || '',
customer: record.customer || record.marketplace || '',
unitsByWeek: {}
unitsByWeek: {},
spendByWeek: {}
});
}
@@ -1300,6 +1302,7 @@ export const pivotWeeklySalesData = (data: CombinedKPIs[]): {
if (record.week) {
const weekKey = `${record.year}-${String(record.week).padStart(2, '0')}`;
row.unitsByWeek[weekKey] = (row.unitsByWeek[weekKey] || 0) + record.unitsTotal;
row.spendByWeek[weekKey] = (row.spendByWeek[weekKey] || 0) + (record.cost || 0);
}
});