Cash Flow Forecasting With Machine Learning
Last updated:
Where a cash forecast actually goes wrong
A typical SME cash forecast is a spreadsheet with receivables expected on their due dates, payables on theirs, payroll and rent in fixed rows, and a closing balance that looks fine. By week three it is wrong, and it is nearly always wrong in the same direction: cash arrives later than the invoices say it should.
The problem is rarely the arithmetic. It is the assumptions. Customers do not pay on due dates, card receipts vary by weekday and season, and a dozen small recurring costs that nobody put in the sheet add up to a noticeable monthly drag. Those are exactly the parts a model can learn.
Which parts machine learning predicts well
| Cash line | Model fit | Why |
|---|---|---|
| Receipts from existing invoices | Strong | Each customer's payment habits are learnable from history |
| Card and till receipts | Strong | Daily patterns, seasonality and calendar effects repeat |
| Recurring supplier payments | Good | Subscriptions, utilities and regular suppliers follow patterns |
| Receipts from sales not yet invoiced | Moderate | Depends on a decent sales forecast |
| Tax, dividends, capital spend, loans | Poor | Known in advance by finance, not predictable from patterns |
The best cash forecasts combine the two: a model for the patterned, high-volume lines, and a manual schedule for the lumpy, known items. Trying to make a model predict a VAT payment is pointless when the finance director already knows the date and roughly the amount.
Predicting when invoices get paid
The single biggest improvement usually comes from replacing 'due date' with 'predicted payment date' for every open invoice. A model trained on your ledger learns that one customer pays reliably eight days late, another pays on the last Friday of the month regardless of terms, and a third pays early when the invoice is small.
This is the same modelling we describe in our post on predicting late payments, used for a different purpose. There the aim is to chase the risky invoices; here it is to put realistic dates into the forecast. One model can serve both.
A worked illustration
Picture a wholesale food supplier with 12 million pounds turnover, 250 trade customers on 30-day terms, a seasonal peak before Christmas and an overdraft facility it would rather not touch. Its spreadsheet forecast assumes invoices are paid on due dates, and every November the business ends up in the overdraft for a fortnight nobody saw coming.
A model of payment timing would probably show that hospitality customers stretch payments during their own busy season, just as the supplier's stock purchases peak. Knowing that six weeks in advance turns an unpleasant surprise into a planned conversation with the bank. The figures are illustrative; the seasonal squeeze is extremely common.
Data you need
- Bank transactions for two or more years, with enough description to categorise them
- Sales ledger: invoices, due dates, paid dates, part-payments and credit notes
- Purchase ledger and payment run schedule
- Payroll dates and amounts, which are simple but must be right
- Known future items from finance: tax, loan repayments, planned capital spend
Categorising bank transactions is often the most tedious step. Accounting platforms help, and a language model can speed up the long tail of unclear descriptions, but someone in finance should review the mapping once.
Judging the forecast
- Back-test by forecasting from past dates and comparing with the real bank balance 4, 8 and 13 weeks later
- Measure error on the closing balance and on the lowest point in the period, since the low point is what threatens the overdraft
- Show a range around the line so decisions account for uncertainty
- Track which lines contribute most to error, and improve those first
A forecast that is roughly right about the lowest balance in the next quarter is worth more than one that is precise about the average. Finance teams make decisions on the low point.
When a model is the wrong answer
Very small businesses with a few large clients do not need machine learning. Their cash forecast depends on three customers, and a phone call to each is more accurate than any model. Businesses in rapid change, such as those just after an acquisition or a switch in business model, also have history that no longer describes the future.
And software is sometimes enough. Several cash forecasting tools connect to Xero or QuickBooks and do reasonable pattern-based projections. At SpiderHunts we suggest trying one before commissioning anything custom. A bespoke build earns its keep when cash spans several entities, currencies or an ERP the tools do not support, or when the forecast needs to feed treasury decisions automatically. Our data science work in finance usually starts with a short back-test of whatever the team uses today.
Frequently asked questions
Can AI forecast cash flow accurately?
What is a 13-week cash flow forecast?
Does Xero or QuickBooks do cash flow forecasting?
How long does it take to build a machine learning cash flow forecast?
Cash forecast wrong by the third week?
Send us a sample of bank transactions and your current forecast. We will tell you which parts a model could predict better and which need to stay in the finance team's hands.