mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 20:15:23 +02:00
fix: zero out deals/promos/chargebacks when 2025 is not in filtered scope
These Excel files only contain 2025 data. When the top filter excludes 2025 (e.g. year=2024), the maps are ignored so columns show 0 instead of stale 2025 figures. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
0eda5551d8
commit
36fa63b6c1
@@ -175,6 +175,12 @@ export default function MktDataView({ rawData, adsData }: MktDataViewProps) {
|
||||
if (asin) adsSpendMap.set(asin, (adsSpendMap.get(asin) || 0) + r.cost);
|
||||
});
|
||||
|
||||
// Deals/Promos/Chargebacks are 2025-only data — only apply when 2025 is in scope
|
||||
const has2025 = rawData.some(r => r.year === 2025) || adsData.some(r => r.year === 2025);
|
||||
const getDeals = (asin: string) => has2025 ? (dealsMap.get(asin) || 0) : 0;
|
||||
const getPromos = (asin: string) => has2025 ? (promosMap.get(asin) || 0) : 0;
|
||||
const getChargebacks = (asin: string) => has2025 ? (chargebacksMap.get(asin) || 0) : 0;
|
||||
|
||||
// Build products from sales ASINs
|
||||
const products = Array.from(metaMap.entries())
|
||||
.map(([asin, meta]): Product => ({
|
||||
@@ -188,9 +194,9 @@ export default function MktDataView({ rawData, adsData }: MktDataViewProps) {
|
||||
grossSales: sellOutMap.get(asin) || 0,
|
||||
unitsSold: unitsMap.get(asin) || 0,
|
||||
ppcSpend: adsSpendMap.get(asin) || 0,
|
||||
deals: dealsMap.get(asin) || 0,
|
||||
promos: promosMap.get(asin) || 0,
|
||||
chargebacks: chargebacksMap.get(asin) || 0,
|
||||
deals: getDeals(asin),
|
||||
promos: getPromos(asin),
|
||||
chargebacks: getChargebacks(asin),
|
||||
chargebacksPrevMonth: 0,
|
||||
cogs: 0,
|
||||
}));
|
||||
@@ -209,9 +215,9 @@ export default function MktDataView({ rawData, adsData }: MktDataViewProps) {
|
||||
grossSales: 0,
|
||||
unitsSold: 0,
|
||||
ppcSpend: spend,
|
||||
deals: dealsMap.get(asin) || 0,
|
||||
promos: promosMap.get(asin) || 0,
|
||||
chargebacks: chargebacksMap.get(asin) || 0,
|
||||
deals: getDeals(asin),
|
||||
promos: getPromos(asin),
|
||||
chargebacks: getChargebacks(asin),
|
||||
chargebacksPrevMonth: 0,
|
||||
cogs: 0,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user