Post #21 Companion — The CFO & AI Series

The Script That Remembers
What the First Invoice Cost

A small script that compares each recurring invoice with the first one on record, not with last month's, and lists services nobody has confirmed using — with the reason, before anyone approves the next one.

Boris Dračka · November 2026 · Companion demo

This is a personal, non-commercial side project I put together to learn — not a product or service.

Post #21 argued that a recurring invoice can be correct every month and still add up to something nobody decided. Below is a small prototype that keeps the first price in one place and checks the latest month against it.

8
Sample recurring series checked
2
Flagged for a second look
0
Flagged by a month-to-month check at 5%

The script doesn't decide whether a price rise was agreed or a service is still needed. It keeps the first price in one place and shows where today disagrees.

The sample data

Eight made-up recurring services, ten monthly invoices each, and one month to check. For each series the script takes the first invoice as its reference price and reads the owner's last confirmation that the service is used.

  recurring_invoices.csv — sample data, all eight series
SupplierReferenceLatestSince startUse confirmedResult
Office Rent2,4002,4000.0%2026-09-15Clear
Cleaning Service1,0001,093+9.3%2026-09-15Flagged
Analytics Subscription4504500.0%2025-04-10 (no owner)Flagged
Courier Services412420+1.9%2026-10-02Clear
Software Licences8008000.0%2026-06-30Clear
Maintenance Contract1,2001,224+2.0%2026-08-20Clear
Insurance Premium6506500.0%2026-03-01Clear
Training Platform3803800.0%2026-05-12Clear

How it works

1
Load the invoicesReads a CSV with one row per invoice: id, date, supplier, service, amount, owner, last_use_confirmed.
2
Take a referenceThe first invoice of each series is its reference price.
3
Check the monthThe checked month is compared with that reference, not with the month before.
4
Flag and explainA drift above the threshold, or no use confirmation for a long time, flags a series. A missing owner is shown as context only.
5
CompareCounts how many series a month-to-month check at the same threshold would have flagged.
6
Print the resultLists each flagged series with its reasons. Nothing is cancelled, disputed or sent.

Try it yourself

1 — Clone the repository

# same personal, non-commercial repo as the earlier demos in this series git clone https://github.com/LuliBobo/cfo-agents.git cd cfo-agents

2 — Add your own recurring invoices (optional)

id,date,supplier,service,amount,owner,last_use_confirmed R0002,2026-01-01,Cleaning Service,Facility service,1000,Facilities,2026-09-15 R0074,2026-10-01,Cleaning Service,Facility service,1093,Facilities,2026-09-15 # ...one row per invoice; keep several months of history so the first invoice is a real reference

3 — Run it

python recurring_invoice_agent.py data/recurring_invoices.csv

4 — Read the output

================================================================ Recurring Invoice Agent — Price Drift and Idle Service Check ================================================================ [Step 1] Loaded 80 invoice(s) from CSV, 8 recurring series [Step 2] Took the first invoice of each series as its reference price [Step 3] Checking 2026-10 against that reference, not against the month before R0075 2026-10-01 Analytics Subscription 450 ⚠ no use confirmed for 569 days (last 2025-04-10) · no owner named R0074 2026-10-01 Cleaning Service 1,093 ⚠ +9.3% since 2026-01 (1,000 -> 1,093) · largest single step +3.0% [Step 4] 2 of 8 series flagged [Step 5] A month-to-month check at 5% would have flagged 0 of 8 [Step 6] Nothing is cancelled or sent — a person looks at each flag

5 — Change the threshold

# drift check only python recurring_invoice_agent.py data/recurring_invoices.csv --signals drift [Step 4] 1 of 8 series flagged # a very loose drift threshold, drift check only python recurring_invoice_agent.py data/recurring_invoices.csv --drift 20 --signals drift [Step 4] 0 of 8 series flagged

What it's made of

Data source

A plain CSV of recurring invoices — no ERP, no contract database, nothing beyond sample data.

Calculation

Standard Python, no external dependencies — a first-invoice reference, a percentage change and an idle-days count.

Configurable

The drift threshold, the step threshold, the idle days and which signals to use are command-line arguments, not hardcoded.

Read-only by design

The script only reads and reports. It doesn't cancel, dispute or send anything, and it is not a substitute for the controls an organisation already has.

What's in the repository

The same personal, non-commercial repository as the earlier demos in this series:

View on GitHub Back to Post #21

Follow the series

Post #22 looks at the invoice that arrives without an order: a cost that nobody ordered, nobody owns, and that is paid anyway because the invoice is correct.

Subscribe free
No spam. One post per week. Unsubscribe any time.