Forecast Management System
Overview
The Forecast Management System provides comprehensive statistical demand forecasting capabilities for inventory planning, production scheduling, and materials requirements planning (MRP). This system implements 12 proven statistical forecasting methods to help predict future demand with accuracy.
The system enables you to:
- Generate item-level (detail) forecasts using 12 different statistical methods
- Process entire stock categories with a single operation (category forecasting)
- Create aggregated summary forecasts by category, customer type, area, or sales person
- Automatically determine the best forecasting method for each item or category
- Track forecast accuracy with multiple metrics (MAD, POA, RMSE, MSE)
- Make manual revisions to override calculated forecasts
- Process forecasts in batch for entire categories
- Integrate forecasts with MRP and purchasing systems
Quick Start Guide
Step 1: Extract Sales History
Before generating forecasts, you must extract historical sales data into the forecast system's cache:
- Navigate to Forecasting → Extract Sales Actuals
- Set the From Date to 24 months ago (recommended minimum)
- Set the To Date to today
- Click "Extract Sales Actuals"
- Wait for the extraction to complete
This creates an optimized cache of sales history aggregated by month, which enables fast forecast calculations.
Step 2: Generate Your First Forecast
Option A: Single Item Forecast
- Navigate to Forecasting → Generate Forecast
- Select "Single Item" radio button (default)
- Enter a Stock Item Code (or use the Select button)
- Select a Location (optional)
- Click "Find Best Fit Method" to automatically select the optimal forecasting method
- Review the recommended method and parameters
- Click "Generate Forecast"
- View the generated forecast data with period-by-period quantities
Option B: Category Forecast (Recommended for Multiple Items)
- Navigate to Forecasting → Generate Forecast
- Select "Entire Category" radio button
- Choose a Stock Category from the dropdown
- Click "Find Best Fit Method" to analyze all items and get a recommendation
- Review the method recommendation and results
- Select the recommended method and click "Generate Forecast"
- View the summary (e.g., "47 successful, 3 failed")
Time Savings: Forecasting a category of 50 items takes 2-3 minutes vs 30-60 minutes for individual items (95% time reduction).
Step 3: Review the Forecast
- Navigate to Forecasting → Forecast Review
- Search for the item(s) you just forecasted
- Review the forecast quantities
- Make manual revisions if needed
- Save changes
Congratulations! You've created your first forecast. For ongoing use, consider processing entire categories at once using the category forecasting feature - it's much faster than processing items individually.
The 12 Forecasting Methods
The system provides 12 statistical forecasting methods, each suited for different demand patterns:
Method 1: Percent Over Last Year
Formula: Forecast = Last Year × (1 + Percentage/100)
Use When: You expect steady, predictable growth or decline
Parameters: Percentage increase (e.g., 5% = 5.0)
Example: If last year's sales were 1,000 units and you expect 10% growth, the forecast will be 1,100 units.
Minimum History: 12 months
Method 2: Calculated Percent Over Last Year
Formula: System automatically calculates the growth percentage from historical trends
Use When: You want the system to determine the growth rate based on past performance
Parameters: None (automatically calculated)
Example: If sales grew from 900 to 1,000 units last year (11.1%), the system will apply 11.1% growth to this year.
Minimum History: 24 months
Method 3: Last Year to This Year
Formula: This Year Forecast = Last Year Actual
Use When: Demand is stable with no growth or seasonal patterns
Parameters: None
Example: If January last year had 100 units, January this year is forecasted at 100 units.
Minimum History: 12 months
Method 4: Moving Average
Formula: Average of the last N periods
Use When: Recent demand is the best predictor of future demand
Parameters: Number of periods to average (typically 3-6)
Example: With 4-period average and recent months of 90, 100, 110, 120, forecast = (90+100+110+120)/4 = 105 units.
Minimum History: 4 months
Method 5: Linear Approximation
Formula: y = mx + b using two historical points
Use When: Clear linear trend exists in demand
Parameters: Uses first and last periods of history
Example: If sales are consistently increasing by 10 units per month, the forecast extends this trend forward.
Minimum History: 6 months
Method 6: Least Squares Regression
Formula: Statistical linear regression (y = mx + b) using all historical data
Use When: You want the most statistically accurate linear trend
Parameters: None (calculated from all history)
Example: Finds the best-fit line through all historical points to project future demand.
Minimum History: 12 months
Method 7: Second Degree Approximation
Formula: Polynomial regression y = a + bx + cx²
Use When: Demand has a curved (accelerating or decelerating) trend
Parameters: None (calculated from history)
Example: Product in rapid growth phase that's starting to level off (S-curve pattern).
Minimum History: 12 months
Method 8: Flexible Method
Formula: Custom weighted formula combining different periods
Use When: You want to apply custom business logic or weighting
Parameters: Custom weights per period
Example: Weight most recent month at 50%, prior month at 30%, and earlier months at 20%.
Minimum History: 12 months
Method 9: Weighted Moving Average
Formula: Moving average with higher weight on recent periods
Use When: Recent demand is more important than older data
Parameters: Number of periods and weighting scheme
Example: 4-period average weighted 40%, 30%, 20%, 10% (most recent to oldest).
Minimum History: 4 months
Method 10: Linear Smoothing (Simple Exponential Smoothing)
Formula: Ft+1 = α × At + (1-α) × Ft
Use When: Demand is relatively stable without strong trends
Parameters: Alpha (α) smoothing constant (0.1 to 0.9)
Example: With α=0.3, the forecast is 30% of last period's actual plus 70% of last period's forecast.
Minimum History: 12 months
Recommended α values:
- 0.1-0.3: Stable, smooth demand
- 0.4-0.6: Moderate variability
- 0.7-0.9: High variability, react quickly to changes
Method 11: Exponential Smoothing (Holt's Method)
Formula: Double exponential smoothing with level and trend components
Use When: Demand has a clear upward or downward trend
Parameters: Alpha (α) for level, Beta (β) for trend
Example: Sales are growing by 50 units per month. This method captures both the current level and the growth rate.
Minimum History: 12 months
Method 12: Exponential Smoothing with Trend and Seasonality (Holt-Winters)
Formula: Triple exponential smoothing with level, trend, and seasonal components
Use When: Demand has both trend and seasonal patterns (e.g., higher sales in summer)
Parameters: Alpha (α), Beta (β), Gamma (γ), Season Length (e.g., 12 for monthly data)
Example: A product that sells more in December every year, with overall growth trend.
Minimum History: 24 months (2 full seasonal cycles recommended)
Forecast Management Dashboard

The Forecast Management Dashboard is the central hub for all forecasting functions. Access it via Forecasting → Dashboard (ForecastDashboard.php).
The dashboard displays:
- System Statistics: Number of active forecasts, summary forecasts, and sales history range
- Setup & Configuration: Links to install, extract actuals, and configure parameters
- Forecast Generation: Links to generate single or batch forecasts
- Review & Analysis: Links to review, query, and analyze forecast accuracy
Generating Forecasts
The Forecast Generation screen provides three ways to generate forecasts: single-item, entire category, or batch processing. The single-item and category modes are accessible from a unified interface.
Forecast Generation Screen
Navigate to Forecasting → Generate Forecast (ForecastGeneration.php).

Choosing Forecast Scope
At the top of the screen, select your forecast scope:
- Single Item: Generate a forecast for one specific stock item
- Entire Category: Generate forecasts for all active items in a stock category
The form fields change automatically based on your selection.
Single Item Forecast Generation
When to use: For detailed analysis of individual items, testing new methods, or items requiring special attention.
- Select "Single Item" radio button (default)
- Stock Item: Enter the stock code or click "Select" to choose from a list
- Location: Select a specific location or leave blank for all locations
- Forecast Method: Choose from the dropdown (1-12) or click "Find Best Fit Method"
- Number of Periods: How many future periods to forecast (typically 6-12)
- Method Parameters: These fields change based on the selected method:
- Methods 1-2: Percentage increase
- Methods 4, 9: Number of periods to average
- Methods 10-12: Smoothing constants (α, β, γ)
- Periods of History: How many past periods to analyze (12-24 recommended)
- Click "Generate Forecast"
Result: A detailed table showing forecast quantities period-by-period with calculated metrics.
Using "Find Best Fit Method" for Single Items
The Best Fit Analysis feature tests all 12 methods against your historical data and recommends the method with the highest accuracy (POA). This is the recommended approach for new items where you're unsure which method to use.
- Enter the stock item and location
- Click "Find Best Fit Method"
- The system will:
- Test all 12 methods against historical actuals
- Calculate MAD and POA for each method
- Automatically select the method with highest POA
- Pre-fill the optimal parameters
- Review the recommendation and click "Generate Forecast"
Category Forecast Generation (New!)
When to use: For processing multiple related items at once, monthly forecast updates, initial system setup, or ensuring consistency across a product line.
Benefits:
- Time Savings: Process 50 items in 2-3 minutes vs 30-60 minutes individually (95%+ time reduction)
- Consistency: Apply the same method and parameters to all items in a category
- Scalability: Ideal for initial setup or monthly regeneration
- Simplicity: Single operation instead of multiple individual forecasts
Generating Category Forecasts
- Select "Entire Category" radio button
- Stock Category: Choose a category from the dropdown (e.g., "Electronics")
- Location: Select a specific location or leave blank for all locations
- Forecast Method: Choose from the dropdown (1-12) or use Best Fit
- Number of Periods: How many future periods to forecast (typically 6-12)
- Method Parameters: Set parameters appropriate for the method
- Periods of History: How far back to look (12-24 recommended)
- Click "Generate Forecast"
Processing: The system will:
- Query all active items in the selected category
- Filter for bought/manufactured items only (mbflag = 'B' or 'M')
- Exclude discontinued items
- Generate forecasts for each item sequentially
- Track success and failure counts
Result: A summary message showing how many items were successfully forecasted and how many failed (e.g., "Category forecast complete: 47 successful, 3 failed"). Navigate to Forecast Inquiry to view detailed results for all items.
Using "Find Best Fit Method" for Categories
This powerful feature analyzes the best forecasting method for each item in the category and recommends the most commonly optimal method.
- Select "Entire Category" radio button
- Choose a Stock Category from the dropdown
- Click "Find Best Fit Method"
- The system will:
- Test all 12 methods for each item in the category
- Calculate POA (accuracy) for each method per item
- Identify the best method for each individual item
- Count method frequency across the category
- Recommend the most common best-fit method
- Review the detailed results table showing:
- Stock ID and description
- Best method for each item
- POA accuracy percentage
- Most common recommended method for the category
- Use the recommended method to generate forecasts for the entire category
Performance Note: Category best-fit analysis is limited to 50 items for web performance. For larger categories, use Batch Generation (see below).
Category Forecasting Examples
Example 1: Monthly Update
Update all forecasts for "Electronics" category (75 items):
- Traditional approach: 75 operations, 30-60 minutes
- Category approach: 1 operation, 2-3 minutes
- Time savings: 95%
Example 2: Initial System Setup
Company has 500 items across 10 categories:
- Traditional approach: 500 operations, 4-8 hours
- Category approach: 10 operations, 15-30 minutes
- Time savings: 98%
Example 3: Method Selection
New "Office Supplies" category (40 items), unsure which method to use:
- Run category best-fit analysis
- Review results: "Method 6 is best for 28 items, Method 4 for 8 items, Method 10 for 4 items"
- Most common recommendation: Method 6
- Generate category forecast using Method 6
- Result: Data-driven decision with 70% of items using their optimal method
Batch Forecast Generation (Alternative for Large Categories)
Navigate to Forecasting → Batch Generation (ForecastBatchGeneration.php).
For very large categories (100+ items) or command-line processing, use the dedicated batch generation screen:
- Select a Stock Category
- Select a Location (or all locations)
- Choose a Forecast Method
- Set Number of Periods to forecast
- Click "Generate Batch Forecasts"
- The system processes all items in the category and displays progress
Note: If forecast constants are configured for specific items, the system will use those item-specific parameters instead of the default method settings.
Which Generation Method to Use?
| Situation | Recommended Method | Reason |
|---|---|---|
| Single item analysis | Single Item mode | Detailed results and full control |
| Testing new methods | Single Item mode | See period-by-period details |
| Small category (1-50 items) | Category mode | Fast, convenient, single screen |
| Medium category (50-100 items) | Category mode or Batch | Either works well |
| Large category (100+ items) | Batch Generation | Better performance, progress tracking |
| Unknown best method | Category Best Fit | Data-driven recommendation |
| Initial system setup | Category mode (per category) | Process categories one at a time |
| Monthly regeneration | Category mode | Quick updates per category |
| Automated scheduling | Batch Generation (cron) | Command-line compatible |
Reviewing and Revising Forecasts
Forecast Review Screen
Navigate to Forecasting → Forecast Review (ForecastReview.php).

This screen allows you to:
- Search for forecasts by stock item, location, or date range
- View forecast quantities period-by-period
- Compare forecasts against actual sales (when available)
- Make manual revisions to override calculated forecasts
- View variance percentages
- Activate or deactivate forecasts
Making Manual Revisions
- Search for and select a forecast
- In the detail grid, enter revised quantities in the "Revised Qty" column
- Click "Save Revisions"
- The system will use revised quantities instead of calculated forecasts in all reports and integrations
Understanding Variance Colors
The variance column is color-coded to help identify forecast accuracy:
- Green: Variance within ±10% (excellent)
- Yellow: Variance between ±10% and ±25% (acceptable)
- Red: Variance greater than ±25% (needs attention)
Summary Forecasts
Summary forecasts aggregate individual item forecasts into higher-level groupings for executive reporting and planning.
Creating a Summary Forecast
Navigate to Forecasting → Summary Forecasts (ForecastSummary.php).
- Click "Add New Summary"
- Enter a Summary Code (e.g., "ELEC-Q1")
- Enter a Description (e.g., "Electronics Q1 Forecast")
- Select aggregation criteria:
- Category: Aggregate all items in a category
- Customer Type: Aggregate by customer segment
- Area: Aggregate by geographical area
- Sales Person: Aggregate by salesperson
- Set the Start Date and Number of Periods
- Click "Generate Summary"
The system will automatically sum all detail forecasts matching your criteria into period-by-period summary totals.
Reviewing Summary Forecasts
Click the "Review" link next to any summary forecast to view and edit the period details (ForecastSummaryReview.php).
The summary review screen shows:
- Summary header information (code, description, criteria)
- Period-by-period forecast quantities and values
- Actual quantities and values (when available)
- Ability to make manual revisions to summary forecasts
- Variance analysis
- Total and average calculations
Forecast Accuracy Tracking
Accuracy Report
Navigate to Forecasting → Accuracy Report (ForecastAccuracy.php).
This report helps you monitor how well your forecasts are performing by comparing them against actual sales.
Understanding Accuracy Metrics
MAD (Mean Absolute Deviation)
- Formula: Average of |Actual - Forecast|
- Measures the average size of forecast errors
- Lower is better
- Same units as your product (e.g., if forecasting units, MAD is in units)
POA (Percent of Accuracy)
- Formula: (1 - MAD / Average Actual) × 100%
- Percentage accuracy from 0-100%
- Higher is better
- Industry guidelines:
- 80-100%: Excellent forecast
- 60-80%: Good forecast
- 40-60%: Fair forecast (consider adjusting method)
- Below 40%: Poor forecast (needs review)
RMSE (Root Mean Squared Error)
- Similar to MAD but penalizes large errors more heavily
- Lower is better
- Useful for identifying forecasts with occasional large misses
What to Do When Accuracy is Low
- Try a different forecasting method (use Method Comparison tool)
- Adjust smoothing constants in Forecast Constants
- Check for outliers in historical sales data
- Consider if demand pattern has changed (seasonal, promotional events)
- Make manual revisions for critical periods
- Ensure sufficient historical data exists (minimum 12-24 months)
Method Comparison Tool
Navigate to Forecasting → Method Comparison (ForecastComparison.php).
This unique tool allows you to visually compare multiple forecasting methods side-by-side for the same item:
- Enter a stock item code
- Select multiple methods to compare (use checkboxes)
- Click "Compare Methods"
- View the results in a comparative table showing:
- Each period's forecast by each method
- Highest and lowest forecasts highlighted
- Total forecast per method
- Average per period
- Standard deviation across methods
Use this tool to understand the range of possible outcomes and select the most appropriate method for your business needs.
Configuring Forecast Constants
Navigate to Forecasting → Forecast Constants (ForecastConstants.php).
Forecast constants allow you to configure item-specific parameters that override default settings:
Smoothing Constants
- Alpha (α): Controls responsiveness to recent changes (0.1-0.9)
- Low (0.1-0.3): Smooth, stable forecast - use for stable demand
- High (0.7-0.9): Responsive forecast - use for volatile demand
- Beta (β): Controls responsiveness to trend changes (Methods 11-12)
- Gamma (γ): Controls responsiveness to seasonal changes (Method 12 only)
Other Parameters
- Periods for Average: Number of periods to use in moving average calculations (Methods 4, 9)
- Periods of History: How far back to look when calculating forecasts
- Safety Stock: Fixed safety stock quantity to add to forecast
- Safety Stock %: Additional safety stock as percentage of forecast
- Outlier Filter: Enable/disable automatic outlier detection
- Outlier Deviation: Number of standard deviations to consider as outlier (typically 2-3)
Querying Forecasts
Navigate to Forecasting → Forecast Inquiry (ForecastInquiry.php).
Use this screen to query and view forecasts across multiple items and time periods:
- Filter by stock item, category, or location
- Specify date range for forecast periods
- View multiple items in a single report
- See forecast quantities, actual quantities, and variances
- Export data for further analysis (if export feature added)
Extracting Sales History
Navigate to Forecasting → Extract Sales Actuals (ForecastExtractActuals.php).
Why Extract Sales History?
The forecast system uses a cached, aggregated view of sales history for optimal performance. The extraction process:
- Reads data from the salesanalysis table (actual sales transactions)
- Aggregates by month and stores in forecastsaleshistory table
- Enables fast forecast calculations without complex joins
- Groups data by item, location, customer type, area, and salesperson for summary forecasts
How Often to Extract
- Initial setup: Extract 24-36 months of history
- Ongoing: Extract monthly (first week of each month)
- Major events: After large sales or data corrections
Extraction Process
- Select From Date (e.g., 24 months ago)
- Select To Date (e.g., today)
- Click "Extract Sales Actuals"
- Wait for completion
- Review statistics displayed (records processed, date range)
Performance Tip: Schedule extraction during off-hours using a cron job for automated processing.
Integration with Other Systems
MRP Integration
Forecasts can be used as independent demand in the Material Requirements Planning (MRP) system:
// Example: Create MRP demands from active forecasts
$sql = "SELECT fh.stockid, fd.perioddate,
COALESCE(fd.revisedqty, fd.forecastqty) as quantity
FROM forecastheader fh
INNER JOIN forecastdetails fd ON fh.forecastid = fd.forecastid
WHERE fh.active = 1
AND fd.perioddate >= CURDATE()
AND fd.perioddate <= DATE_ADD(CURDATE(), INTERVAL 6 MONTH)";
$result = DB_query($sql);
while ($row = DB_fetch_array($result)) {
// Create MRP demand
$insertSQL = "INSERT INTO mrpdemands
(stockid, mrpdemandtype, quantity, duedate)
VALUES (
'" . $row['stockid'] . "',
'FCT',
" . $row['quantity'] . ",
'" . $row['perioddate'] . "'
)";
DB_query($insertSQL);
}
Reorder Level Calculation
Use forecasts to automatically calculate reorder points:
// Reorder Level = Forecast + Safety Stock $forecast = getNextPeriodForecast($stockid, $location); $safetyStock = getSafetyStockFromConstants($stockid, $location); $reorderLevel = $forecast + $safetyStock;
Purchase Planning
Calculate net requirements for purchasing:
// Net Requirement = Forecast - On Hand - On Order $forecast = getForecastTotal($stockid, $startdate, $enddate); $onHand = getCurrentStock($stockid, $location); $onOrder = getPurchaseOrderQty($stockid); $netRequirement = max(0, $forecast - $onHand - $onOrder);
Best Practices
Getting Started
- Start with a pilot: Choose one product category to test the system
- Extract sufficient history: Minimum 12 months, 24-36 months recommended
- Use category forecasting: Process entire categories instead of individual items (saves 95%+ time)
- Use Best Fit: Let the system recommend methods initially (works for both items and categories)
- Review regularly: Check accuracy monthly and adjust as needed
Ongoing Operations
- Monthly: Extract new sales actuals
- Weekly/Monthly: Regenerate forecasts using category mode for efficiency
- Monthly: Review accuracy reports
- Quarterly: Adjust methods and parameters based on accuracy trends
- As needed: Make manual revisions for promotional periods or known events
Category vs. Single Item Forecasting
- Use Category Mode: For initial setup, monthly updates, or when processing 5+ items from same category
- Use Single Item Mode: For detailed analysis, testing new methods, or critical items requiring special attention
- Category Best Fit: Run once per category to find the most common optimal method, then use for all items
- Time Savings: Category mode reduces forecast generation time by 90-98% compared to individual processing
Method Selection Guidelines
| Demand Pattern | Recommended Method | Alternative Method |
|---|---|---|
| Stable, no trend | Method 3 (Last Year to This Year) | Method 10 (Linear Smoothing) |
| Growing steadily | Method 6 (Least Squares Regression) | Method 11 (Exponential Smoothing) |
| Declining | Method 6 (Least Squares Regression) | Method 11 (Exponential Smoothing) |
| Seasonal pattern | Method 12 (Holt-Winters) | Method 1 with seasonal % |
| Erratic/volatile | Method 9 (Weighted Moving Average) | Method 4 (Moving Average) |
| New product | Method 1 (Percent Over LY) | Similar item + adjustment |
| Unknown pattern | Use "Find Best Fit" | Method 4 (safe default) |
Critical Items
For high-value or strategic items:
- Configure specific forecast constants
- Use multiple methods and compare results
- Apply manual review and adjustments
- Monitor accuracy closely
- Document revision rationale in notes field
Troubleshooting
Problem: No forecast generated
Solutions:
- Ensure sales history has been extracted (run ForecastExtractActuals.php)
- Verify the stock item has sales data in the selected date range
- Check that the item exists in stockmaster table
- Ensure sufficient historical periods exist for the selected method
Problem: Forecast accuracy is low (POA < 60%)
Solutions:
- Try different forecasting methods using the Comparison tool
- Adjust smoothing constants (increase α for volatile, decrease for stable)
- Check for data quality issues (outliers, missing data)
- Review for external factors (promotions, market changes)
- Consider increasing periods of history used
- Apply manual revisions for known upcoming events
Problem: Batch generation is slow
Solutions:
- Extract sales history during off-hours
- Process smaller categories at a time
- Ensure database indexes are created (check installation)
- Consider running batch jobs via command line during low-usage periods
Problem: Forecast is all zeros
Solutions:
- Check that the item has sales history in forecastsaleshistory table
- Verify the location filter isn't excluding all data
- Ensure the date range overlaps with available history
- Check that the stock item is not discontinued
Advanced Topics
Seasonal Forecasting (Method 12)
For products with seasonal patterns:
- Requires at least 24 months of history (2 full seasonal cycles)
- Set Season Length parameter (12 for monthly data with annual seasonality)
- Start with α=0.3, β=0.3, γ=0.3 and adjust based on results
- Review seasonal indices to ensure they make sense
Promotional Events
For forecasting during promotional periods:
- Use historical promotion data if available
- Generate baseline forecast first
- Apply manual revision with promotional uplift percentage
- Document the promotion in the notes field
- Track actual vs forecast to improve future promotional forecasts
New Product Introduction
For items without sales history:
- Find similar products and copy their forecast patterns
- Use Method 1 with estimated percentage based on similar items
- Apply conservative estimates initially
- Review and adjust weekly as actual sales data becomes available
- Switch to statistical methods once 6+ months of history exists
Automating Forecast Generation
Set up automated forecast generation using cron jobs:
# Extract sales history monthly (1st of month at 2 AM) 0 2 1 * * php /path/to/webERP/ForecastExtractActuals.php extract # Generate forecasts weekly (Sunday at 3 AM) 0 3 * * 0 php /path/to/webERP/batch_forecast.php # Email accuracy report monthly (5th of month at 8 AM) 0 8 5 * * php /path/to/webERP/email_forecast_accuracy.php
Database Table Reference
forecastheader
Master table containing one record per forecast. Links to stockmaster and locations.
forecastdetails
Period-by-period forecast data. Multiple records per forecast (one per period). Stores forecast quantity, actual quantity, revised quantity, and metrics.
forecastsummary
Summary forecast definitions. Specifies aggregation criteria (category, customer type, area, salesperson).
forecastsummarydetails
Period-by-period summary data. Stores both quantity and value forecasts.
forecastconstants
Item-specific parameters. One record per stock item/location combination. Stores smoothing constants and safety stock settings.
forecastsaleshistory
Cached sales history for fast calculations. Pre-aggregated by month with dimensions for summary forecasting.
forecastmethods
Lookup table of the 12 forecasting methods with descriptions and requirements.
forecastmetrics
Calculated accuracy metrics (MAD, POA, RMSE, MSE) stored per forecast and period.
forecastprices
Historical and projected pricing for value-based forecasting.
forecastinclusionrules
Rules defining which transaction types to include in forecasts.
forecastsimulation
What-if scenarios for testing forecast adjustments before committing.
Frequently Asked Questions
Q: How much historical data do I need?
A: Minimum 6 months for basic methods (4, 9), 12 months recommended for most methods, and 24 months for seasonal methods (12). More history generally produces better forecasts.
Q: Can I forecast new products with no sales history?
A: Yes, use Method 1 (Percent Over Last Year) with estimates based on similar products, or manually enter forecast quantities.
Q: What's the difference between detail and summary forecasts?
A: Detail forecasts are item-specific. Summary forecasts aggregate multiple items for higher-level planning (e.g., total sales for electronics category).
Q: Should I forecast by location or for all locations combined?
A: If demand patterns differ by location, forecast separately. If locations have similar patterns, combined forecasting may be simpler.
Q: When should I use manual revisions?
A: Use manual revisions when you have knowledge of future events that aren't reflected in historical data (promotions, market changes, new customers, etc.).
Q: Can I use multiple methods for the same item?
A: Yes, you can generate forecasts with different methods and compare them. However, only one forecast per item/location can be marked as "active" for MRP integration.
Q: How do I know which method to use?
A: Use the "Find Best Fit Method" feature in Forecast Generation, or use the Method Comparison tool to compare multiple methods visually.
Q: What if my forecast accuracy is low?
A: Try different methods, adjust smoothing constants, check for data quality issues, ensure sufficient historical data, and consider manual adjustments for known future events.
Glossary of Terms
- Detail Forecast
- Item-level forecast for a specific product and location
- Summary Forecast
- Aggregated forecast combining multiple items by category, customer type, area, or salesperson
- MAD (Mean Absolute Deviation)
- Average magnitude of forecast errors, regardless of direction
- POA (Percent of Accuracy)
- Percentage accuracy measure (0-100%), with higher being better
- Alpha (α)
- Smoothing constant controlling responsiveness to recent changes (0.1-0.9)
- Beta (β)
- Smoothing constant for trend component in exponential smoothing
- Gamma (γ)
- Smoothing constant for seasonal component in Holt-Winters method
- Seasonality
- Repeating patterns in demand over time (e.g., higher sales in December)
- Outlier
- Data point significantly different from other observations, potentially skewing forecasts
- Best Fit
- Automated analysis to determine which forecasting method performs most accurately for an item
Screen Reference
| Screen | File | Purpose |
|---|---|---|
| Forecast Dashboard | ForecastDashboard.php | Central hub with navigation and statistics |
| Generate Forecast | ForecastGeneration.php | Create forecasts for individual items or entire categories |
| Forecast Review | ForecastReview.php | Review and revise detail forecasts |
| Method Comparison | ForecastComparison.php | Compare multiple methods side-by-side |
| Summary Forecasts | ForecastSummary.php | Create and manage summary forecasts |
| Summary Review | ForecastSummaryReview.php | Review and edit summary details |
| Extract Actuals | ForecastExtractActuals.php | Import sales history into cache |
| Accuracy Report | ForecastAccuracy.php | Monitor forecast accuracy metrics |
| Forecast Inquiry | ForecastInquiry.php | Query and view forecasts |
| Forecast Constants | ForecastConstants.php | Configure item-specific parameters |
| Batch Generation | ForecastBatchGeneration.php | Generate forecasts for categories |
Integrating Forecasts with MRP
The Forecast Management System directly integrates with webERP's Material Requirements Planning (MRP) system, allowing forecasted demand to drive production planning and purchasing decisions. This creates a complete demand-driven planning cycle from historical sales through statistical forecasting to materials requirements.
Complete Workflow: Forecast to MRP
The integration follows a five-step workflow:
Step 1: Extract Sales History → Forecast Sales History Table
File: ForecastExtractActuals.php
Purpose: Pull historical sales data from sales orders into the forecast system's optimized cache.
Process:
- Extracts from
salesordersandsalesorderdetailstables - Aggregates by stock item, location, customer type, area, salesperson, and period
- Creates records in
forecastsaleshistorytable - No dependency on salesanalysis or stockmoves tables
How to Use:
- Navigate to Forecasting → Extract Sales Actuals
- Select date range (e.g., last 12-24 months)
- Click "Extract"
- Wait for completion
Step 2: Generate Forecasts → Forecast Header and Details Tables
File: ForecastGeneration.php
Purpose: Create statistical forecasts based on historical sales patterns.
Process:
- Analyzes historical sales patterns from
forecastsaleshistory - Applies selected statistical algorithm (12 methods available)
- Creates forecast header in
forecastheadertable - Creates period-by-period forecasts in
forecastdetailstable
How to Use:
- Navigate to Forecasting → Generate Forecast
- Select stock item or entire category
- Choose location (optional)
- Select forecast method or use "Find Best Fit"
- Set number of periods to forecast (e.g., 3 months)
- Click "Generate Forecast"
Step 3: Review and Adjust Forecasts → Update Revised Quantities
File: ForecastReview.php
Purpose: Review generated forecasts and make manual adjustments based on business knowledge.
Process:
- Reviews
forecastdetailsrecords - Allows updating
revisedqtyfield - Revised quantities override calculated forecasts
- Original forecasts are preserved for comparison
How to Use:
- Navigate to Forecasting → Forecast Review
- Search for forecasts to review
- View period-by-period forecast quantities
- Enter adjusted quantities in "Revised Qty" column (e.g., for known promotions)
- Add notes to document adjustments
- Click "Save Changes"
Step 4: Convert Forecasts to MRP Demands → MRP Demands Table (NEW)
File: ForecastToMRP.php
Purpose: Convert active forecasts into MRP demand records that drive material requirements planning.
Process:
- Reads from
forecastdetailsfor active forecasts - Uses
revisedqtyif available, otherwiseforecastqty - Creates records in
mrpdemandstable - Links to specified MRP demand type (e.g., "FORECAST")
How to Use:
- Navigate to MRP → Forecast to MRP Demands
- Set From Date and To Date (e.g., next 3 months)
- Select MRP Demand Type (create "FORECAST" type if needed)
- Select Location (or "All Locations")
- Select Stock Categories to include
- Check "Replace Existing" to clear old forecast demands first
- Click "Generate MRP Demands"
- Review confirmation: "X MRP Demands created"
Example: If you have a forecast showing 45 units in April, 48 in May, and 75 in June (revised), the system creates three MRP demand records with these quantities and dates.
Step 5: Run MRP → Planned Purchase and Work Orders
File: MRP.php
Purpose: Calculate material requirements based on all demands including forecasts.
Process:
- Reads from
mrpdemandstable (includes forecast demands) - Analyzes current inventory levels
- Checks Bills of Materials (BOMs)
- Considers lead times and safety stock
- Generates planned purchase orders
- Generates planned work orders
- Identifies shortages and reschedule recommendations
How to Use:
- Navigate to MRP → Run MRP
- Select location
- Select manufacturing calendar
- Set planning horizon
- Click "Run MRP"
- MRP calculates requirements based on all demands (sales orders + forecasts)
- Review planned orders under MRP → Planned Purchase Orders
- Review planned work orders under MRP → Planned Work Orders
Complete Example Scenario
Scenario: Forecast and plan for electronic components for the next 3 months
| Step | Action | Result |
|---|---|---|
| 1. Extract History | ForecastExtractActuals.php From: 2025-03-01 To: 2026-03-01 |
5,974 historical sales records loaded into forecastsaleshistory |
| 2. Generate Forecast | ForecastGeneration.php Item: ELEC-0001 Location: MAIN Method: Exponential Smoothing Periods: 3 |
Forecast created: • April 2026: 45 units • May 2026: 48 units • June 2026: 50 units |
| 3. Review & Adjust | ForecastReview.php June revised to 75 units (Known promotion) |
Revised forecast: • April: 45 units • May: 48 units • June: 75 units (revised) |
| 4. Convert to MRP | ForecastToMRP.php From: 2026-04-01 To: 2026-06-30 Type: FORECAST |
3 MRP demand records created: • 2026-04-30: 45 units • 2026-05-31: 48 units • 2026-06-30: 75 units |
| 5. Run MRP | MRP.php Planning horizon: 3 months |
MRP calculates requirements: • Total demand: 168 units • Current stock: 20 units • Net requirement: 148 units • Planned purchase orders generated |
Key Integration Features
Priority System: Revised Over Calculated
The system uses a priority hierarchy for forecast quantities:
COALESCE(forecastdetails.revisedqty, forecastdetails.forecastqty)
This means:
- If you've made manual adjustments, the
revisedqtyis used - If no revision exists, the statistical
forecastqtyis used - Both values are preserved for audit and comparison
Multiple Demand Sources
The MRP system combines demands from multiple sources:
| Demand Source | MRP Demand Type | Description |
|---|---|---|
| Sales Orders | SO | Actual customer orders (firm demands) |
| Forecasts | FC | Statistical predictions (planned demands) |
| Work Orders | WO | Production requirements for assemblies |
| Manual | MAN | Manually entered demands |
Incremental vs. Replace Modes
Replace Mode (Recommended for weekly/monthly updates):
- Deletes existing forecast demands in the date range
- Creates new demands from current forecasts
- Ensures MRP always uses latest forecast data
Incremental Mode (For adding new forecasts):
- Only adds demands that don't already exist
- Preserves existing demands
- Use when adding forecasts for new items or periods
Best Practices for Forecast-to-MRP Integration
1. Regular Update Schedule
| Activity | Recommended Frequency | Timing |
|---|---|---|
| Extract Actuals | Monthly | After closing each period |
| Regenerate Forecasts | Monthly | Same day as actuals extraction |
| Review & Adjust | Weekly | Before converting to MRP |
| Convert to MRP | Weekly | Before running MRP |
| Run MRP | Weekly or Daily | After converting forecasts |
2. Review Process
Always review forecasts before converting to MRP demands:
- Check for anomalies: Look for unusually high or low forecasts
- Adjust for known events: Promotions, product launches, seasonality
- Document changes: Use the notes field to explain adjustments
- Compare with actuals: Review accuracy of previous forecasts
3. Accuracy Monitoring
Track forecast performance over time:
- MAD (Mean Absolute Deviation): Average forecast error
- POA (Percent of Accuracy): Percentage accuracy metric
- Bias detection: Identify consistent over/under forecasting
- Method comparison: Test different algorithms for each item
4. Planning Horizon
Set appropriate forecast and MRP horizons:
- Forecast horizon: 3-6 months typical (longer for seasonal items)
- MRP planning horizon: Forecast horizon + longest lead time
- Example: 3-month forecast + 2-month lead time = 5-month MRP horizon
Configuration and Setup
Create MRP Demand Type for Forecasts
Before first use, create a demand type for forecasts:
- Navigate to MRP → MRP Demand Types
- Click "Add New"
- Enter code:
FC - Enter description:
Forecast Demand - Click "Save"
Or using SQL:
INSERT INTO mrpdemandtypes (mrpdemandtype, description)
VALUES ('FC', 'Forecast Demand');
Recommended Demand Type Setup
| Code | Description | Priority |
|---|---|---|
| SO | Sales Order | 1 (Highest - firm demand) |
| FC | Forecast | 2 (Planned demand) |
| WO | Work Order | 3 (Production requirement) |
| MAN | Manual | 4 (As needed) |
Troubleshooting
No MRP Demands Created
Possible causes and solutions:
- Forecasts not marked active: Check
forecastheader.active = 1 - Zero quantities: Ensure forecast quantities are greater than 0
- Date range mismatch: Verify forecast periods fall within selected date range
- MRP demand type missing: Create the FORECAST demand type first
Duplicate Demands
Solution:
- Use "Replace Existing" checkbox when converting to MRP
- Or manually delete old demands:
DELETE FROM mrpdemands WHERE mrpdemandtype = 'FC' AND duedate < '2026-04-01'
Forecasts Don't Update in MRP
Solution:
- Remember to convert forecasts to MRP demands after making changes
- The MRP system reads from
mrpdemands, not directly fromforecastdetails - Use "Replace Existing" mode to ensure latest forecasts are used
Database Table Flow
salesorders + salesorderdetails
↓
forecastsaleshistory (via ForecastExtractActuals.php)
↓
forecastheader + forecastdetails (via ForecastGeneration.php)
↓
mrpdemands (via ForecastToMRP.php) ← NEW
↓
MRP planned orders (via MRP.php)
Integration Summary
The Forecast-to-MRP integration provides:
- ✓ Direct integration: Forecast → MRP with one click
- ✓ Manual overrides: Use revisedqty to adjust statistical forecasts
- ✓ No intermediate tables: Direct from sales orders to forecasts
- ✓ Multiple sources: Combine actual sales + forecasts in MRP
- ✓ Flexible filtering: By location, category, dates
- ✓ Audit trail: Keeps both original and revised forecasts
- ✓ Automated workflow: Minimal manual intervention required
This creates a complete closed-loop system from historical sales analysis through statistical forecasting to production planning and material requirements.
Getting Help
For additional support and resources:
- Quick Start Guide: FORECAST_QUICKSTART.md in the webERP root directory
- MRP Integration Guide: FORECAST_TO_MRP_GUIDE.md - Complete workflow from forecasts to production planning
- Technical Documentation: doc/ForecastManagement.md
- API Reference: FORECAST_API_REFERENCE.md for developers
- webERP Forum: https://github.com/timschofield/webERP/discussions
- webERP Website: https://www.weberp.org/