A rebate claim tracker on AWS for a few dollars a month
Somewhere in an inbox is a PDF that says you get two and a half percent back on everything you buy from a supplier above ninety thousand a year, rising to four percent above a hundred and forty. You bought a hundred and thirty-eight thousand. Nobody noticed until March, and the claim window closed in January.

Key takeaways
- Rebate terms belong in a rule, not in a PDF nobody opens.
- Accrue as you buy; year-end discovery is how windows get missed.
- Retrospective tiers pay on everything, so the last pallet is the valuable one.
- Your figure and the supplier’s will differ, and the difference is definitional.
- Designed on AWS for about $3 a month.
The whole system on one page
Before any code, here is the shape of what we are designing.
- Analytics
- Front-end & mobile
- People
Why this money goes missing
Rebate income is not invoiced to you and it does not appear on a statement. Nothing arrives to remind you it exists. It is the only significant sum in a small business that has to be actively gone and got, and the only person who knows the terms is usually the one who negotiated them.
When that person changes role, the terms become a document in a folder, the accrual becomes a guess at year end, and two or three claims a year quietly expire. None of that shows up as a loss anywhere, which is precisely why it persists.
What runs (the inside)
- Terms as rules. The agreement, once, turned into tiers, dates and exclusions a machine can evaluate. Part 2.
- Live accrual. What you have earned so far, updated as purchases land, with the tier you are closest to. Part 3.
- Claims and windows. What a claim has to contain to survive scrutiny, and how a window stops being missed. Parts 4 and 5.
One agreement, one year
- Machine learning
- Management
- Analytics
In plain words
A supplier agreement arrives as a PDF. It is read once — properly, by a model, into structured fields — and becomes a rule: these product ranges, this period, these tiers, this claim window, these exclusions. The PDF is kept, because a claim sometimes needs the original wording, but nothing downstream reads it again.
From then on, every purchase invoice line is matched against the rules it might count towards. A line can count towards more than one agreement, and frequently does. The accrual moves as the lines land, so the number is current rather than annual.
In October, when the system can see that you are four thousand pounds of purchases short of a tier that pays retrospectively on the whole year, it says so to the person placing orders. That is a purchasing decision with about six weeks of runway, and it is the single most valuable output here.
At period end the claim is assembled with the line detail behind it, submitted inside the window rather than near the end of it, and then chased — because a submitted claim and a received credit note are separated by roughly two months and one forgotten email.
Design rules that shaped every decision
- The agreement is read once and becomes a rule. Nothing downstream re-reads a PDF.
- Accrue on purchase lines, not on supplier statements. Their statement arrives too late to act on.
- A retrospective tier pays on everything, so proximity to a threshold is an alert, not a note.
- Every accrual has to be explainable down to the invoice lines that produced it.
- The claim window is a date with a countdown, not a field in a document.
- Chase the credit note, not the claim. Submission is the halfway point.
What it does not do
It does not negotiate, it does not tell you whether the terms are good, and it does not buy anything. Deciding to spend four thousand pounds in November to earn six is a judgement about stock, cash and shelf life that only the buyer can make.
It also does not replace the supplier relationship. When your figure and theirs differ by nine hundred pounds, the resolution is a phone call. What the system does is make sure you arrive at that call with the line detail rather than with a number you cannot explain.
The next four posts walk through each piece: how an agreement becomes a rule, why an accrual is not a claim, what a claim needs to survive scrutiny, and how a window stops being missed. One diagram per post, a cost breakdown, and an engineering reference at the end.
All posts