Build an AI Stockout Alert Before Your Next Purchase Order Is Late
By Ehab Al Dissi ·

Watch the Inventory walkthrough
Read the video transcript
Your warehouse has one hundred and twenty units. You're still about to run out. Here's what the stock report missed.
Thirty units are already reserved. At forty units per day, the remaining ninety cover just over two days.
The supplier says five days. The automation flags the gap and puts a transfer or expedited shipment in front of the buyer.
If the date is missing, the workflow asks for confirmation. The buyer approves any purchase or customer promise.
Take the last item that ran out. Replay the updates in order and find the first day your team could have acted.
The warehouse has 120 units. Thirty are already promised. At 40 units a day, you have 2.25 days of available stock. If the next receipt is five days away, the buyer needs to see the gap today. A useful automation tells them what changed, which products are affected, and what decision they can make before the shortage reaches the customer.
How to build a stockout alert
Start with one warehouse and a shortlist of products whose shortages matter. Run the workflow every morning and whenever a supplier changes a committed date. Join inventory, reservations, recent demand, and open purchase orders by SKU and location. Calculate the stock projection with rules, then use AI to extract a proposed date from a supplier update or summarize the evidence for the buyer.
- Define available stock as on-hand units minus firm reservations. Exclude damaged stock and keep quantities in the same unit of measure.
- Estimate daily demand from the period your team uses to plan. Record the window and flag promotions or unusually large orders so the buyer can inspect the assumption.
- Build a dated view of inventory. Deduct expected demand, add confirmed receipts on their expected dates, and flag the first day availability falls below your safety stock. Put a buffer around uncertain supplier dates.
- Give the buyer a choice. Compare transferring stock, expediting the supplier order, or changing a customer promise. Show estimated costs, lead times, and the records behind each option.
- Let the buyer approve any purchase, transfer, or customer commitment. Keep the alert open until a changed supplier or inventory record confirms the plan.
Try the calculation on three fictional SKUs
Run python replay.py inventory --output inventory.csv. The starter uses constant daily demand and a single receipt date. Replace those assumptions with dated demand and receipts when you connect your own data.
| SKU | Available | Daily demand | Coverage | Receipt | Decision |
|---|---|---|---|---|---|
| A-42 | 90 | 40 | 2.25 days | 5 days | Buyer reviews a transfer or expedite. |
| B-19 | 140 | 20 | 7 days | 5 days | Monitor in this fixture. |
| C-08 | 20 | 10 | 2 days | Unknown | Confirm the supplier date. |
Change A-42’s receipt from five days to one. The replay should switch the recommendation to monitoring. Then set daily demand to zero. The replay will ask the buyer to review demand before making a forecast.
Run a two-week pilot
Track time from a known risk to the buyer’s first decision. Compare alerts with actual shortages, count misses and false alarms, and record how much the team paid to expedite. Review the alerts that arrived with too little time to act. That tells you whether your next improvement belongs in the trigger, the data, or the decision process.
Ask the buyer for one SKU that ran out recently. Replay the demand and supplier updates in the order they arrived. Find the earliest date the system could have warned them with the data available at the time.
Download the Python replay · Download the example CSV