Think Build Implement Repeat
London, UK +44 7367 067226
WhatsApp FOLLOW f in X
AI & Machine Learning

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 lineModel fitWhy
Receipts from existing invoicesStrongEach customer's payment habits are learnable from history
Card and till receiptsStrongDaily patterns, seasonality and calendar effects repeat
Recurring supplier paymentsGoodSubscriptions, utilities and regular suppliers follow patterns
Receipts from sales not yet invoicedModerateDepends on a decent sales forecast
Tax, dividends, capital spend, loansPoorKnown 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

  1. Back-test by forecasting from past dates and comparing with the real bank balance 4, 8 and 13 weeks later
  2. Measure error on the closing balance and on the lowest point in the period, since the low point is what threatens the overdraft
  3. Show a range around the line so decisions account for uncertainty
  4. 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?

For short horizons and patterned items, such as customer receipts, card takings and recurring costs, machine learning can improve markedly on due-date assumptions. It cannot predict one-off events such as a lost contract or an unexpected tax bill. The best results come from combining a model with finance's knowledge of known future items.

What is a 13-week cash flow forecast?

It is a rolling weekly forecast of cash in and out over the next quarter, widely used by finance teams and lenders to manage liquidity. Its short horizon makes it practical to forecast in detail. Machine learning fits it well because many of the underlying lines repeat week to week.

Does Xero or QuickBooks do cash flow forecasting?

Both offer basic cash flow projections, and add-on tools provide more detail with scenario planning. They are a good first step for many small businesses. Custom modelling becomes worthwhile with multiple entities, complex payment behaviour or data outside the accounting system.

How long does it take to build a machine learning cash flow forecast?

For a single entity with clean ledger and bank data, a first version typically takes six to ten weeks, including back-testing. Multi-entity or multi-currency setups take longer, mainly because of data integration. Categorising historical bank transactions is often the slowest part.

Keep reading

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.

Book a free 30-minute call Get a project estimate WhatsApp us

Related services

What we build for problems like this one

AI AgentsMachine LearningAI Integration