How does the daily forecast adjustment work in MySales?
Daily Forecast Adjustment in MySales (updateDaily.js)
The daily forecast adjustment is a mechanism for operationally adapting the weekly forecast based on the latest actual sales. It is implemented in updateDaily.js and serves to:
Respond quickly to changes in demand
Adjust the trend
Account for OOS (lost sales)
Separate regular and promo demand
Below is a structured explanation of its logic.
1️⃣ Basic Concept
The system:
Analyzes the last 28 calendar days
Selects up to 7 valid days
Adjusts sales for:
Seasonality
Price
Weather
Discounts
Builds:
Average
Linear trend
The weekly forecast is calculated as:
Week=trendShare×trendWeekAvg+(1−trendShare)×avgWeek\text{Week} = \text{trendShare} \times \text{trendWeekAvg} + (1 - \text{trendShare}) \times \text{avgWeek}Week=trendShare×trendWeekAvg+(1−trendShare)×avgWeek
If the trend is disabled, only the average is used.
2️⃣ Valid Days
From the last 28 days, up to 7 suitable days are selected. A day is included if:
✔️ There was stock
✔️ Stock was not critically low
✔️ Stock ≥ 30% of minimum daily forecast (
dailyUpdateMinSalesRatio = 0.3)✔️ Price deviation ≤ 15%
✔️ Regular and Promo are analyzed separately (by
promoId)
Special logic for low stock:
If stock < 30% and no sales → day is excluded (likely OOS, write-off, or non-display)
If stock < 30% and sales occurred → day can be used, and sales are adjusted relative to the forecast
This is critical for accounting for lost sales
3️⃣ Separation of Regular and Promo
Forecasts are adjusted separately for:
Regular
Promo (by each
promoId)
Trend and average are calculated independently for each.
4️⃣ Mechanism Parameters
Parameter | Value |
|---|---|
minDailyAdjust regular | 2 days |
minDailyAdjust promo | 1 day |
minDailyAdjust.trendRegular | 4 (if undefined) |
minDailyAdjust.trendPromo | 4 |
dailyUpdateMaxDays | 7 |
dailyUpdateFutureWeeks | 2 |
dailyUpdateMinSalesRatio | 0.3 |
Key Notes:
If
trendRegular = null→ trend is disabledMaximum 7 days analyzed
Adjustment is applied 2 weeks forward
5️⃣ How the Final Value Is Calculated
After adjusting the days:
Days are aligned to the calendar (missing days are considered)
Average (
avgWeek) and trend (trendWeekAvg) are computedFinal weekly forecast:
Final=trendShare×trendWeekAvg+(1−trendShare)×avgWeek\text{Final} = \text{trendShare} \times \text{trendWeekAvg} + (1 - \text{trendShare}) \times \text{avgWeek}Final=trendShare×trendWeekAvg+(1−trendShare)×avgWeek
6️⃣ Limits on Sudden Changes
To prevent forecast “spikes”:
Slow-moving SKUs (median ≈ 0) → max ±2×
Limited data (<4 selling days) → max ±3×
Exceptions (new SKU / first promo and ≥4 days) → max ±6× (rare)
7️⃣ Impact on Ordering
Daily adjustment affects:
D1D2 forecast
Lost sales calculation
self.salesDayUsed
Auto Replenishment
Demand formula:
Demand=Forecast(D1D2)+SafetyStock+Presentation−Stock(D1)\text{Demand} = \text{Forecast(D1D2)} + \text{SafetyStock} + \text{Presentation} - \text{Stock(D1)}Demand=Forecast(D1D2)+SafetyStock+Presentation−Stock(D1)
Additional D1D2 cycles may also be added.
8️⃣ When the Mechanism Is Especially Important
Sharp increase or decrease in demand
After OOS
At the start of a promotion
Price changes
Competitor openings
9️⃣ Managerial Notes
This is not a full model recalculation
It is an operational adjustment of the base forecast
It amplifies the trend but is limited by coefficients
Works separately for regular and promo