Restore ForecastView UI, Fix default YTD logic, and Refine Seasonality (Specific > Global fallback)

This commit is contained in:
Christian Vidal Wolf
2026-01-28 14:55:35 +01:00
parent cfff95bff2
commit 9d732eeba3
2 changed files with 9 additions and 27 deletions
+2 -8
View File
@@ -1628,7 +1628,6 @@ export const calculateForecastViewData = (
const getWeights = (records: SalesRecord[]): number[] | null => {
const weights = new Array(12).fill(0);
let total = 0;
const seenMonths = new Set<string>();
records.forEach(r => {
const m = r.month.split('-')[0];
@@ -1636,18 +1635,13 @@ export const calculateForecastViewData = (
if (idx !== -1) {
weights[idx] += r.units;
total += r.units;
if (r.units > 0) seenMonths.add(m);
}
});
// 1. No data -> Fallback
// If ASIN has any 2025 sales, we trust its specific seasonality.
// Return null ONLY if there's no data at all for this ASIN in 2025.
if (total === 0) return null;
// 2. Sparse Data Check (< 4 months)
// If an ASIN has very little history (e.g. only Jan), using its own curve implies 100% seasonality in Jan.
// The user requested to use the "General Catalog Seasonality" in these cases.
if (seenMonths.size < 4) return null;
return weights.map(w => w / total);
};