A late payment interest claimer on AWS for a few dollars a month
A fabrication workshop with eleven staff spent an afternoon working out what it was owed for being paid late over one financial year. The interest came to nine thousand pounds, which was more than expected. The fixed compensation came to twenty-six thousand, which nobody in the room had heard of.

Key takeaways
- A debt becomes late on a date the contract decides, or on a statutory default if it is silent.
- The rate is fixed once, at the reference date, and does not move afterwards.
- There is a fixed sum per late invoice on top of the interest, and on small invoices it dominates.
- The entitlement survives payment of the principal, for six years.
- Designed on AWS for about $4 a month.
The whole system on one page
Before any code, here is the shape of what we are designing.
- Security & identity
- Management
- Analytics
Why nobody claims it
Not because they do not want the money. Because the calculation is fiddly in a way that resists being done once: every invoice has its own due date, its own rate fixed on its own reference date, its own number of days late and its own compensation band. Doing that for one invoice takes ten minutes. Doing it for four hundred and twelve is a project nobody authorises.
So the entitlement accrues and nothing records it, and by the time somebody thinks about it the invoices have been paid, the relationship has moved on and the whole thing feels like ancient history. It is not ancient history. It is an ordinary debt with six years on the clock, and the arithmetic that felt impossible by hand is a loop.
What runs (the inside)
- The due date. When this particular invoice actually became late, established from the terms rather than assumed to be thirty days. Part 2.
- The rate. Base rate plus eight, pinned to the reference date it was fixed on, and never moved afterwards. Part 3.
- The entitlement. Daily interest, the fixed sum for the band, and reasonable recovery costs above it. Part 4.
- What you do with it. Which of these numbers is a letter, which is a negotiating position, and which is a note to self. Part 5.
One workshop, one financial year
In plain words
Invoices come in from the accounting system as they are raised, each with a customer, an amount, a date and whatever payment terms were attached to it. The first job is to turn that into a due date that can be defended, which is less obvious than it sounds and is the whole of part two.
Payments come in as they clear. An invoice with a payment on or before its due date leaves the system immediately and is never thought about again. An invoice without one starts a clock, and that clock keeps running whether or not anybody looks at it.
The rate is pinned at the moment the clock starts. This is the detail that most spreadsheet attempts get wrong, because it feels natural to apply today’s rate to everything, and the actual rule fixes a rate for a whole six-month reference period and then leaves it alone for the life of the debt. Part three is entirely about that.
Then the entitlement is three lines rather than one: interest accruing daily, a fixed sum determined by the size of the invoice, and any reasonable costs of recovery above that fixed sum. They are three separate rights with three separate rules and adding them up is the easy part.
Design rules that shaped every decision
- Every due date records how it was derived, not just what it is.
- The rate is written onto the debt when it becomes late, and never recomputed.
- Interest accrues daily and is stored as a daily amount, not a running total.
- Payment of the principal closes the invoice and does not close the entitlement.
- Nothing is ever sent automatically. The system calculates; a person decides.
- Every figure can name the invoice, the date and the rate it came from.
What it does not do
It does not chase invoices. That is a different system with a different rhythm, and most businesses already have one. This runs behind it and records what the chasing was worth, which is a question credit control never gets asked.
It does not send anything on its own either. The number this system produces is commercially loaded in a way that a dunning email is not: claiming it against a customer you want to keep is a decision, claiming it against one who has just gone quiet is a different decision, and no rules engine should be making either. Part five is about that, and the design follows from it.
And it does not give legal advice. It implements a published set of rules, records which version it applied and shows its working, so that the number in front of you is one you can check rather than one you have to trust. When there is a contractual remedy that displaces the statutory one, the system says so and stops calculating rather than guessing.
The next four posts walk through each piece: when an invoice actually became late, which rate was fixed on it and when, what the three components of the entitlement are, and what to do with a number you may well decide not to send. One diagram per post, a cost breakdown, and an engineering reference at the end.
All posts