← All work

BUILDZN / WORK

Invoice to cash agent

Match synthetic invoices and bank lines, retain exceptions, and prepare reminders that require approval.

TypeScriptNode.jsPostgreSQLDocker ComposeGitHub Actions
Conceptual illustration of invoices matched with payment tokens and a reminder hourglass
Project illustration. All project data is synthetic.

Synthetic data. This is a portfolio implementation with recorded command line runs. No customer data, paid model calls or hosting deployment were used.

Tests and demos use a deterministic mock provider. A Claude adapter sits behind the same interface; its live quality remains unmeasured.

Problem

Partial payments, duplicate bank lines and missing references make an invoice balance hard to trust. A reminder also needs to survive worker restarts without being delivered twice.

Architecture

  1. 1. Import and reconcile

    PostgreSQL stores invoices, bank lines and allocations. Integer minor units preserve balances; ambiguous references go to review.

  2. 2. Persist the workflow

    Day-14 reminder jobs and completed steps remain in the database. A polling worker resumes pending work after restart.

  3. 3. Prepare and review

    A mock or Claude provider drafts text. Customer history adds an escalation record. A trusted operator approves the current balance and draft.

  4. 4. Dispatch atomically

    A transactional demonstration mailbox shares its commit with the delivery checkpoint. Retries cannot create another mailbox entry.

Tradeoffs

  • Reconciliation locks all invoices in a stable order. This is easy to inspect and test, but limits throughput.
  • The transactional mailbox proves local delivery idempotency. A real email transport would need its own durable idempotency contract.

Test results

39 distinct test cases passed in at least one appropriate environment. Zero failures in the linked CI run.

Actual results from the linked GitHub Actions run
EnvironmentPassedSkipped
Native PostgreSQL381
Embedded PostgreSQL372

The embedded disk-reopen test runs only on the embedded engine. The two process-kill tests run only on native PostgreSQL. Both native process-kill tests passed.

Both native process-kill tests passed: reconciliation and reminder delivery rolled back and resumed without duplicate delivery.

Docker Compose built and ran the seeded demo from a fresh Actions checkout. These fixture measurements do not establish production accuracy, security certification or business outcomes.

Verified code: d3e973044a42f6f374a0f7a7882b49a0b5b1f09b

Recorded demo output

Real stdout from the Docker demo in the linked CI run. All records, identities and messages are synthetic.

All data synthetic. Transport: transactional demo mailbox.
Invoice 10000 USD minor units. Partial payment 4000. Remaining: 6000
Dry run: dry-run
Approved delivery: delivered
Retry: delivered
Mailbox records: 1
Persisted steps: [
  { job: 'reminder:demo-invoice', name: 'delivered' },
  { job: 'reminder:demo-invoice', name: 'drafted' },
  { job: 'reminder:demo-invoice', name: 'escalated' }
]
Read the recorded output in the repository ↗

Known limits

  • No bank integration, currency conversion, public authentication or real email delivery.
  • The Claude adapter is implemented but live model quality was not measured.
  • Approval uses a trusted local operator identity. This is a CLI showcase.
Read policy and implementation assumptions ↗
Back to portfolio