Post #16 Companion — The CFO & AI Series

The Script That Knows What a Normal Week
Looks Like

A small script that checks each payment against its own supplier's history and prints the ones that look different — with the reason, before anyone approves the run.

Boris Dračka · October 2026 · Companion demo

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

Post #16 argued that an odd payment only stands out against a normal one. Below is a small prototype that builds that normal from sample data and checks one week against it.

42
Sample payments checked
1
Flagged for a second look
3.4×
Flagged amount against the supplier's usual

The script doesn't decide whether a payment is fine. It writes down, in one place, what each supplier's own history says is normal, and shows where this week disagrees.

The sample data

Eighteen made-up suppliers, nine weeks of payments, and one week to check. For each supplier the script builds a baseline from the earlier weeks: the usual amount and spread, the usual weekday and the accounts it has used.

  payments.csv — sample data, six of eighteen suppliers
SupplierUsual amountUsual dayThis weekResult
Raw Materials Supplier≈ 18,262Tue3 paymentsIn band
Freight Carrier≈ 2,853Thu4 paymentsIn band
Maintenance Contractor≈ 4,214Tue2 paymentsFlagged
Software Platform2,400 (fixed)Tue1 paymentIn band
Courier Services≈ 415Thu4 paymentsIn band
Insurance Broker5,200 (fixed)Thu1 paymentIn band

How it works

1
Load the paymentsReads a CSV with one row per payment: id, date, supplier, amount, account.
2
Build a baseline per supplierFrom the payments before the week: median amount, a robust spread, the usual weekday, the known accounts.
3
Check the weekEach payment is compared with its own supplier's baseline, not with a global limit.
4
Flag and explainAn amount outside the band, a repeated amount or a new account flags a payment. An unusual weekday is shown as context only.
5
Print the resultLists each flagged payment with its reasons. Nothing is blocked, held 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 payments (optional)

id,date,supplier,amount,account P0004,2026-08-04,Packaging Supplier,6581,ACC-PAC1 P0349,2026-10-02,Maintenance Contractor,14400,ACC-MAI2 # ...add as many rows as you have payments; keep a few weeks of history before the week you check

3 — Run it

python anomaly_watch_agent.py data/payments.csv

4 — Read the output

================================================================ Anomaly Watch Agent — Unusual Payment Check ================================================================ [Step 1] Loaded 378 payment(s) from CSV [Step 2] Built a baseline per supplier from 336 payment(s) before 2026-09-28 [Step 3] Checking 42 payment(s) in the week of 2026-09-28 against each supplier's own history P0349 2026-10-02 Fri Maintenance Contractor 14,400 ⚠ amount 3.4x usual (4,214 +/- 261) · new account for this supplier · usual day Tue [Step 4] 1 of 42 payment(s) flagged [Step 5] Nothing is blocked or sent — a person looks at each flag

5 — Change the tolerance

# a tight band, amount check only python anomaly_watch_agent.py data/payments.csv --tolerance 1.5 --signals amount [Step 4] 9 of 42 payment(s) flagged # a very loose band, amount check only python anomaly_watch_agent.py data/payments.csv --tolerance 60 --signals amount [Step 4] 0 of 42 payment(s) flagged

What it's made of

Data source

A plain CSV of payments — no bank connection, no ERP, nothing beyond sample data.

Calculation

Standard Python, no external dependencies — a median, a robust spread and three checks.

Configurable

The tolerance, the repeat window and which signals to use are command-line arguments, not hardcoded.

Read-only by design

The script only reads and reports. It doesn't hold, block or send a single payment, 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 #16

Follow the series

Post #17 looks at a different blind spot: the margin on a single product or customer, and how it can turn negative without anyone seeing it in the monthly average.

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