# registerAccountPayableDocument

## Overview

Registers a DRAFT vendor invoice, transitioning the `AccountPayableDocument` from DRAFT to REGISTERED. Registration is where **3-way matching** runs: for each `PURCHASE_ORDER`-sourced line, the invoiced quantity and price are reconciled against the linked PO's ordered quantity/price and the posted received quantity, applying any supplier `InvoiceToleranceConfig`. Variances raise SYSTEM `AccountPayableDocumentHold` rows. **Registration still succeeds when holds are placed** — holds block posting to the general ledger, not registration. Registration also recalculates the linked `PurchaseOrder`'s `billingStatus`. Manual (amount-only) lines carry no source and are never matched.

## Modules Commands Used

- [account-payable] registerAccountPayableDocument

## Exception Handling

| Error Code | Description |
| --- | --- |
| ACCOUNT_PAYABLE_AP_DOCUMENT_NOT_FOUND | No account payable document exists for the given ID. |
| ACCOUNT_PAYABLE_AP_INVALID_DOCUMENT_STATUS | The document is not in DRAFT status; only DRAFT documents can be registered. |
| ACCOUNT_PAYABLE_AP_DUE_SCHEDULE_INVALID | The due schedule does not reconcile with the document total. |
| ACCOUNT_PAYABLE_AP_LINE_TOTAL_MISMATCH | The sum of line amounts does not reconcile with the document total. |
| ACCOUNT_PAYABLE_AP_MINIMUM_LINES_NOT_MET | The document has no lines to register. |
| ACCOUNT_PAYABLE_AP_PURCHASE_ORDER_BILLING_SYNC_FAILED | The linked purchase order's billing status could not be recalculated. |
