# Vendor Invoice — Models & Action Visibility Matrix

## Models Involved

Source of truth: `@tailor-platform/erp-kit` v0.17.0 (see `package.json`).

| Model | erp-kit model | Role in this flow |
|---|---|---|
| AccountPayableDocument | `AccountPayableDocument` | Invoice header; owns `status`, `documentType`, supplier, currency, document date |
| AccountPayableDocumentLine | (see AccountPayableDocument) | Per-line amount; `PURCHASE_ORDER`-sourced lines are matched, manual (amount-only) lines are not |
| AccountPayableDocumentHold | (see AccountPayableDocument) | Variance hold raised by matching (SYSTEM) or manually (MANUAL); blocks posting |
| PurchaseOrder / PurchaseOrderLine | `PurchaseOrder` | Optional backing order; registration advances `billingStatus` |
| Account | `Account` | Payable control account (LIABILITY) and distribution account (non-liability) |
| BusinessPartner | (supplier docs) | Supplier reference; source of preferred currency and company |

### Status Axis

| Field | Values |
|---|---|
| `status` | `DRAFT` → `REGISTERED` → `POSTED` \| `CANCELLED` |
| `documentType` | `INVOICE` (this template) \| `CREDIT_MEMO` (native, not created here) |

Native transitions are `register`, `post`, `cancelDraft`, and `cancelRegistered`. **This template exposes create + register + release-hold only; `post` (posting to the general ledger) is out of scope.** The state machine is owned by the native erp-kit `AccountPayableDocument` model.

## Action Visibility Matrix

The `invoice-detail` screen's action panel gates buttons on the document's `status` plus, for hold release, the presence of active holds.

Legend: ✓ visible+enabled · ◐ visible but disabled · blank = hidden.

| Action | Resolver / target | DRAFT | REGISTERED | POSTED | CANCELLED | Extra condition | Role |
|---|---|:-:|:-:|:-:|:-:|---|---|
| Register | `registerAccountPayableDocument` | ✓ |  |  |  | — | purchaser |
| Release Hold | `releaseAccountPayableDocumentHold` | ✓ | ✓ |  |  | one action per active hold | purchaser |
| Back to Invoices | _navigate to list_ | ✓ | ✓ | ✓ | ✓ | — | — |
