Case files / PAN-074

PAN-074In flight

A back office that audits itself

A micro-ERP for small South African businesses: orders, a till, stock, double-entry books, VAT, payroll and SARS preparation in one database. One AI agent built it in about two weeks, with one person operating it. It runs on a single box with test data, and no tax practitioner has checked the tax rules.

Control flow

  1. Capture: order, counter sale or booking
  2. Fulfil: packing check deducts stock
  3. Invoice: numbered, VAT posted
  4. Reconcile: the matcher suggests, a person confirms
  5. Pay: payroll run, payslips, returns
  6. Close: month-end journal and summary

Industry: Small business · Stack: Next.js 16 · TypeScript · PostgreSQL 16 · Prisma · AWS · Seed species: Abacus

Problem

A business of two to twenty people runs its orders, stock, books, tax and payroll in four tools that do not agree with each other. The question here was narrower and harder: can one AI agent build the whole back office, and then tell the truth about it.

How it works

Orders, counter sales and bookings are captured once. A packing check deducts stock. Invoices are numbered without gaps and post VAT. A bank matcher suggests matches with a confidence score and a plain reason; only an administrator can confirm one, and nothing posts until they do. Payroll runs go from draft to approved to paid. Month end closes with a journal and a summary.

Tax tables are versioned by tax year and expire. Approving payroll on expired tables needs an acknowledgement, which is logged.

Method

The building agent also wrote the audit, as the defendant’s own statement of the case: known weaknesses first, and one of its own findings retracted as a harness error. A ledger invariant script checks that every batch balances, that receivables equal outstanding invoices, that invoice numbers have no gaps, and that twenty simultaneous allocations come out distinct. The audit says plainly that this is a data checker, not a test suite.

The box has no SSH; shell access is through SSM only. A point-in-time restore drill landed between two markers 43 seconds apart.

What broke

The deploy script traced its own environment load, so every deploy wrote the database password, session secret and encryption key into a log any user on the box could read.

During a simulation the agent hard-deleted an invoice with SQL. The ledger still balanced, pointing at nothing, and receivables broke without an error. Ledger keys now refuse the delete.

Goods receipts once claimed no input VAT at all: about R61,000 unclaimed in one simulated period.

Limitations

Stated by the audit itself: the bus factor is one AI agent; no person has reviewed the code; it runs on one box; there is no automated test suite; email has never been delivered. Commission PAYE is knowingly wrong for monthly commission, by about R11,000 a year across three staff in the test case, and it is not fixed.

Next

A practitioner review of payroll, production mail access, and a full rebuild from the backup bucket alone.

Open the living case file