Workflow and records
Six steps from purchase order to payment. Each step names who acts, what starts it, what it does, how it ends, and the records it owns. A record has exactly one owning step; other steps and other modules only read it or hand it postings.
- ST-1Buyer, then an approver by amount
Raise and approve the purchase order
The buyer creates the order. It routes for approval by order total, then is sent to the vendor.
- Starts
- A replenishment need or an approved request.
- Ends
- Order approved and sent.
- ST-2Receiver
Receive the goods
The receiver counts what arrived and posts it against the open order lines. Stock and the receipt accrual post in the same transaction.
- Starts
- A delivery arrives at the dock with a packing slip.
- Ends
- Lines received in full, or in part with the rest left open.
- ST-3AP clerk
Capture the invoice and check for duplicates
The clerk keys the header and lines against the order. The duplicate check runs before the invoice can be saved as payable.
- Starts
- An invoice arrives by mail, email or the vendor portal.
- Ends
- Invoice accepted for matching, held as a possible duplicate, or blocked.
- ST-4System
Three-way match
Each invoice line is compared with its order line (price) and the receipts so far (quantity). Lines outside tolerance open a hold with the exact variance.
- Starts
- An invoice is accepted, or a receipt, order change or credit memo touches a held invoice's order.
- Ends
- Matched, or on hold with an owner.
- ST-5System, or the AP lead after an override
Approve for payment
A clean match approves itself for payment. The due date comes from the vendor's terms and the invoice date.
- Starts
- The invoice has no open holds.
- Ends
- Approved, with a due date.
- ST-6AP lead proposes, Treasury releases
Pay
The AP lead proposes a payment run. Treasury reviews and releases it; the bank file and remittance go out.
- Starts
- Approved invoices fall due within the run window.
- Ends
- Paid, with remittance sent to the vendor.
State diagrams
Every state an order or invoice can be in, and every way between them. Numbers match the table; the rule column links to the rule that governs the move. Both diagrams are generated from spec/workflow.yaml, with editable Mermaid sources.
Purchase order
Mermaid source| # | From | To | When | Rule |
|---|---|---|---|---|
| 1 | Draft | Pending approval | submit | |
| 2 | Pending approval | Approved | approve | BR-02 |
| 3 | Pending approval | Cancelled | reject | |
| 4 | Approved | Pending approval | material change | BR-03 |
| 5 | Approved | Partially received | partial receipt | |
| 6 | Partially received | Received | rest received | |
| 7 | Approved | Received | full receipt | |
| 8 | Partially received | Closed short | close short | BR-06 |
| 9 | Received | Closed | fully billed | |
| 10 | Closed short | Closed | billed to received |
Vendor invoice
Mermaid source| # | From | To | When | Rule |
|---|---|---|---|---|
| 1 | Captured | Duplicate check | save | |
| 2 | Duplicate check | Matching | unique | |
| 3 | Duplicate check | Blocked duplicate | exact match | BR-08 |
| 4 | Duplicate check | Possible duplicate | near match | BR-09 |
| 5 | Possible duplicate | Matching | AP lead clears | |
| 6 | Matching | Matched | within tolerance | |
| 7 | Matching | On hold | outside (BR-10 | BR-10 |
| 8 | On hold | Matching | re-match | BR-12 |
| 9 | On hold | Rejected | vendor reissues | |
| 10 | Matched | Approved for payment | auto | BR-13 |
| 11 | Approved for payment | Paid | run released | BR-14 |
Records
The records this workflow owns, with their key fields. The audit entry is owned by the platform and written by every step.
| Record | Owned by | Key fields |
|---|---|---|
| Purchase order | ST-1 | po_no, vendor_id, buyer_id, terms, currency, total, revision, status |
| Order line | ST-1 | po_no, line_no, item_id, qty_ordered, unit_price, qty_received, qty_billed, qty_closed_short, status |
| Approval record | ST-1 | document, revision, tier, approver_id, decision, decided_at |
| Goods receipt | ST-2 | gr_no, po_no, packing_slip, received_by, received_at |
| Receipt line | ST-2 | gr_no, po_line, qty, location, lot |
| Vendor invoice | ST-3 | inv_id, vendor_id, vendor_invoice_no, normalized_no, invoice_date, gross_amount, status, captured_by |
| Invoice line | ST-3 | inv_id, line_no, po_line, qty_billed, unit_price, amount |
| Duplicate check | ST-3 | inv_id, rule, matched_inv_id, outcome, checked_at |
| Match result | ST-4 | inv_line, qty_variance, price_variance, variance_pct, outcome |
| Hold | ST-4 | hold_id, inv_id, type, opened_at, owner_role, released_at, released_by, reason |
| Payment approval | ST-5 | inv_id, approved_by, approved_at, due_date, override |
| Payment run | ST-6 | run_id, proposed_by, released_by, second_approver, total, status |
| Payment | ST-6 | pay_id, run_id, vendor_id, amount, method, invoice_ids |
| Audit entry | every step | entity, entity_id, from_state, to_state, actor, at, reason |