mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 14:55:23 +02:00
feat: show ad spend and remove grouping in weekly sales tab
This commit is contained in:
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user