fix: correct revenue metric mapping in Weekly Sales grid (pivot revenue vs ads cost)

This commit is contained in:
Christian Vidal Wolf
2026-02-19 16:22:19 +01:00
parent 079e4130f7
commit 2b9399e7e0
3 changed files with 256360 additions and 27 deletions
+4 -1
View File
@@ -1642,7 +1642,8 @@ export interface WeeklyPivotRow {
line: string;
customer: string;
unitsByWeek: { [weekKey: string]: number }; // Key: "YYYY-WW"
spendByWeek: { [weekKey: string]: number }; // Key: "YYYY-WW"
spendByWeek: { [weekKey: string]: number }; // Key: "YYYY-WW" (Ads Cost)
revenueByWeek: { [weekKey: string]: number }; // Key: "YYYY-WW" (Sell-out)
gvByWeek: { [weekKey: string]: number }; // Key: "YYYY-WW"
}
@@ -1691,6 +1692,7 @@ export const pivotWeeklySalesData = (data: CombinedKPIs[]): {
customer: record.customer || record.marketplace || '',
unitsByWeek: {},
spendByWeek: {},
revenueByWeek: {},
gvByWeek: {}
};
map.set(key, row);
@@ -1698,6 +1700,7 @@ export const pivotWeeklySalesData = (data: CombinedKPIs[]): {
row.unitsByWeek[weekKey] = (row.unitsByWeek[weekKey] || 0) + (record.unitsTotal || 0);
row.spendByWeek[weekKey] = (row.spendByWeek[weekKey] || 0) + (record.cost || 0);
row.revenueByWeek[weekKey] = (row.revenueByWeek[weekKey] || 0) + (record.salesTotal || 0);
row.gvByWeek[weekKey] = (row.gvByWeek[weekKey] || 0) + (record.glanceViews || 0);
}