All jobs

Cash Flow Forecast From QuickBooks, Updated Each Week

A fractional CFO firm gives each client an agent that reads its QuickBooks every Monday and rolls its 13-week cash flow forecast forward for the CFO to review.

Run this on RushOpens the console with this prompt ready to send. Connect QuickBooks there first.

What the agent does

This is for a fractional CFO firm: a handful of part-time CFOs, each serving six to ten companies that are too small for a full-time finance lead, through a client portal the firm built. The deliverable clients value most is the 13-week cash flow forecast, a table of thirteen weekly columns that starts from the cash in the bank, adds the customer payments expected each week, takes off payroll, rent, supplier bills and loan payments, and shows the closing balance week by week. It has to be rolled forward every Monday from the client's books, and that roll-forward is where a CFO's morning goes. The portal adds an agent per client that does it, so the CFO spends Monday reviewing ten forecasts rather than building them.

The firm connects a QuickBooks company of its own and saves the agent once as a template with POST /o/{org}/agents, naming "connections": ["quickbooks"] and instructions that keep it to reading. When a client joins, the portal calls POST /o/{org}/agents {"template": "<template id>", "name": "cash-<client id>"}, stores the agent id against the client, then calls POST /o/{org}/agents/{agent}/connections {"type": "app", "name": "quickbooks"} and opens the authorize_url in a popup for the client's owner or bookkeeper, who signs in on Intuit's page and picks the company. The firm registers no Intuit app and holds no Intuit token, and one client's agent can only ever read that client's books.

Each Monday the portal starts a run with the facts the books do not hold: the payroll amount and pay dates, rent, loan payments, the expected collection delay for each large customer, the minimum cash the client wants to keep, and last week's forecast for weeks 1 and 2. The agent reads through the QuickBooks Online Accounting API. A query for Account rows with AccountType = 'Bank' gives each bank account's CurrentBalance, the opening cash. select * from Invoice where Balance > '0' gives every open invoice with its CustomerRef, DueDate and Balance, and select * from Bill where Balance > '0' every unpaid bill with its vendor and DueDate. Payment rows from the last 90 days, matched to their invoices through Line.LinkedTxn, show how many days late each customer actually pays. ProfitAndLoss with summarize_column_by=Week for the past 13 weeks gives the run rate of spending that never arrives as a bill.

From that it builds the forecast: receipts by week, each open invoice placed at its due date plus that customer's measured delay (or the delay in the input when there is too little history), disbursements by week from bills, payroll, rent and loan payments, then net flow and closing cash. Any week whose closing cash falls under the client's minimum is marked, with the receipts and payments that push it there. Last week's forecast for the week just ended is compared with what the bank balance shows, and the largest misses are named. It writes cash-forecast.md, cash-forecast.csv with the thirteen columns, and returns the same numbers as JSON. It records nothing in QuickBooks.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "<agent id>",
  "input": "Roll the 13-week cash flow forecast forward for the week starting Monday 2026-11-30. Read only: never create, edit or delete anything in QuickBooks. Facts not in the books: payroll 38400 every other Friday, next on 2026-12-04; rent 6200 on the 1st of each month; equipment loan 2150 on the 15th; minimum cash to keep 60000. Expected collection delay past due date when history is thin: Harbor Medical 21 days, Lakeview Schools 35 days, everyone else 10 days. Last week's forecast for the week of 2026-11-23: receipts 51200, disbursements 47900, closing cash 132600. Steps: 1) query Account where AccountType = 'Bank' and sum CurrentBalance as opening cash; 2) select * from Invoice where Balance > '0' (CustomerRef, DueDate, Balance); 3) select * from Bill where Balance > '0' (VendorRef, DueDate, Balance); 4) select * from Payment where TxnDate >= '2026-08-31' and match each to its invoices through Line.LinkedTxn to measure each customer's average days paid after DueDate (use it when the customer has 3 or more matched invoices, else the delay above); 5) ProfitAndLoss from 2026-08-31 to 2026-11-29 with summarize_column_by Week, accounting_method Cash, to find weekly spending that does not come as bills (exclude payroll, rent and the loan, which are listed above). Build 13 weekly columns, Monday to Sunday, from 2026-11-30: opening cash, receipts (each open invoice at DueDate plus the delay; overdue invoices in week 1 only if the customer usually pays within 14 days late, otherwise at today plus the delay), disbursements (bills at DueDate, overdue bills in week 1, payroll, rent, loan, average weekly non-bill spending), net flow, closing cash. Mark every week whose closing cash is under 60000 and list the receipts and payments that put it there. Compare last week's forecast with the actual change in bank balance and name the three largest differences you can trace. Show every figure with the query or report it came from. Write cash-forecast.md (summary, then the table, then notes), cash-forecast.csv (one row per line item, one column per week) and return JSON: {week_starting, opening_cash, weeks: [{start, receipts, disbursements, net, closing}], below_minimum: [{start, closing, drivers}], last_week_variance: [{item, forecast, actual}], customer_delays: [{customer, days, matched_invoices}], checks: []}. Put anything you could not place, such as an invoice with no DueDate or a bank account with a negative balance, in checks."
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

What comes back is the JSON in the session's result, which the run.completed webhook carries to the portal's server, and cash-forecast.md and cash-forecast.csv among the session's files. The portal draws the thirteen weeks as a table and a line of closing cash against the client's minimum, with any week under it highlighted and its drivers listed. Every figure in the markdown names the query or report it came from, and the measured delay for each customer shows whether a receipt was placed from history or from the input.

What the CFO checks before the client sees it: the weeks marked under the minimum and whether the drivers are real (a large invoice the client already knows will be paid early, a bill already disputed), the checks list, and last week's variance, which says whether the forecast is drifting. The CFO writes the advice and decides what to tell the client. The agent places numbers on dates; it does not decide which bills to delay or whether to draw on a credit line.

Run it on every Monday morning

The portal starts one run per client each Monday at 6:00 in the client's timezone: POST /o/{org}/sessions with {"agent": "<agent id>", "input": "…"} for that client's agent, the input written from the facts the portal stores and last week's JSON, and a request_id that is a UUID v5 of the client id and the week, so a retry of the scheduler starts nothing twice.

A firm with sixty clients starts sixty runs at once, each on its own computer reading only its own company's books. A CFO who hears on Wednesday that a large customer will pay a month late starts that client's agent again with the new delay in the input and gets a fresh forecast in the same format.

The use case this job follows, with its automation and trigger: Run an agent per customer task.

Why run it on Rush?

Each client's Intuit sign-in is held in Rush's connection under that client's own agent, so the firm stores no Intuit token and no run can read another client's books. Each session lists the QuickBooks company it read in accounts by realm id, and GET /o/{org}/sessions?account=<realm id> lists every run that touched a client's books, which is the answer when a client asks what the firm's software read.

A spreadsheet model rolls forward only when someone pastes in this week's open invoices and bills, and a script that does the pasting breaks on the client whose bookkeeper left due dates blank. The agent reads the books, measures each customer's real payment delay, says what it could not place, and shows its arithmetic. Each run has its own computer and a record of every query, and GET /o/{org}/sessions?agent=<agent id> adds up what each client's forecasts cost in model calls.

Frequently asked questions

What is a 13-week cash flow forecast?

It is a weekly table of cash in and cash out for the next thirteen weeks, about one quarter, starting from today's bank balance. Weekly columns show a squeeze that a monthly view hides, such as two payrolls landing before a large customer pays. It is rolled forward every week so it always looks thirteen weeks ahead.

How does it decide when a customer will pay?

It matches the last 90 days of payments to the invoices they paid and measures how many days after the due date each customer usually pays. Customers with fewer than three matched invoices use the delay the input gives. The CFO can override any customer in the input the following week.

Does it change anything in QuickBooks?

No. The instructions and the prompt keep it to queries and reports, and it creates, edits and deletes nothing. The forecast lives in the files and the JSON the portal stores.

Is this a forecast of profit?

No. It forecasts cash: when money arrives and leaves the bank. A month can be profitable and still run short of cash when customers pay late, which is the case the table is built to show.

More QuickBooks jobs

More jobs like this: Run an agent per customer task

Keep reading