Skip to content

docs: accounts payable module page - #89

Merged
futurebuildai merged 2 commits into
refactor/v1from
refactor/docs-ap
Oct 10, 2026
Merged

futurebuildai merged 2 commits into
refactor/v1from
refactor/docs-ap

Conversation

@futurebuildai

Copy link
Copy Markdown
Contributor

docs: accounts payable module page

Adds docs/modules/ap.md for the AP module: the vendor bill (ApInvoice), the approve and void transitions, the vendor payment (ApPayment), the aging by vendor and the GL postings (2010 Accounts Payable, 1010 Cash). Lists the seven AP routes under /api/v1/ap, the bill and line fields, the lifecycle with its blockers (has_payments, entry_not_linked, entry_unbalanced, period_closed, account_missing, line_needs_account, invoice_not_approved, exceeds_open), the events the module writes (vendor_invoice.created, .approved, .partial, .paid, .voided), the admin/owner/finance role guard behind the branch wall and the stated limits from C4-1b (unlinked legacy bills stay approved and payable; across-branch payments show whole). Adds the page to docs/modules/README.md's module table and the ap segment to the convention block, and removes AP from the not-in-brief sentence.

Every sentence on the page traces to a row in the claims table below.

Claims table (rows A through M, source paths and the proof that backs each row): see /home/colton/Desktop/FBHQ/gable-v1/mm/docs-ap-claims.md (off repository).

The groups:

  • A. Routes: 7 AP routes; census rows in core/api/ROUTES.txt.
  • B. Bill fields: every property of ApVendorInvoice, ApVendorInvoiceSummary and ApVendorInvoiceLine.
  • C. Payment fields: ApPayment and the ApCreatePaymentRequest body.
  • D. Aging: ApAgingSummary bucket fields.
  • E. Lifecycle: statuses, edges in core/internal/ap/model.go:53-62, blockers has_payments, entry_not_linked, entry_unbalanced, invoice_not_approved, exceeds_open, plus the If-Match 428 / stale_revision 409 rule.
  • F. Posting failure blockers: period_closed, account_missing, entry_unbalanced, line_needs_account mapped in service.go.
  • G. Scopes and roles: scoped("admin", "owner", "finance") at serve.go:679; BranchGuard.CheckPayloadBranch for the payload branch_id.
  • H. Events the module writes: vendor_invoice.created, .approved, .partial, .paid, .voided from service.go:49-55; written in transaction per ADR 0003 section 2.
  • I. GL postings: approve builds entry from lines (pro rata tax, last line takes remainder, credit to 2010); pay entry is DR 2010 / CR 1010; void reverses through gl.PostReversal. Accounts AccountCodeAP = "2010" and AccountCodeCash = "1010".
  • J. Branch wall behaviour: list, get, transitions, payments list and aging all hold the wall; a payment spanning branches shows whole.
  • K. Stated limits: unlinked legacy bills stay approved and payable (no route links an entry to a bill today); bills with the removed sync's one leg unbalanced entry likewise.
  • L. Money ceilings: tax_cents, lines[i].unit_price_ten_thousandths, lines[i].quantity, lines subtotal, lines-and-tax together, amount_cents: all 999999999999 cents; unit_price 999999999999 ten-thousandths. Defined at input.go:261-265.
  • M. ADR rule sentences: ADR 0008 sections 7.4, 12 and 13; ADR 0001 sections 4, 6, 7, 7a, 9, 11 and 12; ADR 0007 section 5.5; ADR 0003 sections 1, 2, 3 and 5.

File changes:

  • docs/modules/ap.md: new page.
  • docs/modules/README.md: adds the Accounts payable row and the ap segment in the convention block; removes AP from the "not in the brief's list" sentence.

🤖 Generated with Claude Code

Adds docs/modules/ap.md for the AP module: the vendor bill (ApInvoice),
the approve and void transitions, the vendor payment (ApPayment), the
aging by vendor and the GL postings (2010 Accounts Payable, 1010 Cash).
Lists the seven AP routes under /api/v1/ap, the bill and line fields,
the lifecycle with its blockers (has_payments, entry_not_linked,
entry_unbalanced, period_closed, account_missing, line_needs_account,
invoice_not_approved, exceeds_open), the events the module writes
(vendor_invoice.created, .approved, .partial, .paid, .voided), the
admin/owner/finance role guard behind the branch wall and the stated
limits from C4-1b (unlinked legacy bills stay approved and payable;
across-branch payments show whole). Adds the page to
docs/modules/README.md's module table and the ap segment to the
convention block, and removes AP from the not-in-brief sentence.

Backed by docs/gable-v1/mm/docs-ap-claims.md: every sentence on the
page traces to a row in that table (routes, bill fields, payment
fields, statuses, blockers, role and scope checks, events, postings,
branch wall behaviour, money ceilings and the ADR rule sentences).

Migration 106 brought the AP tables onto the wire contract; C4-1b
(PR 78) owns the conversion. ADR 0008 sections 7.4 and 12-13 hold the
design; ADR 0001 sections 7, 7a, 9 and 11 hold the wire contract;
ADR 0007 section 5.5 holds the branch bound key rule the payload
branch_id applies.

Signed-off-by: colton <colton@futurebuild.ai>
Address the Sonnet 5.5 review for PR 89 (round 1):

P1-1 clarify that the payload branch rule applies to POST /ap/invoices
only; POST /ap/payments carries no branch_id and is held to the wall
through the bills it names via LockForPayment.

P2-1 an omitted currency is USD (Parse fills it in input.go); the
currency.default setting is not read on the create path.

P2-2 the id-order lock prevents deadlock and serialises payments on a
bill; repeats are caught by Idempotency-Key and the open amount check.

P2-3 remove the invented UI clause about the desk typing dollars.

P2-4 MarkVoided leaves gl_entry_id set; the bill rows agree.

P2-5 ApPaymentApplication is a storage row, not on the wire.

P3 notes: entry_not_linked reachable from approved only (a partial bill
is refused has_payments first); every route reads included is behind
scoped; name the field the AP code returns (branch_id); the approver
is the caller-given id; error envelope is ADR 0001 section 3; dev mode
needs no bearer; method is accepted case insensitively; remove 'Loader
has reviewed'; add the machine key role guard sentence from ADR 0002
section 4.

Claims table rows in mm/docs-ap-claims.md bind each change.

Signed-off-by: colton <colton@futurebuild.ai>
@futurebuildai
futurebuildai merged commit 488ea64 into refactor/v1 Oct 10, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant