mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 13:15:24 +02:00
Restore ForecastView UI, Fix default YTD logic, and Refine Seasonality (Specific > Global fallback)
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user