Forecasting Modules - Logic, Rules, Worked Examples
For each module you get: purpose, key fields, validation rules, calculation logic with formulas, a complete worked example, and edge cases. All formulas are presented exactly as the engine applies them, so a consultant can reproduce any number on screen.
7.1 Inventory Forecast
Where: iVendNext → Foresight → Inventory Forecast
Purpose
Predicts how many units of one item will be consumed from one warehouse over the forecast period, computes the reorder point, suggests a purchase quantity, and (optionally) drafts a Purchase Order.
Key fields
| Field | Notes |
|---|---|
| Item | Mandatory |
| Warehouse | Mandatory; determines the company |
| Company | Derived from the warehouse |
| Current stock | Read from live stock balance |
| Forecast period (days) | Default 30 |
| Lead time (days) | Default 7; used in the reorder formula |
| Predicted consumption | Engine output |
| Movement type | Fast / Slow / Non Moving / Critical |
| Confidence score | 0–100 % |
| Reorder level | Engine output |
| Suggested quantity | Engine output |
| Reorder alert | True when current stock ≤ reorder level |
| Auto-create PO | Toggle |
| Supplier / preferred supplier | Used for auto-PO |
Validation rules
Items and warehouses are mandatory.
Company is derived from the warehouse; a mismatch is rejected.
Current stock is read from the live balance and cannot be typed manually.
The preferred supplier is set automatically when one can be determined.
Calculation logic
The engine uses a trend-fit when there is enough movement history (at least ten consumption events in the recent window), otherwise a moving average.
Trend-fit path:
daily_avg = average daily consumption from the fitted trend
confidence = how well the trend fits, scaled to 50–95 %
movement type:
daily_avg > 2 → Fast Moving
daily_avg > 0.5 → Slow Moving
else → Non Moving
safety_factor = 1.5 if Fast Moving else 1.2
reorder_level = daily_avg × lead_time × safety_factor
suggested_qty = daily_avg × (forecast_period + lead_time) (minimum 1)
reorder_alert = current_stock ≤ reorder_level
Moving-average path:
daily_consumption = total consumption (last 90 days) / max(30, days with consumption)
predicted_consumption = daily_consumption × forecast_period
movement type:
daily > 5 OR active days > 15 → Fast Moving (confidence 85)
daily > 1 OR active days > 5 → Slow Moving (confidence 70)
daily > 0.1 → Non Moving (confidence 50)
else → Critical (confidence 40)
reorder_level = daily_consumption × lead_time × safety_factor
suggested_qty = Fast → daily × 45 (1.5 months)
Slow → daily × 60 (2 months)
else → daily × 30 (1 month)
If anything prevents a forecast (for example, no history at all), the item is marked Critical with a conservative reorder level and an alert is raised, so it is never silently ignored.
Worked example: item "TSHIRT-RED-M" at warehouse "Mumbai-Main"
Observed over the last 90 days:
- Total consumption: 600 units · Days with sales: 45 · Lead time: 14 days · Current stock: 80 units · Forecast period: 30 days
Step 1: daily consumption
daily = 600 / max(30, 45) = 600 / 45 = 13.33 units/day
Step 2: movement type (moving-average path)
daily 13.33 > 5 AND active days 45 > 15 → Fast Moving (confidence 85 %)
Step 3: predicted consumption
predicted = 13.33 × 30 = 400 units
Step 4: reorder level
safety_factor = 1.5 (Fast Moving)
reorder_level = 13.33 × 14 × 1.5 = 280 units
Step 5: suggested quantity
suggested_qty = 13.33 × 45 = 600 units
Step 6: reorder alert
current_stock 80 ≤ reorder_level 280 → alert ON
Result on screen:
Fast Moving · 400 predicted · reorder at 280 · suggest 600 · Alert ON. With auto-PO enabled and a preferred supplier set, a draft Purchase Order for 600 units is created, scheduled 14 days out, for the buyer to review.
Edge cases
| Scenario | What happens | What to tell the customer |
|---|---|---|
| Brand-new item, no history | Marked Critical, conservative reorder, alert ON | "We don't predict on no data. Set the reorder manually for the first 90 days." |
| Sample-only item (no sales) | Non Moving, confidence 50 % | "Mark such items as not-for-forecasting to keep dashboards clean." |
| Festival promotion week | Daily average spikes then falls | "Hold these items out of auto-reorder during the campaign." |
| Strongly seasonal item | Trend-fit under-predicts peaks | "Switch the financial model to Prophet for seasonal lines." |
| Warehouse not linked to a company | Save is rejected | "Fix the warehouse-company link in master data." |
Auto-PO behaviour
This is triggered when all of these are true: reorder alert, auto-create PO, and a preferred supplier. The system then:
Skips if the suggested quantity is zero or less.
Skips if a purchase order for this item was already raised in the last 7 days (this prevents duplicates).
Chooses the best supplier (by price and delivery performance where available, otherwise the most recent supplier used).
Creates a draft Purchase Order, scheduled by the item's lead time, for the suggested quantity.
Leaves the order as a draft for the buyer to review and submit. The human stays in control.
Never promise customers fully automatic, unattended PO submission. By design, Foresight drafts the order and the buyer approves it.
7.2 Sales Forecast
Where: iVendNext → Foresight → Sales Forecast
Purpose
Predicts how many units of an item a specific customer will buy in the forecast period, plus revenue potential, churn risk, cross-sell score, and seasonality. Drives the Sales Dashboard and, optionally, auto-Sales-Order creation.
Key fields
Item · Customer · Territory · Company · Forecast period (default 30) · Forecast date · Predicted quantity · Sales trend (Increasing / Decreasing / Stable / Volatile) · Movement type · Confidence score · Actual quantity · Accuracy score · Sales alert · Demand pattern · Customer score · Market potential · Seasonality index · Revenue potential · Cross-sell score · Churn risk (Low / Medium / High / Unknown) · Sales velocity · Auto-create Sales Order · Delivery days (default 7).
Validation & business rules
Negative predicted quantity is corrected to zero.
On save, the sales trend and movement type are set from the predicted quantity:
| Predicted quantity | Sales trend | Movement type |
|---|---|---|
| > 10 | Increasing | Fast Moving |
| > 5 | Stable | Slow Moving |
| > 0 | Decreasing | Non Moving |
| ≤ 0 | Stable | Critical |
sales_velocity = predicted_qty / forecast_period.
Consultant note. Because movement type is derived from predicted quantity on every save, customer-specific movement thresholds are not configurable today. Flag this in the blueprint if a customer needs custom thresholds.
Forecasting engine
Uses a pattern-learning approach per item when there is enough history (at least ten data points), trained on calendar signals, recent averages, lags, the rate, customer segment, and churn probability.
When history is sparse, it falls back to a recency-weighted simple forecast:
base_qty = average quantity over the last 90 days
recency_factor = higher weight for recent activity
weekend_factor = 0.7 on weekends, 1.0 on weekdays
seasonal_factor= ±10 % by month
trend_factor = small daily trend adjustment
predicted_day = base_qty × weekend × seasonal × trend × recency
confidence = 60 + transaction-volume bonus + recency bonus + stability bonus (capped 50–95)
Confidence (pattern-learning path):
data_points = sales transactions for this item × customer over 90 days
confidence = min(70 + data_points × 2, 95)
reduced by 20 (floor 50) if predicted quantity ≤ 0
Analytics formulas
| Field | Formula |
|---|---|
| Customer score | 30 + min(purchases × 5, 40) + min(total_value / 10000 × 30, 30) over 180 days |
| Market potential | base_by_movement × confidence/100 × (0.5 + min(predicted/100, 1) × 0.5) (Critical 90, Fast 75, Slow 40, else 60) |
| Seasonality index | Nov–Jan 1.3, Jun–Aug 0.8 when seasonal; Increasing 1.2, Decreasing 0.8; else 1.0 |
| Revenue potential | predicted_qty × average selling rate (180 days) → fallback item price → 100 |
| Cross-sell score | min(30 + distinct_items × 5, 90) |
| Churn risk | Decreasing → High; Stable → Medium; Increasing → Low; else by recent order count |
Worked example: item "TSHIRT-RED-M" × customer "ACME Retailers"
Observed: 12 invoices over 90 days · total 84 units · average rate ₹450 · last order 4 days ago · rising trend.
predicted_qty = 18 units (next 30 days)
data_points = 12
confidence = min(70 + 12×2, 95) = 94 %
movement (qty>10) = Increasing / Fast Moving
sales_velocity = 18 / 30 = 0.6
customer_score = 30 + min(12×5,40) + min(84×450/10000×30,30) = 30 + 40 + 11 = 81
market_potential = 75 × 0.94 × (0.5 + min(18/100,1)×0.5) = 41.6 %
seasonality_index = 1.2 (rising)
revenue_potential = 18 × 450 = ₹ 8 100
churn_risk = Low (rising)
demand_pattern = "Growth"
How to read it: "ACME will buy about 18 units next month, worth ₹8 100. They are a high-value customer (score 81), with low churn risk and strong cross-sell potential."
Edge cases
| Scenario | What happens |
|---|---|
| Customer with very few invoices | Falls back to a simple forecast, with lower confidence |
| Item not flagged for forecasting | Skipped. Set the flag on the item. |
| Negative predicted quantity | Corrected to zero, marked Critical |
Auto-SO behaviour
When enabled, Foresight selects forecasts due in the next 7 days with confidence above the threshold (default 85 %) and a positive quantity, skips any customer/date that already has a sales order, and prepares the order. Recommendation: keep auto-SO off until at least 30 days of accuracy tracking shows the forecasts are trustworthy, then pilot on one customer or item group. Always pair it with credit-limit checks.
7.3 Financial Forecast (Master)
Where: iVendNext → Foresight → Financial Forecast
Purpose
The master finance forecast. Cashflow, Revenue, and Expense forecasts all roll up here, and accuracy and alerts hang off it.
Key fields
Company · Account · Account type · Forecast type (Cash Flow / Revenue / Expense / Balance Sheet / P&L) · Start/End date · Period (days) · Prediction model · Predicted amount · Upper/Lower bound · Confidence score · Confidence threshold · Forecast accuracy · Volatility score · Data quality score · Risk category (Low / Medium / High / Critical) · Trend direction · Current balance · Auto-sync · Sync frequency · Sync status · Forecast alert.
Validation rules
Forecast type must be one of the five allowed values.
End date must be after the start date (otherwise it is derived from the period).
Confidence score between 0 and 100.
Upper bound must be greater than lower bound (a built-in correction can swap them if reversed).
Negative predicted amount is allowed only for Expense and Cash Flow.
Account-type vs forecast-type compatibility:
| Forecast type | Allowed account types |
|---|---|
| Cash Flow | Bank, Cash, Receivable, Payable |
| Revenue | Income, Revenue |
| Expense | Expense |
| Balance Sheet | Asset, Liability, Equity |
| P&L | Income, Expense, Revenue |
Calculation logic
volatility_score = (upper_bound − lower_bound) / |predicted_amount| × 100 (0–100)
forecast_accuracy = ≥ 80 High | ≥ 60 Medium | else Low
risk_category = confidence ≥ 75 AND volatility ≤ 30 → Low
| confidence ≥ 60 AND volatility ≤ 50 → Medium
| confidence ≥ 40 → High
| else → Critical
trend_direction = change vs last forecast:
> +5 % Increasing | < −5 % Decreasing | |change| > 2 % Volatile | else Stable
forecast_alert = confidence < threshold
OR risk ∈ {High, Critical}
OR volatility > 75
Balance alerts
| Condition | Alert |
|---|---|
| Current balance < critical threshold | Critical |
| Current balance < cash trigger threshold | Warning |
| Current balance < 0 | Critical (negative balance) |
| Prediction differs from balance by > 50 % | Info |
Worked example: cash-flow forecast for "Acme Retail"
Inputs: predicted ₹ 12 50 000 · upper ₹ 14 00 000 · lower ₹ 11 00 000 · confidence 78 · current balance ₹ 11 80 000 · prior forecast ₹ 11 80 000.
volatility = (14 00 000 − 11 00 000) / 12 50 000 × 100 = 24 %
accuracy band= 78 → Medium
risk = confidence 78 ≥ 75 AND volatility 24 ≤ 30 → Low
trend = +5.9 % vs prior → Increasing
alert = confidence ≥ threshold, risk Low, volatility ≤ 75 → no alert
balance check= 11 80 000 above all thresholds, prediction within 6 % → healthy
This is a healthy forecast, and the system queues the Cashflow detail automatically.
What this module does not do
It does not run a model itself. It records the chosen model and scores the prediction's risk, volatility, and quality. The forecasting itself happens in the engines and in the detail modules below.
7.4 Cashflow Forecast
Purpose
A line-itemised cash inflow / outflow projection per company per month.
Inflows: receivables collection, sales forecast amount, other income, investment returns, loan proceeds. Outflows: payables payment, inventory purchases, operating expenses, capital expenditure, loan payments.
Calculation
predicted_inflows = Σ inflow components
predicted_outflows = Σ outflow components
net_cash_flow = inflows − outflows
closing_balance = opening_balance + net_cash_flow
surplus_deficit = closing_balance − minimum_cash_required
liquidity_ratio = inflows / outflows × 100 (100 if no outflows)
Risk & confidence
data_completeness = filled(receivables, payables, opex) / 3 × 100
ratio_health = liquidity ≥ 120 → 90 | ≥ 110 → 80 | ≥ 100 → 70 | ≥ 90 → 60 | else 40
confidence = (data_completeness + ratio_health) / 2
risk_score = liquidity < 100 → 90 | < 110 → 70 | < 130 → 40 | else 20
seasonal_factor = Oct–Dec 1.2 | Jan–Feb 0.8 | Jun–Aug 0.9 | else 1.0
alert_status = surplus_deficit < 0 → Critical | liquidity < 110 → Warning | else Normal
When inflow/outflow fields are left blank, Foresight populates them automatically from the company's cash and bank account movement for the month.
Worked example: June 2026, "Acme Retail"
Inputs: receivables ₹ 18 00 000 · payables ₹ 9 50 000 · inventory purchases ₹ 4 00 000 · opex ₹ 3 50 000 · opening ₹ 5 00 000 · minimum cash ₹ 2 00 000.
inflows = 18 00 000
outflows = 17 00 000
net_cash_flow = 1 00 000
closing_balance= 6 00 000
surplus_deficit= 4 00 000
liquidity_ratio= 105.9 %
confidence = (100 + 70)/2 = 85
risk_score = 70 (liquidity < 110)
alert_status = Warning (surplus positive but liquidity below 110)
Reading: This is a healthy month with a ₹4 lakh surplus, but liquidity is just below the comfort line. Accelerate collections or defer one large payment.
7.5 Revenue Forecast
Purpose
Revenue projection by category (product, service, recurring, one-time, commission, other) with growth, seasonality, market, and risk factors.
Calculation
total_predicted_revenue = Σ revenue categories
growth_rate = (current − previous) / previous × 100
confidence_score = min(95, max(50, 80 + growth_rate × 0.3))
seasonal_factor: Nov–Dec 1.3 | Jan–Feb 0.7 | Jun–Aug 0.9 | Sep–Oct 1.1 | else 1.0
market_factor: growth > 10 → 1.2 | growth < −5 → 0.8 | else 1.0
risk_adjustment: +10 if |growth| > 20, +15 if confidence < 70, +10 if any category > 80 % of total
trend_direction: growth > 5 Increasing | < −5 Decreasing | else Stable
When a revenue figure is needed, Foresight can populate it automatically from the company's confirmed sales for the period.
Worked example: November, "Acme Retail"
Inputs: product ₹ 32 00 000 · service ₹ 4 00 000 · recurring ₹ 3 00 000 · prior period ₹ 30 00 000.
total = 39 00 000
growth_rate = (39 − 30)/30 × 100 = 30 %
confidence = min(95, 80 + 30×0.3) = 89 %
seasonal_factor = 1.3 (November)
market_factor = 1.2 (growth > 10)
risk_adjustment = 10 % (growth > 20)
trend = Increasing
Reading: "A strong month, up 30 % on the prior period, with November seasonality reinforcing it. A conservative risk-adjusted view is about ₹35 lakh."
7.6 Expense Forecast
Purpose
Expense projection with category breakdown, variance against actuals, and optimisation suggestions.
Categories: fixed, variable, semi-variable, inventory-related, operational, administrative. Inventory-linked costs: storage, handling, purchase-related, reorder, carrying, stockout.
Calculation
total_predicted_expense = Σ categories + Σ inventory-linked costs
variance_percentage = (actual − forecast) / forecast × 100
confidence_score = clamp(85 − |variance%| × 0.3, 50, 95)
risk factors: variance risk, category-concentration risk, trend risk → weighted overall risk
alert_status: risk ≥ 70 Critical | ≥ 40 Warning | else Normal
optimisation: actual > forecast × 1.10 → high-priority suggestion
actual < forecast × 0.90 → underutilisation note
Worked example: January, "Acme Retail"
Inputs: fixed ₹ 2 50 000 · variable ₹ 1 80 000 · inventory-related ₹ 60 000 · operational ₹ 1 20 000 · admin ₹ 40 000 · carrying ₹ 30 000 · last-month actual ₹ 7 00 000.
total_predicted = 6 80 000
variance% = (7 00 000 − 6 80 000)/6 80 000 × 100 = 2.94 %
confidence = 85 − 2.94 × 0.3 ≈ 84 %
overall_risk = low (~1.2)
alert_status = Normal
Reading: "The forecast holds. Actuals came in within 3 % of forecast, so the expense profile is healthy."