Research note · 2026
How I built AI agents that run the accounting of nine companies
Two countries, two local GAAPs, IFRS and a group consolidation pack. Agents work every cycle, every day, and close the books at month end.
A set of AI agents I designed now runs the accounting of nine legal entities in France and Morocco, every day and not only at the close. They post the supplier and customer entries, reconcile the banks, match the intercompany flows, compute the fixed asset and IFRS 16 lease adjustments, and build the reporting pack each entity sends to the group. They build that pack from the ERP alone. On the largest entity, a balance sheet of more than a billion, the result lands within a few hundredths of a percent of what the team submitted. Every line carries the rule that produced it and the evidence behind it.
It began with a simple idea: connect to the ERP, watch how the finance team works, and have the machine do the same work. The hard part is that accounting runs on memory as much as on rules. IFRS, the group manual and local tax law say what to do. How it is actually done lives in people’s heads, in spreadsheets kept by one person, in a correcting entry passed three years ago that nobody remembers. So the method became: connect to the ERP, map the company with discovery agents, infer the rules as executable policies, prove them by replaying the history, and only then let the engine run.
The perimeter is a French company and a Moroccan group of eight, including a holding, a merged entity whose history had to be rebuilt, and companies with very different activities. That means two local GAAPs with their own charts of accounts and tax rules, IFRS restatements kept in separate ledger layers, intercompany flows between every pair of entities, and a monthly group reporting pack of several thousand lines per entity in the format the consolidation system expects. The code base behind it is more than 400,000 lines, with another 85,000 lines of tests that replay the history.
Entities shown anonymously. Every cycle agent works across every entity, from local books to the group pack.
The agents are organised the way a finance function is, by cycle. There is one for purchases and suppliers, one for sales and customers, one for cash and bank reconciliation, one for fixed assets and leases under IFRS 16, one for intercompany, one for payroll and the other flows the team receives from outside, and one for the group reporting pack. Each owns both the daily flow of its cycle and its share of the close. Above them sit a close pilot, which sequences the work and tracks every task to the day, and a manager agent, which checks what the others produce before anything reaches a person.
The method. Nothing runs until it has been proven against what the team actually did.
What changed for the team
Before explaining how it works, here is what it changed.
The first gain is time. A month of finance work used to start with collection: exporting, reformatting, matching, rebuilding the same schedules as the month before with new amounts. That part now arrives prepared. The entries, the reconciliations, the intercompany matching and the reporting pack land ready for review, with the reasoning attached. Work that took the team days at each close is done by the time they sit down, and the hours we measure are the hours given back, counted task by task.
Controls changed in nature. A manual control is a sample, performed late, by someone who is also busy producing the numbers. Here every line is checked, every month, against the rule that should have produced it and against the history that justifies it. A difference no longer waits for the auditor or the group to find it. It is raised the day the data arrives, qualified, and kept in view.
Compliance became something we can show. Each policy carries its source in the standard or the group manual, its version, the person who approved it and the replay that proved it. When a figure is questioned, the answer is a trace to the event, the rule and the documents, which is a far better conversation with an auditor than a spreadsheet and a memory.
Quality improved in a way I did not fully expect. Because the engine treats every entity with the same rules, inconsistencies between entities became visible for the first time. Some were in the ERP, some in the group reporting, some in our own understanding. Fixing them at the source improved the numbers everywhere at once, and each fix stays fixed because it lives in code, not in someone’s habit.
The most important change is what people now do with their time. The team spends less of the month producing and more of it understanding: why a margin moved, whether an estimate still holds, which contract deserves a second look, what the numbers mean for the decisions ahead. The machine prepares the routine work and shows the evidence. The accountants make the calls that need judgement. That is a better job, and a more valuable one.
Illustrative. The routine production work moves to the agents; the time released goes to review, analysis and decisions.
The ledger already knows most of the answer
The starting observation was simple. A mature ledger is a very long record of decisions. Every month, the team takes the same kinds of documents, applies the same kinds of judgement, and leaves a trace in the general ledger. Most months repeat the previous one, and mostly only the amounts change.
If that is true, the expected output does not have to be specified by hand. It can be read back from the history. A rule that the team has applied consistently for eighteen months is visible in the data, even if it was never written down. A rule that changed in March leaves a seam, and the seam can be dated.
This sounds obvious. It turned out to be the most productive idea of the whole project, because it changed the question we asked the machine. We stopped asking it to know accounting in general. We asked it to explain this ledger, entry by entry, and to say when it could not.
Getting the data was the real project
I underestimated this part, and I suspect most people do. It is also where I spent the most energy.
Our ERP is a large cloud system. Read access is granted object by object, and the objects that matter most are often the ones that are not yet open: ledger entries, supplier invoices, bank statements, the lease schedules. The obvious interfaces returned refusals. Others answered, but slowly, a few thousand records at a time. A full year of one entity’s ledger is close to a million lines.
I designed a small, careful collection layer around those constraints instead of waiting for them to disappear. It runs inside the user’s own authenticated session, it only reads, and it is limited to a short list of export actions that the finance director approved explicitly. Large exports are cut by entity and by month and queued so that small jobs never wait behind a large one. Each package arrives with a fingerprint and a provenance record, and is never modified. Working copies are separate, and any normalisation is logged. One of our historical ledgers opened the year with amounts carried to six decimal places. The rounding we applied is recorded, down to the last cent of difference.
None of this is glamorous. It is, however, what makes everything downstream trustworthy. An agent that reasons well on incomplete data is worse than useless in a close, because it is confidently wrong.
Turning the rules into code
The heart of the system is a single engine. Every accounting rule lives there, and nowhere else. There is no rule hidden in a dashboard, no correction applied in a report, no special case written into an export. That constraint felt bureaucratic at first. It is the reason the system can be audited at all.
Rules enter the engine in two ways. Some are declared, because a standard or a group policy says so. Others are learned from the history, proposed by an agent, reviewed by a person, then frozen. Once frozen, a rule is replayed against months the agent has not seen. If it does not reproduce what the team actually did, it does not go into service.
The learning is deliberately conservative. Early on, we let the system learn every exception it could find. It fitted the past beautifully and predicted the future badly, because many of those exceptions were timing differences rather than rules. We pulled back to a much stricter approach: a prior built on the structure of the chart of accounts, and exceptions accepted only when they survive the replay. Fewer rules, each one defensible.
IFRS was where this became interesting. A local ledger and an IFRS view of the same company diverge for reasons that are perfectly principled but rarely visible in the entries. One example is fully depreciated assets. They remain in the local books for years, while the IFRS book retires them. Another is a deferred tax asset carried into the year with its counterpart in equity. A third is a lease liability that the standard splits between current and non-current, while the ledger keeps it in one line. Each of these became a small, explicit policy in the engine, with its source, its scope and its proof attached.
A rule that fails the replay goes back to review. Nothing enters service on trust.
The engine does not paraphrase the standard. It encodes how this group applies it, and keeps the evidence.
The group pack as an exam
Every month, each entity sends a reporting pack to the group consolidation system. It is a dense, formal object: thousands of lines by account, flow, partner and destination, in a fixed format.
We used these packs as an exam. The engine produces the pack for each entity from the ERP alone, with no access to the answer, and we compare its output with what the team submitted, line by line. We hide one month, produce it, and score it. Then we rotate the hidden month and do it again.
Each month is hidden in turn. The engine learns from the others, produces the hidden one from the ERP alone, and is scored line by line.
The first runs were humbling. I took them personally, went back through every line that did not match, and fixed the engine one rule at a time. Today the balance sheet of our largest entity, more than a billion in total, lands within a few hundredths of a percent of the submitted pack, produced from the ERP alone. On our French entity, the net result matches every month of the year to within a few thousand euros. Where a line still differs, we know exactly why.
The goal was never to copy the pack. It was to understand every line of it well enough to produce it without being shown.
Every difference gets a name
This is the part I am proudest of, and the part that changed how I think about the finance function.
When the engine and the team disagree, nobody assumes the machine is right, and nobody assumes the team is right either. The difference goes into a register, and is qualified. It may be an error in the ERP, an error in the pack, a deliberate group choice, a gap in our rules, or missing data.
Several of the largest differences turned out to be ours. In one case, our generator silently dropped accounts that had moved in a month the group template did not list. In another, it carried a deferred tax asset without its equity counterpart. Fixing those collapsed gaps of hundreds of thousands to almost nothing. Other differences were genuine group choices, such as an investment presented one way in the group view and another way in the statutory books. Those stay visible, marked as intended, until the finance director closes them. Some were simply the team being human, and we found them.
Five possible causes for every difference. Only the person accountable for the numbers closes one.
The register is the system’s conscience. Nothing is closed automatically, and nothing disappears because it is inconvenient. A difference stays on the dashboard until the person accountable for the numbers lifts it.
Agents that work, people who decide
The agents now do the work first. They prepare the entries, the reconciliations, the intercompany matching, the fixed asset and lease adjustments, and the group pack, for a French entity and the Moroccan perimeter. Each output comes with its justification: which rule, which source documents, which months of history support it.
People validate, or take the exception. The machine never writes to the ERP on its own; it hands over its work with the reasoning attached, and someone accountable decides. Around it, I built the cockpits the leadership team uses every day: reliability per entity, open differences, the age of each one, and the hours the agents give back to the team.
The comparison with the ERP and with the consolidation system is no longer the way the system runs. It is how a rule earns the right to run. With the engine able to produce the pack on its own, the consolidation system becomes a confirmation rather than the source of truth.
I owned this end to end: the ambition, the data access, the engine design, the rules, the review of every difference, and the dashboards on top.
The ERP was never designed to know why
Building this changed how I see the systems we all run on.
Today’s ERPs are extraordinary recording machines. They capture every purchase, invoice, payment and asset with great discipline. What they do not hold is the reasoning. The accounting policy sits partly in the standard, partly in a parameter screen, partly in a procedure document, and largely in the heads of the people who close the books. So every month a finance team collects data the company already produced, reconciles it after the fact, translates it into entries, and then spends the close proving to itself, and later to the auditors, how each number came to be. A large share of finance work is the reconstruction of an economic reality the business knew at the moment it happened.
The ERP is where the transactions live. It was never designed to be where the judgement lives.
New ERP is a bet on a different architecture. The operational systems keep doing what they do well, emitting events. Above them, an engine independent of any particular ERP interprets those events through explicit, versioned, tested accounting policies. It decides recognition, measurement and allocation, generates the entries and runs the controls as the activity happens. The ledger stops being the place where accounting is done and becomes its output. Reconciliation becomes continuous, anomalies arrive as exceptions, and the close shrinks to what genuinely needs a person: estimates, trade-offs and sign-off. Every figure can be traced back to the event that caused it, the rule that treated it and the evidence behind it.
Today the team rebuilds the numbers from the ERP. In the target architecture, policies run on events and the ledger is the result.
We built for that from the first day. The engine never speaks the ERP’s language: its rules are written on accounts, counterparties, amounts and dates, and a thin connector translates whatever the source system exposes. Today that source is a large cloud ERP. Pointing the same engine at another one, an open-source ERP for instance, means writing a new connector and replaying that company’s history, not rebuilding the logic.
If that holds, the consequences go well beyond accounting. A group could run the same policies across every entity whatever ERP each one uses, and a migration would stop being a multi-year trauma, because the knowledge no longer lives in the system being replaced. The question a finance leader asks of software would also change, from where are my transactions stored? to where are my rules, who approved them, and can I replay them? And a finance function could be organised around governing a programmable system instead of feeding a manual chain.
We have shown on a real group, with real ledgers and real IFRS, that the rules can be read out of the history, written as code and proven. I think the next decade of finance systems will be decided less by who records transactions best than by who owns the logic that turns them into accounts.
Related research
When software becomes the customer — what changes when enterprises start operating through agents.
Redesigning a labour-intensive business for the AI economy — operating-model choices when routine work becomes cheap to automate.
About the author
Amine El Afrit is a Casablanca-based finance executive working across strategic finance, capital allocation, business transformation and operating-model design.