Automatically invoice complex contracts: why Claude agents are game-changers
Eiffage Energie Systèmes - Val de Loire purchases energy wholesale and re-invoices it to its clients according to terms defined in the contract. Over a hundred sites monitored, over a thousand statements produced, and a discrepancy between the purchase price and the re-invoiced price which constitutes the activity's margin. The request received by Galadrim's Data & AI team was simple: automate this re-invoicing.
1000 statements per year, and as many ways to calculate them
Four objectives came from the business: gain full-time equivalents, reduce errors, extract knowledge from people's minds, and manage the activity. Three unknowns accompanied them, and it was these that determined the shape of the solution.
A process driven by experience. From one case to another, the path varied, and the way of working existed as an intention shared by experienced managers.
Highly diverse contracts. Each contract has its own revision formula, its indices, and its adjustment terms, so much so that two almost identical contracts lead to two different calculation paths.
Expertise held in people's minds. What managers knew about the portfolio was written nowhere, and one departure was enough to lose it.
The work therefore relied on Excel, with one workbook per manager, a flexible tool that offers little scope for automatic verification. Re-running manually produced statements placed their accuracy at 85%, and the remaining discrepancies amounted to 5% to 10% of the total, a level explained more by the tools of the time than by the people who used them.
The specifications foresaw an entirely deterministic workflow, with OCR of contracts, formula analysis, resolution of each symbol, then calculation. This chain runs into a problem, what happens when an amendment signed in December applies retroactively to the first of January? A faulty meter, advance payments followed by an adjustment, information missing from the contract; each of these cases becomes a code branch that cuts across all already written rules.
The solution: the agentic approach
Determinism remains necessary to issue real invoices, and it requires strong agility to adapt to all scenarios.
Sources enter as they arrive, the agent chooses its approach within a closed harness, the calculation remains code, and a manager validates before issuance. The bottom loop represents the most counter-intuitive point of the project, since a decision made by the business enriches the case memory rather than the code.
An agent, more flexible than a workflow, relies on four building blocks in the delivered system.
1. A typed domain model. Clients, contracts, amendments, readings, indices, and statements exist as objects close to reality, and this model has retained its form since the start of the project.
2. A harness of eighteen tools. Each business action becomes a callable function, with its French label that the user sees in the conversation thread, and six specialised calculation tools have merged into one over the course of the project.
3. A memory per case, in markdown. Everything a manager knows without it being written in the contract lives in a versioned text file, which the business reads and corrects itself.
4. Calculations entrusted to code. Claude Sonnet 5 decides what to calculate, deterministic code calculates, and the server refuses a spreadsheet that feeds an invoice line without declaring a single consistency check.
Of the three categories of new features encountered since deployment, only one required writing code: where an unknown data source necessitated a connector. Unforeseen events and concepts not covered by the specifications are entered into the case memory, and the business handles them.
The steps to succeed in this type of project
Going into production follows five steps, and the last remains a business decision.
1. Objectify performance. A quantified target, set with managers before the first line of code: to accelerate without regressing.
2. Co-construct with the business. Managers describe their way of working, and the team equips this way of working with them.
3. Put the tool in their hands. They test on their own files, which brings up cases that no initial scoping could have listed in advance.
4. Go into semi-automatic production. The agent produces, a manager validates each output before issuance, and performance is measured continuously.
5. Go into automatic production. This step remains conditional, and the business decides it when the target is met.
The project currently operates under the fourth regime. Three signs indicate it is being used, rather than merely delivered. Managers review a prepared statement, where previously they produced it end-to-end, so the business changes in nature as much as in speed. Each decision made enriches the case memory, meaning open cases close without technical team intervention. Consistency checks flagged during acceptance testing a subscription line and a second tax rate that came into effect mid-month, two discrepancies that a spreadsheet inherently allows.
From 85% to 95% of accurate statements
Indicator
Manually
With the agent
Time per statement
≈ 30 minfor production
≈ 1 minmedian over 82 executions, then review
Cost per statement
≈ 20 €manager cost
≈ 0,10 à 0,25 €for inference, excluding review
Traceability
the workbook retains the result
replayable trace, each value has its source
The table shows the time, cost, and traceability, and the two figures show the accuracy. This gains ten points, and the result lies elsewhere: fifteen statements out of a hundred contained a discrepancy that no automatic check could detect, whereas the remaining five per cent are not produced today, because the agent hands back control due to lack of information.
The cost should be read as an order of magnitude, and human review remains the true expense. Inference costs between ten and twenty-five centimes per statement, for an average of 76 000 tokens in input and 1 350 in output per execution. A system that would have covered all cases would have produced uncertain statements, with no means of distinguishing them from others.
“Data collection and recalculations took up a significant portion of our managers' time. Today, they review an already prepared statement, with each amount justified and its source, and they retain the decision to issue it. This time given back to expertise, and the traceability we gained, convinced us.”
Philippe Bany, Operations Maintenance Director - Centre-Val de Loire Region, Eiffage Energie Systèmes
Where this approach is justified, from invoicing to claims
The method is transferable, and the percentages remain those of this business and target. A process lends itself to this approach when it combines a unique and clear objective with an execution that varies for each case, which is found in complex billing, claims management, compliance, or procurement.
---
This project was led by Galadrim's Data & AI team for Eiffage Energie Systèmes - Val de Loire.
Do you want support to launch your digital project?