← All standards
Open specificationStablePublished November 2026Changelog

The Ledger Write Preview Build Standard

Before any bot writes an invoice, bill or journal into your accounts, it shows you the figures worked out again from scratch and the exact journal it will post. Anything a cent out stops for you. You release it, it is written once, and it is checked again once it is in. Works with Xero, MYOB or QuickBooks.

Used by

  • Bookkeeper
  • Accounts Officer
  • Financial Controller
  • Business Systems Analyst
  • AI Officer

10 min read · Published by AI Pathway

Using Claude? This standard installs as a skill. Guides for ServiceM8, Xero and Simpro.

How to get this live in your business

Need a bot to do something?Not sure where to start or how to do it? Contact us and we'll help scope it and build it.
Build it myself

DIY. The objects, the checks in order, and the pass test.

What this is

An open build standard for any bot or build that writes into your accounts. Before it writes an invoice, a bill, a credit note, a bank payment or a journal, it shows you a preview: every line, the GST, the totals and the exact debits and credits it will post, all worked out again from the inputs.

The core rule

The build previews. A named person releases. Only then is the document written, once, and read back to check the ledger stored the same totals.

What it does not do

It never corrects a total quietly, never guesses a GST rate, never writes a journal that does not balance, and never writes the same invoice twice. A draft a cent out stops with both figures for you.

The hard part

Getting the cents right the way your ledger does, line by line, and writing exactly once into accounts we do not own when the connection drops halfway.

A bot raised forty invoices overnight. Thirty-nine are right. One has GST a cent higher than the line it sits on, because the bot worked the tax out on the total instead of per line, and nobody will notice until the BAS does not reconcile in three months. The ledger took it without a murmur. The preview is where somebody would have seen it.

One draft, from the hand-over to the read-back

  1. Another build hands over a draft to write into the ledger: an invoice, bill, credit note, spend or receive money, or a manual journal.
  2. Every line amount is worked out again from quantity, unit price and discount, and the tax on each line from the ledger's own rate.
  3. The subtotal, total tax and total are worked out, with the exact journal lines the document will post.
  4. A draft whose stated totals are out by a cent, that names a tax rate the ledger does not hold, or whose journal does not balance is parked for a person with the figures, and never written.
  5. Before anything is written: has a named person released this preview? If no, nothing is written and the preview waits.
  6. If yes, the document is written once, with an idempotency key, and a retry reads the ledger for the key first.
  7. Do the totals the ledger stored equal the preview? If yes, the read-back is recorded and the document is done.
  8. If no, it is parked for a person with both sets of figures. The build does not edit the document to match.
The filled diamond is the release. Before it, the build only reads your ledger’s tax rates and fills the preview. Everything written into your accounts comes after it, and the document is done only when it reads back equal to the preview.

Take the spec to Claude, ChatGPT or Copilot. The sentence to paste is one click away.

1. What this standard covers

Any build that writes documents into a cloud ledger: a bot raising invoices from finished jobs, a flow turning supplier emails into bills, an agent posting accruals. The documents are invoices, bills, credit notes, spend money and receive money transactions, and manual journals. Before each one is written, the build produces a preview from the draft’s inputs alone and holds it for a person. After that person releases it, the build writes it once, reads it back and compares.

Out of scope. Deciding what to invoice or what a bill is for, coding a transaction, and the month-end close. A line nobody can code goes to the Uncoded Query standard, and journals posted at month end follow the Month-End Close, which can use this preview for each one.

How it connects. The tax rates and the write go through the ledger’s own sign-in and API, approved by you. The preview can be worked out by your own build, or by AI Pathway’s preview_draft tool on the connector you already signed in to.

Facts that can change, and when we checked them

Checked as at 24 November 2026

Xero. A write through the Accounting API can carry an Idempotency-Key header, so a retry with the same key lands once. Tax rates and their names are readable from the organisation’s tax rates.

MYOB Business. No idempotency key is documented, so the key goes in the document’s memo or reference and the build reads for it before any retry.

QuickBooks Online. A request id on the call makes a repeat return the first answer instead of writing again.

These change, and a ledger can have its own rounding setting. Check the vendor’s current API reference before you build, and run the pass test on your own file.

Check these against the primary instrument before you rely on them, and store the date you checked beside the value rather than hard-coding it. This standard tells you the shape and where to look. It is not legal advice and it does not tell you that anything complies.

2. The arithmetic, line by line

Every figure in the preview is worked out from the inputs, never copied from the draft. Money is whole cents. The tax rate is the one your ledger holds for the line’s tax type, read before the preview; a tax type it does not hold parks the draft.

FigureHow it is worked out
Line amountQuantity x unit price x (1 - discount), rounded to the cent, half away from zero.
Tax, amounts before taxLine amount x the ledger's rate for the line's tax type, rounded to the cent on each line.
Tax, amounts including taxLine amount x rate / (1 + rate), rounded to the cent on each line.
Total taxThe sum of the line taxes. Never worked out once on the subtotal.
Subtotal and totalBefore tax: subtotal is the sum of the lines, total is subtotal plus tax. Including tax: total is the sum of the lines, subtotal is total less tax.
JournalThe control account (receivables, payables or bank) for the total, each line's account for its amount before tax, the GST account for the tax. Debits equal credits.

3. The preview, in the shape your developer needs

One preview per draft. Money is whole cents. The build fills everything except the release.

For your developer. Show the fields for your developer
draft                             # handed over by another build
  - draft_id, type                  # invoice | bill | credit_note |
                                    #   spend_money | receive_money |
                                    #   manual_journal
  - amount_type                     # exclusive | inclusive | no_tax
  - lines[]  quantity, unit_price, discount_pct,
             account_code, tax_type
  - stated   subtotal, total_tax, total

preview                           # written by the build
  - preview_id, draft_id
  - rates_read_id                   # the ledger's own rates
  - lines[]  line_id, amount, tax   # recomputed
  - subtotal, total_tax, total      # recomputed
  - journal[] account, debit, credit  # must balance
  - idempotency_key                 # preview:<tenant>:<draft>:<preview>

parked                            # for a person, never written
  - draft_id, kind                  # totals_differ | unknown_tax_rate |
                                    #   unbalanced | readback_differs |
                                    #   write_failed
  - stated?, recomputed?, ledger?   # both figures, always

release                           # a person, never the build
  - preview_id, by, at

after release
  - document_id                     # written once
  - read_back  subtotal, total_tax, total, matches

There is no field for a tolerance and no status the build can set on a release. A cent is a difference, and a person decides what it means.

4. The checks, in order

The order is the claim. The arithmetic comes before the preview, the preview before any release, and the release before anything is written. A document that went in wrong is harder to find than one that never went in.

  1. Every draft gets a preview or is parked. Each draft handed over to be written ends the run with a preview in the book or a parked item that says why not. None is skipped, and none goes to the ledger on the strength of the draft alone.
  2. Every line amount is recomputed from its inputs. Each line amount in the preview is quantity times unit price less any discount, rounded to the cent, half away from zero. It is worked out from the inputs, never copied from the amount the draft states.
  3. Tax is recomputed per line from the ledger's own rate. The tax on each line comes from the rate the ledger holds for that line's tax type, read before the preview: for amounts before tax, amount x rate; for amounts including tax, amount x rate / (1 + rate); each rounded to the cent on the line. The preview names the read the rates came from.
  4. The subtotal, total tax and total are recomputed. The preview's total tax is the sum of the line taxes. Before tax, the subtotal is the sum of the line amounts and the total is the subtotal plus tax. Including tax, the total is the sum of the line amounts and the subtotal is the total less tax.
  5. The preview shows the exact journal, and it balances. The preview lists the journal lines the document will post, account, debit and credit: the control account for the total, each line's account for its amount before tax, and the tax account for the tax. Debits equal credits to the cent. A draft whose journal cannot balance is parked as unbalanced and never previewed for release.
  6. A draft whose totals differ by a cent is parked, never adjusted. When the draft's stated subtotal, total tax or total differs from the recomputed figure by any amount, even one cent, the draft is parked for a person with both sets of figures. The build does not correct it, round it away or write either version.
  7. A tax rate the ledger does not hold is never guessed. When a line names a tax type the ledger has no rate for, or the ledger does not answer the rates read, the draft is parked as unknown_tax_rate. The build never assumes 10%, never borrows a rate from another line and never writes the draft.
  8. Nothing is written until a named person releases the preview. A document is written only after a named person has released the preview for that draft, and what is written is that preview. A draft nobody released has nothing written, however long it waits.
  9. Each released document is written exactly once. Each write carries an idempotency key, preview:<tenant>:<draft>:<preview>, in the ledger's idempotency key or request id where it has one, and in the reference or memo. Before any retry the build reads the ledger for that key. A write with no answer is not counted as written; it is parked as write_failed and tried again only after the read.
  10. The document is read back and its totals compared with the preview. After a write, the build reads the document back from the ledger and compares the subtotal, total tax and total the ledger stored with the preview, to the cent, and records the comparison. A difference is parked for a person with both sets of figures; the build does not edit the document to match.
  11. A dry run writes nothing. With dry run on, the build reads, recomputes, previews and parks exactly as it would otherwise, and makes no write to the ledger, even for a released preview.
  12. It survives the builder. Someone other than the builder can explain what it does, and it runs on an account the business owns.
  13. The pass test passes. In the business's own ledger: take one invoice draft, one bill draft and one draft whose stated tax is a cent out. The two good drafts preview with totals and a balanced journal; the third is parked with both figures. With no release, nothing is written. After a named person releases, each is written once, a second run writes nothing, and each reads back with the ledger's stored totals equal to the preview.

5. One morning’s drafts

An illustration, not data, using the figures the runnable stub uses. A plumbing business’s bot hands over nine drafts. An invoice for three filters at $19.99 less 15% comes to $50.97 on that line, with $5.10 GST; 2.5 hours at $19.99 is $49.98 with $5.00 GST; the GST free line carries none. The preview shows the totals and the journal: receivables debited $156.05, sales credited for each line, GST credited $10.10. It balances.

A second invoice for $123.45 states GST of $12.36. Per line it is $12.35. It is parked with both figures, and nothing is written. A bill for import freight names a tax type the ledger does not hold, so it is parked too, not given 10%. A wages journal with $100.00 of debits and $90.00 of credits is parked as unbalanced.

The bookkeeper releases every preview but one. The first write times out after it landed; the next run reads the ledger for its key, finds it, and does not write it again. One bill reads back with GST a cent lower than the preview, so it goes to the bookkeeper with both figures. Everything else reads back equal.

6. Writing into your accounts, once

Each released preview carries the key preview:<tenant>:<draft>:<preview> in the document’s reference or memo, and in the ledger’s idempotency key or request id where it has one. Before any write the build reads the ledger for that key. A write with no answer does not count as written. It is parked and tried again only after the read.

The document is done only when it reads back. The build compares the subtotal, total tax and total the ledger stored with the preview, to the cent, and records the result. A difference goes to a person with both sets of figures; the build never edits the document to match. With dry run on, everything up to the release happens as usual and nothing is written.

7. What stays with a person

  • Releasing each preview, by name.
  • Every parked draft: totals a cent out, a tax type the ledger does not hold, a journal that does not balance.
  • A document whose stored totals differ from the preview once it is written.
  • Fixing the bot or build upstream that produced a wrong total, so the next draft is right.

8. Run it your way

The same checks and the same pass test on each. Two rules hold whichever you pick: nothing is written before a named person releases it, and a cent is a difference.

  • Google Workspace. A sheet with tabs for the drafts, your ledger’s tax rates, the previews and the releases, working each line out with the formulas above. It never connects to your ledger. See building on Google Workspace.
  • Microsoft 365. SharePoint lists for the drafts, previews and releases, a flow that works out each preview through your ledger’s own connector, and a second that writes only after release. The Release Before Posting build plan lays out the lists and flows.
  • Your own Grok Bot or Claude. Connected to your ledger through AI Pathway, it calls preview_draft before it writes anything and shows you the preview in the chat. You release it there; the write and the read-back follow.
  • Your own code. This page. Hand it to a coding agent: it gets the checks as data, the stub world, and a runner that tells it when the build is right. See running a standard anywhere.

9. What to Stub, and What Not to Hand-Roll

Everything runs against the stub first: the drafts, the ledger's rates, the preview book, the release and a ledger that can lose an answer. In production the preview comes from preview_draft on the AI Pathway connector at connect.aipathway.com.au, which reads the connected ledger's own tax rates. The write and the read-back are your build's, against your own ledger.

For your developer. Show the setup for your developer
provider:
  stub:       local.mock_ledger_write
  production: office_voice.preview_draft# AI Pathway MCP tool; no insert to buy
  default:    stub                       # no live mapping in the conformance kit yet

the live step                        # AI Pathway connector
  preview_draft                      # connect.aipathway.com.au
    in:  a draft, as handed over
    out: lines, tax, totals, journal
         or the reason it is parked

the ledger connection                # the ledger's own sign-in
  Xero, MYOB Business or QuickBooks Online API
  scopes: read tax rates, write and read documents

ports the stub exposes
  readSettings, readDrafts, readTaxRates, readBook,
  writePreview, park, writeDocument, readDocument,
  recordReadBack

no port exists for
  releasing a preview, or editing a
  written document to match

Anyone selling a bot that writes into your ledger should be able to answer one question: show me the preview a person released before last week's invoices went in, and the read-back that proves each was written once.

The pass test. In your own ledger, not a sample. Hand the build an invoice draft, a bill draft and a draft whose stated tax is a cent out. The first two preview with recomputed totals and a balanced journal; the third is parked with both figures. With no release, nothing is written. Release the two. Each is written once, with the key in its reference, and reads back with the ledger’s stored totals equal to the preview. Run it again: nothing new is written. A stub cannot pass this. On a stub the documents are rows in the runner’s memory. Only your own ledger, with its own tax rates and rounding, proves the figures agree and the write landed once.

10. A checklist to hold any build or supplier to

Hold a DIY build or a vendor to this. If a box is empty, it is not in production.

  • 1. Every draft gets a preview or is parked. Each draft handed over to be written ends the run with a preview in the book or a parked item that says why not. None is skipped, and none goes to the ledger on the strength of the draft alone.
  • 2. Every line amount is recomputed from its inputs. Each line amount in the preview is quantity times unit price less any discount, rounded to the cent, half away from zero. It is worked out from the inputs, never copied from the amount the draft states.
  • 3. Tax is recomputed per line from the ledger's own rate. The tax on each line comes from the rate the ledger holds for that line's tax type, read before the preview: for amounts before tax, amount x rate; for amounts including tax, amount x rate / (1 + rate); each rounded to the cent on the line. The preview names the read the rates came from.
  • 4. The subtotal, total tax and total are recomputed. The preview's total tax is the sum of the line taxes. Before tax, the subtotal is the sum of the line amounts and the total is the subtotal plus tax. Including tax, the total is the sum of the line amounts and the subtotal is the total less tax.
  • 5. The preview shows the exact journal, and it balances. The preview lists the journal lines the document will post, account, debit and credit: the control account for the total, each line's account for its amount before tax, and the tax account for the tax. Debits equal credits to the cent. A draft whose journal cannot balance is parked as unbalanced and never previewed for release.
  • 6. A draft whose totals differ by a cent is parked, never adjusted. When the draft's stated subtotal, total tax or total differs from the recomputed figure by any amount, even one cent, the draft is parked for a person with both sets of figures. The build does not correct it, round it away or write either version.
  • 7. A tax rate the ledger does not hold is never guessed. When a line names a tax type the ledger has no rate for, or the ledger does not answer the rates read, the draft is parked as unknown_tax_rate. The build never assumes 10%, never borrows a rate from another line and never writes the draft.
  • 8. Nothing is written until a named person releases the preview. A document is written only after a named person has released the preview for that draft, and what is written is that preview. A draft nobody released has nothing written, however long it waits.
  • 9. Each released document is written exactly once. Each write carries an idempotency key, preview:<tenant>:<draft>:<preview>, in the ledger's idempotency key or request id where it has one, and in the reference or memo. Before any retry the build reads the ledger for that key. A write with no answer is not counted as written; it is parked as write_failed and tried again only after the read.
  • 10. The document is read back and its totals compared with the preview. After a write, the build reads the document back from the ledger and compares the subtotal, total tax and total the ledger stored with the preview, to the cent, and records the comparison. A difference is parked for a person with both sets of figures; the build does not edit the document to match.
  • 11. A dry run writes nothing. With dry run on, the build reads, recomputes, previews and parks exactly as it would otherwise, and makes no write to the ledger, even for a released preview.
  • 12. It survives the builder. Someone other than the builder can explain what it does, and it runs on an account the business owns.
  • 13. The pass test passes. In the business's own ledger: take one invoice draft, one bill draft and one draft whose stated tax is a cent out. The two good drafts preview with totals and a balanced journal; the third is parked with both figures. With no release, nothing is written. After a named person releases, each is written once, a second run writes nothing, and each reads back with the ledger's stored totals equal to the preview.
  1. 1

    Hold the build to the checklist

    The checks in this standard are what a working build looks like. Implement it yourself, hand it to a developer, or hand the page to an AI with the button below.

  2. 2

    Do not hand-roll

    There is no product for this step. Highest option: none. Checklist plus a build.

  3. 3

    If you are stuck

    Exceptions, three systems, a team that will not maintain a Zap, or an owner who wants it done. We implement when it has to survive the business.

Related reading

Want the whole thing by email?

This paper, plus the rest of the library. One click to stop them.

Run these checks yourself

Every check on this page is published as structured data. This prints them with what to inject, what to assert, and which ones can be proved on your own machine rather than against the live thing.

npx @aipathway/conformance show ledger-write-preview-build-standard

Free and open source, CC BY 4.0. The checks are fetched from this page rather than bundled, so a correction here reaches you without a release, and you cannot end up conformant against a stale copy. The raw JSON is there if you would rather wire it into your own harness, and the package shows how to drive your build through the ports.

Built it, and one check failed?

Tell us which one. You have already read the standard and tried it, so the answer is a fixed price to finish that step, not a call to work out what you need.