Repository navigation
API: read, code and check invoices, post to MYOB with safe retries - #1
Merged
Merged
Conversation
Fictional Australian suppliers a coffee roaster deals with: green coffee (GST-free beans, taxable freight), dairy, packaging, freight with a mistyped ABN, an espresso machine repair with a capital item, and a crooked phone photo of a receipt. Rendered from HTML with Chrome so they can be regenerated. Phone numbers use the 02 5550 range ACMA reserves for fiction.
…enAI - docintel: prebuilt-invoice over REST, polling, and mapping to the app's shape, keeping each field's confidence and bounding polygon. Cleans vendor names that come back with logo text attached. - coding: chart of accounts, bookkeeping rules and the supplier's past codings in the prompt; strict JSON schema with account codes as an enum of active accounts. - checks: sums, GST against tax codes, ABN checksum, dates, duplicates, closed accounts and low-confidence reads, in plain tested code. - Tests use real Document Intelligence responses as fixtures.
MYOB has no idempotency keys, so a timed-out POST may have created the bill. The worker marks such attempts uncertain and searches MYOB by supplier invoice number before posting again. Rate limits (403 Developer Over Qps) and 503s back off with jitter; 400s stop and go back to a person. The simulated AccountRight API follows MYOB's shapes (Location headers, OData filters, error bodies) and can be flaky or drop responses after saving. The client takes a transport, so the real API is a configuration change. Reconciliation compares posted invoices with the company file and reports duplicates, edited amounts, deleted bills and manual entries.
- Hono app: upload, extract, code, review, approve, post, sync log, reconcile, settings for the failure modes, and a cron endpoint. - Each visitor gets a workspace seeded with a month of history. The seed comes from running the real pipeline over past invoices once (scripts/build-seed.ts), not hand-written numbers. - Free-tier guards: per-visitor and daily rate limits, and extraction results cached by file hash. - esbuild bundles the API into one file for Azure Functions. - Integration test: lost responses with and without the duplicate guard, and MYOB rejecting a closed account, against Postgres.
Integration tests run against a dedicated Neon branch.
… the mock On CI the mock's own database round trips could exceed the 2.5 s client timeout, so an unguarded retry posted a third bill. CI now waits 8 s, and the mock loads accounts and tax codes once.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
The whole back end, from an uploaded PDF to a bill in MYOB.
prebuilt-invoice) over REST. Fields keep their confidence and bounding polygon, so the UI can show where each value came from.sync_jobs) with backoff. A timeout is treated as "maybe it worked": the next attempt looks the bill up by supplier invoice number before posting again, because MYOB has no idempotency keys.Decisions
403 Developer Over Qps, so the client classifies 403s by body rather than treating them as auth failures.api/scripts/build-seed.ts), not invented numbers.Testing