The Problem: Manual Inventory Management
Many mid-size retailers still manage inventory by hand on a legacy ERP system. The result is a familiar pattern: frequent stockouts on popular items and overstock on slow ones, which means lost revenue on one side and wasted warehouse space on the other.
This is a common pattern: the ERP records every sale, order and delivery, but purchasing decisions still depend on manual judgement. When a season behaves differently from last year, the business either runs out of popular items or fills the warehouse with stock that does not sell. The data needed to do better is already there; nothing is using it.
Starting Point: Data Before Models
Before training anything, the data has to be made trustworthy. This is the step most AI projects underestimate, and it decides whether the models can be believed. The essentials for demand forecasting:
- Sales history: transactions cleaned of returns, test orders and duplicate records.
- Stockout correction: days when an item was out of stock show zero sales, but demand was not zero. Flag those days so the model does not learn that the item was unpopular.
- Calendar and promotions: holidays, campaigns and price changes, aligned to the same dates as sales.
- External signals: weather and local events, joined only where they clearly relate to demand.
- Supplier data: actual lead times and delivery reliability, measured from purchase orders rather than taken from supplier promises.
An AI-First Approach
1. Demand Forecasting with LSTM
A demand forecasting model, for example an LSTM neural network trained on two to three years of sales history, can learn the effect of seasonality, promotions, weather patterns, and local events. How accurate it becomes depends on your data, so always measure it against simple baselines, as described below.
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import LSTM, Dense, Dropout
def build_demand_model(sequence_length, n_features):
model = Sequential([
LSTM(128, return_sequences=True, input_shape=(sequence_length, n_features)),
Dropout(0.2),
LSTM(64, return_sequences=False),
Dense(32, activation='relu'),
Dense(1)
])
model.compile(optimizer='adam', loss='mse', metrics=['mae'])
return modelThree practices make a forecast reliable enough to act on:
- Compare against simple baselines. Measure every model against a seasonal naive forecast ("same week last year") and a moving average. A complex model that cannot clearly beat these is not worth running.
- Validate on time, not at random. Train on earlier periods and test on later ones, ideally including a full peak season, because random splits let the model see the future and overstate accuracy.
- Measure error per product group. A good average can hide poor accuracy on the expensive, slow-moving items where mistakes cost the most.
2. Automated Reordering
The system can then draft purchase orders automatically, taking lead times, seasonality, and supplier reliability into account, so buyers review suggestions instead of building every order by hand.
Reorder logic turns a forecast into a decision: expected demand during the supplier's lead time, plus safety stock sized by how uncertain the forecast is and how reliable the supplier has been. A sensible safeguard is to route orders above a set value, or outside normal patterns, to a buyer for review, so automation handles the routine volume and people handle the exceptions.
3. Dynamic Pricing Engine
Machine learning can also support pricing by analysing competitor prices, demand patterns, and inventory levels. How often prices change, from a daily update to near real-time adjustments, should be a business decision rather than a technical default.
Pricing automation needs firm guardrails: a minimum margin and a maximum allowed change per day for every product, the option to exclude protected items entirely, a log of every price change with the reason behind it, and a simple way for the commercial team to pause automation for any category.
Integrating AI Into the ERP, Not Next to It
Forecasts that live in a separate dashboard are rarely used. Predictions, suggested orders and price recommendations belong inside the screens buyers already use every day, ideally with a short explanation of the main drivers (for example, an upcoming promotion or a seasonal peak). Users keep their familiar workflow; it simply starts with a better suggestion. A typical layered setup:
| Layer | What it does |
|---|---|
| Data pipeline | Extracts ERP data nightly, cleans it and builds model features |
| Forecasting service | Produces demand forecasts per product and location |
| Decision rules | Converts forecasts into reorder quantities and price recommendations within business limits |
| ERP integration | Writes suggestions and draft purchase orders back into the ERP |
| Monitoring | Tracks forecast error, data quality and model drift, and alerts the team |
Keeping Models Accurate: MLOps
- Scheduled retraining on the latest data, with the new model promoted only if it beats the current one on recent periods.
- Drift monitoring that alerts when forecast error rises or when incoming data looks different from training data.
- Versioned models and data, so any forecast can be traced to the exact model and data that produced it.
- Fallback forecasts from the simple baseline whenever a model fails or data is missing, so purchasing never stops.
What to Measure
- Revenue and gross margin per product category, compared with the same period before launch
- Inventory write-offs and waste
- Stockout rate and the sales lost to it
- Warehouse space utilization
Is Your ERP Ready for AI? A Quick Checklist
- At least two years of reasonably clean transaction history
- Consistent product and location codes across the system
- A record of promotions, price changes and stockouts
- An ERP that can accept data back through an API or import
- A business owner who will define the limits automation must respect
- A team willing to review exceptions during the first months
Key Takeaways
Success depends less on the ML models than on integrating AI predictions directly into the existing ERP workflows, so that users do not have to change how they work.
Clean data, honest validation against simple baselines, clear business guardrails and continuous monitoring are what turn a promising model into a system a business can trust with real purchasing and pricing decisions.
For a broader look at adding AI to business software, read our guide to integrating LLMs into enterprise applications. Considering AI for your ERP? Talk to our team.