A small Python script that validates supplier invoices by independently recalculating the total from line items and VAT, and comparing it against the invoice's stated total.
Built as a learning exercise translating validation logic originally built in n8n (see the AI Invoice Processing System project) into plain Python, reusable as a function across multiple invoices.
Given a list of line item amounts, a VAT amount, and a stated total, validate_invoice() returns whether the numbers actually add up, catching cases where a stated total doesn't match what the line items and VAT actually sum to.
Two invoices are checked: one where the totals correctly match, and one with a deliberate 70ドル.55 discrepancy between the stated total and the real sum, to confirm the validation logic actually catches a mismatch.