Automating the accounting cycle into Odoo and Zoho, without letting the AI touch the ledger
An AI agent that reads invoices, bills and bank statements, posts them into each client's own ERP and reconciles them against the bank, for many companies at once. The seven problems that make this hard, and how we solved each one.

The AI never touches the ledger
Picture an ordinary week in a finance team.
A supplier emails a PDF invoice. Another sends a photo of one, taken at an angle on a desk. A third sends a spreadsheet with twelve bills in it. A customer pays three of your invoices in a single bank transfer, minus a bank fee, with a reference that matches none of them. Someone has to read every document, key it into the ERP with the right accounts and the right VAT, and then, at the end of the month, match every line on the bank statement to the invoice or bill it settles, until the books tie to the bank.
Now do that for many companies at once, each with its own ERP, from one shared system. And hand the reading, the drafting and the matching to an AI.
That is what we built for an AI accounting platform. Client companies upload invoices, bills and bank statements; an AI agent reads them, drafts the matching entries, posts them into each company's own ERP, which is Odoo for some clients and Zoho Books for others, and reconciles payments against the bank. Many companies share one deployment and one database.
A demo of this takes an afternoon: upload a PDF, watch the model fill in an invoice. The real thing is hard for a reason that is easy to miss. In accounting, the dangerous error is not the one that crashes. It is the wrong number that looks right. Nobody notices it on the day. Someone finds it at year end, or an auditor does.
The whole cycle, end to end
Automating only the invoice is half the job. The loop closes when the money arrives and is matched to the invoice it pays. Here is the full cycle, and who is allowed to do each step:
- 01AI model
Read
Pulls the fields out of invoices, bills and bank statements.
Code checks every field before anyone sees it.
- 02AI model
Draft
Proposes the entry: who, which accounts, which tax.
Code computes every amount and tax line.
- 03Person
Approve
Sees the draft beside the original and confirms it.
Nothing moves until they do.
- 04Code
Post
Writes to the client's ERP, reads it back, records it once.
Retries can never post twice.
- 05AI modelPersonCode
Reconcile
Matches the money in the bank to the invoices and bills it settles.
Same rules: proposed, confirmed, then posted.
One rule runs through all of it: the model only does the parts where judgement helps, and everything that touches money is ordinary, predictable code. Reading a messy scan needs judgement. Adding up line items, computing VAT and writing to a ledger do not.
The seven problems that make it hard
- 01Every document is differentPDFs, scans, photos and spreadsheets, and a model that misreads with confidence.
- 02Models are bad at moneyA VAT figure off by a rounding rule looks perfectly reasonable.
- 03Who is allowed to write to the books?An agent that can post on its own is an agent you cannot trust.
- 04Posting exactly onceEvery queue delivers twice eventually. A duplicate invoice is real money.
- 05ERPs that agree on nothingOdoo, Zoho Books and ERPNext disagree about what "posted" even means.
- 06Matching the moneyBank lines rarely map one-to-one to the invoices they pay.
- 07Many companies, one databaseOne company must never see, or post into, another's books.
01Every document is different
The problem
Invoices arrive in every layout a supplier has ever invented. This is exactly where a language model earns its place: it reads the document and pulls out the supplier, invoice number, dates, line items, amounts and tax. But models misread with confidence. Two we had to catch: a date read as an amount, and line items that do not add up to the total. In both cases the field is filled in, the format is plausible, and it is wrong.
What we did
Extraction is never the end of reading. Plain code checks what the model returned before any person sees it: do the lines sum to the subtotal, does subtotal plus tax equal the total, is every date a date and every amount an amount. A document that fails is flagged, not drafted.
Lesson
Never let a misread reach a reviewer looking like a clean draft. A reviewer who sees ten clean drafts in a row stops checking the eleventh.
02Models are bad at money
The problem
Once the fields are trusted, someone has to decide which customer or vendor, which accounts and which tax treatment. That is judgement, and the model is good at it. But a model asked to compute the VAT can be off by a rounding rule, and the result looks completely reasonable.
What we did
The model proposes the entry. Deterministic code computes every amount and every tax line, from the extracted fields and the client's own tax setup. The model never does arithmetic that ends up in a ledger.
Lesson
The AI suggests, code calculates.
03Who is allowed to write to the books?
The problem
Finance teams need to know exactly what was posted, by whom, and why, months later. "The AI decided" is not an answer anyone can accept for their ledger.
What we did
Every draft is shown to a person next to the original document, and nothing moves until they confirm it. The important part is how that is built. Approval is not a flag the agent is asked to respect: the model has no code path to the ERP at all. The only thing that can write to a ledger is a separate component that acts on confirmed drafts. Even a model that misbehaves completely cannot post, because there is nothing for it to call.

Lesson
Make human approval a wall in the architecture, not a checkbox in the prompt.
04Posting exactly once
The problem
Long extractions and ERP syncs run as background jobs, and every job queue eventually delivers the same message twice. With accounting, a duplicate is not a glitch. It is a bill paid twice or revenue counted twice.
What we did
The database is the record of truth. The job row is written in the same transaction that creates the work, and the queue message carries only the job's ID. A worker has to claim the job in the database before it runs, so a duplicate message finds nothing left to claim. More on the job design.
Message 1
Message 2 (the duplicate)
A single component, the committer, writes each confirmed entry, reads back what it wrote and records it once. Each write also leaves a marker in the ERP, so a retry can recognise its own earlier attempt. Finding somewhere to put that marker was harder than it sounds: in ERPNext the obvious reference fields already hold the customer's purchase order number, and writing there would have overwritten it. The marker lives in the remarks field instead, with a documented cost: if someone hand-edits that remark, retry protection is lost for that one document.
Lesson
Posting is not done when the API returns success. It is done when you have read it back, recorded it once, and can retry without fear.
05ERPs that agree on nothing
The problem
Odoo, Zoho Books and ERPNext, which we added later, disagree about almost everything: what a posted invoice is, whether one can be un-posted, how errors come back. A client should not be able to tell which one is underneath.
What we did
One interface, one write path, and adapters that can admit what they cannot do:
type Port interface {
Read(ctx context.Context, entity Entity, q Query) ([]Row, error)
Write(ctx context.Context, action Action, doc Document) (Result, error)
Fingerprint(ctx context.Context) (Capabilities, error)
}
Fingerprint is the part that matters. If an ERP cannot send an invoice, the agent never offers to, rather than offering and failing at the last step. Then each system's quirks are handled honestly:
- A draft is not a post. In ERPNext a document is a draft until it is submitted, so an entry is reported as posted only once it truly is. If the submit fails, the draft stays: it carries the retry marker.
- Errors mean something. A duplicate bill number in Zoho came back as a generic failure and looked like an outage. It now appears against the bill number, fixable in one step.
- Match on IDs, not numbers. People renumber invoices. We key documents by Zoho's internal ID, because matching on numbers quietly breaks reconciliation the day someone renumbers.
And some entries the ERP would accept are refused outright, because they would post in a misleading shape:
- RefusedAn invoice mixing two VAT ratesThe ERP can only represent it as one tax line, so the tax would be wrong.
- RefusedA VAT invoice with no tax account to post toIt would understate the client's VAT liability and look like a clean post.
- RefusedA payment larger than what is outstandingOr against an invoice already closed. That is real money leaving twice.
Lesson
A refusal gets fixed in minutes. A wrong number that looks right gets found at year end.
06Matching the money
The problem
Posting invoices and bills is only half the cycle. The other half is the bank. A bank statement line rarely maps neatly to one document: one transfer pays three invoices, a customer pays part of an invoice now and the rest later, a bank fee comes off the top, the reference is missing or mistyped, and the payment is in a different currency from the books. Until every line is matched, the books do not tie to the bank, and nobody can trust the numbers.
What we did
Bank statements go through the same loop as everything else. The agent reads the statement and proposes which open invoices and bills each line settles. Code checks every proposal against what is actually outstanding in the client's ERP. A person confirms it, and the committer posts the reconciliation, exactly once, through the same single write path, including across currencies.
The guards from the rest of the system matter most here:
- A payment larger than what is outstanding is refused, and so is a payment against a document that is already closed. A best-effort match there would mean money counted, or paid, twice.
- Foreign-currency documents that a company's Zoho currency setup cannot accept are held, not attempted.
- Matching runs on ERP IDs, so a renumbered invoice does not silently drop out of reconciliation.
When this step is done, the loop is closed: every document that came in has been read, drafted, approved, posted, and matched to the money that settled it.
Lesson
Automating invoices without reconciliation just moves the manual work to month end. The cycle is only automated when the books tie to the bank.
07Many companies, one database
The problem
Many client companies share one deployment and one database. One company must never see, or post into, another's books, and an AI agent holding a database connection makes that harder, not easier: a tenant filter in application code is a promise the model never made.
What we did
Isolation lives in the database itself. Every tenant table has forced row-level security, the application connects as a role that cannot bypass it, and two separate checks in CI make it impossible to merge a new table without the policy. The agent's connection can only ever see one client's rows. How that works.
That still did not catch everything. A client with no ERP connected yet quietly fell back to the deployment's default ERP, which on a shared system is the operator's own books. We found it on staging, where two client workspaces were already reading from and posting to the wrong ledger. The fix was to refuse, and tell the client to connect their ERP. The more useful finding: a unit test had been protecting the bug. Its name promised tenant-scoped routing, but its empty setup actually tested the fallback. The full story.
Lesson
Enforce isolation in the database, then test the fallback branch. That is where the leak was.
Where it is now
The agent drafts invoices, bills and bank reconciliations from the documents a finance team already has, across Odoo and Zoho Books. Nothing reaches a ledger until a person confirms it, every write happens exactly once and is read back, and the database itself makes it impossible for one client to see another's books. CI checks those guarantees on every pull request.
In the UAE, e-invoicing makes this more relevant, not less: from 1 July 2027 most supplier bills will arrive as structured e-invoices instead of PDFs, so reading gets easier and the checks matter more. Our guide to UAE e-invoicing covers the deadlines and what changes in Odoo and Zoho Books.
If you are building this
- Automate the whole loop, not just the invoice. Reconciliation is where the remaining manual work hides.
- Keep the model away from the write. Let it read and propose. Let code compute the numbers and a person approve them.
- Check extraction with plain code before a person ever sees a draft.
- Make posting exactly-once: claim jobs in the database, leave a retry marker in the ERP, read back what you wrote.
- Match on IDs, not numbers people can edit.
- Refuse rather than approximate. In accounting, a refusal is a feature.
- Test every branch, especially the fallback.
The model is the easy part of automating accounting. The work is everything around it that makes the model safe to trust with real money.
If you are planning something similar, we are happy to talk it through.
Keep reading

Three ERPs. One interface. Zero agreement.
One interface, three ERPs that agree on nothing
Odoo, Zoho Books and ERPNext disagree about what a posted invoice is, where an idempotency key can live, and whether a document can be un-posted. Here is the adapter boundary that survived adding the third one.
Read →
Why our jobs can't post twice
Postgres holds the state, the queue holds the delivery
Most background-job bugs come from treating the queue as the system of record. Put the state in your database and let the queue do nothing but wake a worker, and at-least-once delivery stops being a problem you have to solve.
Read →
One company saw another's books
The tenant fallback that served one company's books to another
A multi-tenant finance platform refused to degrade in four places and fell back in one. The unit test covering that path was named as though it proved the opposite — and for months it held the bug in place.
Read →