# Catch Duplicate Vendor Bills in QuickBooks Before Each Week's Payment Run

A restaurant group's agent reads QuickBooks every Wednesday and lists open bills that look like a second copy of another bill, before Thursday's payment run.

[Run this on Rush](https://cloud.getrush.ai/run/find-duplicate-bills-before-paying/quickbooks/). Opens the console with this prompt ready to send. Connect QuickBooks there first.

## What the agent does

This is for a restaurant group with three locations and one bookkeeper. Suppliers deliver to each kitchen several times a week, invoices arrive by email, on paper at the back door and through a supplier portal, and the same invoice is easily entered twice: once from the email at the office and once from the paper copy a chef handed in, or once under each location. The bookkeeper pays vendor bills every Thursday, and a duplicate that gets paid has to be chased back from the supplier. So every Wednesday the agent lists the open bills that look like copies. Connect QuickBooks Online once with the API key: `POST /me/connections {"type": "app", "name": "quickbooks"}` answers with an `authorize_url`, which the key's creator opens while signed in to the Rush console and approves on Intuit's page for the group's company.

The agent reads bills through the QuickBooks Online Accounting API. It sends a query of the form `select * from Bill where TxnDate >= '2026-09-26'` to the query endpoint, paging with `STARTPOSITION` and `MAXRESULTS`, so it has 60 days of bills, paid and unpaid. Intuit's schema marks a bill's `Balance` as filterable only in QuickBooks Desktop, so the agent reads `Balance` on each bill rather than filtering by it, and treats a bill with a `Balance` above zero as open. From each bill it keeps `Id`, `VendorRef`, `DocNumber` (the reference number, where the bookkeeper types the supplier's invoice number), `TxnDate`, `DueDate`, `TotalAmt`, `Balance`, `DepartmentRef` (the location, when location tracking is on), `PrivateNote` and the line descriptions.

Then it compares, per vendor. Two bills with the same `DocNumber` are the strongest match. Two bills with the same `TotalAmt` within ten days of each other and different or empty reference numbers come next, and so do two bills with the same amount and date under different locations, which is how one delivery entered at two kitchens looks. It matches open bills against paid ones too, because an open bill that copies one already paid is the one the payment run would pay twice. For each pair it writes why it matched and which of the two it would expect to keep, usually the one with the supplier's reference number and the earlier entry.

It deletes and voids nothing. Rush's QuickBooks sign-in asks for `com.intuit.quickbooks.accounting`, which can write to the books, and the prompt forbids any create, update, delete or void of a bill or bill payment. The bookkeeper checks each pair against the supplier's invoice and removes the copy in QuickBooks.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Duplicate bill check before Thursday's payment run. Today is 2026-11-25. Use QuickBooks. Query Bills with TxnDate >= '2026-09-26' using the query endpoint, paging with STARTPOSITION and MAXRESULTS until none are left. Keep Id, VendorRef, DocNumber, TxnDate, DueDate, TotalAmt, Balance, DepartmentRef, PrivateNote and line descriptions. Open means Balance > 0. Per vendor, find pairs where at least one bill is open and: (a) same DocNumber; (b) same TotalAmt, TxnDate within 10 days, DocNumber different or empty; (c) same TotalAmt and TxnDate, different DepartmentRef. Return Markdown: one row per pair, strongest match first: vendor, rule (a/b/c), bill A (Id, DocNumber, date, location, amount, balance), bill B (same), which to keep and why, and the open balance at risk. End with the total open balance at risk. Read only: never create, update, delete or void a Bill or BillPayment.",
  "connections": [
    "quickbooks"
  ]
}
```

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

The answer is a table of bill pairs, strongest match first: the vendor, which rule matched, each bill's id, reference number, date, location, amount and open balance, which of the two the agent would keep and why, and the open amount that would be paid twice if both went out. A last line totals that amount for the week's run.

The bookkeeper checks every pair against the supplier's own invoice or statement before touching either bill. Some pairs are not duplicates: a supplier that bills the same standing order every week, or two kitchens that ordered the same thing on the same day. A pair matched on reference number is the likeliest copy; a pair matched on amount alone needs the paperwork. The agent's choice of which bill to keep is a suggestion, and the bookkeeper may keep the other one to preserve its attachments.

## Run it on every Wednesday, before the payment run

Save the prompt as an agent with `POST /o/{org}/agents` and `connections: ["quickbooks"]`, and give it an automation in the console with a `schedule` trigger, a cron such as `0 14 * * 3` and the group's timezone, so the list is ready the afternoon before bills are paid; a schedule fills nothing into the prompt, so the saved prompt says "today" and "60 days before today" in place of the dates. Automations need Pro or Max. A group that schedules from its own system sends the same request with the dates filled in and a `request_id` that is a UUID v5 of the payment date, so a retried job starts no second run.

A bookkeeper who serves several restaurant groups saves one agent per client's QuickBooks company and runs each on that client's payment day; the session's `accounts` names the QuickBooks company's realm id, so each run's record shows whose books it read.

## Why run it on Rush?

Duplicate checks in a spreadsheet export catch only exact matches, and a script against the Accounting API means an Intuit developer app, OAuth, token refresh and a server that holds the books' credentials. On Rush the QuickBooks sign-in stays in Rush's connection, and the agent applies all three rules and explains each match in words the bookkeeper can check.

Each Wednesday's check runs in its own computer and is a session with its record: the queries sent, the bills returned, and the pairs found. `GET /o/{org}/sessions?account=<realm id>` lists every run that read the company's books, which is what an owner asks for when money goes out twice, and each run's cost is on its session.

## Frequently asked questions

### Can the agent delete the duplicate for us?

It could, since the QuickBooks scope allows writes, but this prompt forbids it. Removing a bill changes the books, and a pair that is not a duplicate would leave a supplier unpaid, so the bookkeeper does it after checking the paperwork.

### We do not use location tracking. Does the cross-location rule still work?

Without location tracking a bill has no `DepartmentRef`, so rule (c) finds nothing and rules (a) and (b) still catch same-vendor copies. Groups that keep one QuickBooks company per restaurant run one agent per company instead.

### Why look back 60 days and not just at open bills?

An open bill that copies one already paid last month is the costliest duplicate, and it only shows up when paid bills are in the comparison. The window is a line in the prompt; a group with suppliers who bill quarterly widens it.

### Does this work with QuickBooks Desktop?

No. Rush's QuickBooks sign-in reaches the QuickBooks Online Accounting API. The fields here come from Intuit's schema, where some, like filtering by `Balance`, behave differently between Desktop and Online.

## More QuickBooks jobs

- [How Can Bookkeeping Software Find Customer Payments Still Sitting in Undeposited Funds? One Agent per Client Company in QuickBooks](https://getrush.ai/run/find-payments-not-yet-deposited/quickbooks/)
- [Which Customer Payments Never Got Applied to an Invoice? A Month-End Close App's Check of Each Client's QuickBooks](https://getrush.ai/run/find-unapplied-customer-payments/quickbooks/)
- [Find Last Month's Uncategorized Expenses in QuickBooks Before the Close](https://getrush.ai/run/find-uncategorized-expenses/quickbooks/)

## More jobs like this: Produce a report or file, no repo

- [Which Freezer Rooms Ran Warm Overnight? A Cold-Storage Warehouse's 6 a.m. Check of Its Grafana Sensor Data](https://getrush.ai/run/find-freezer-rooms-that-ran-warm-overnight/grafana/)
- [Which Guest Complaints From Yesterday Got No Reply From a Manager? A Hotel Group's Morning Sweep of Its Slack Property Channels](https://getrush.ai/run/find-guest-complaints-without-a-reply/slack/)
- [Which Railway Projects Are Still Running for Clients We No Longer Serve? A Web Agency's Monthly Hosting Check](https://getrush.ai/run/find-hosting-left-running-for-past-clients/railway/)

## Keep reading

- [Connect QuickBooks to Rush once, then name it on any run](https://getrush.ai/integrations/quickbooks/)
- [Start your first run from the developer API quickstart](https://getrush.ai/docs/quickstart/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
