# registerAccountReceivableDocument

## Overview

Registers a DRAFT customer invoice, transitioning the `AccountReceivableDocument` from DRAFT to REGISTERED. Unlike the AP side there is no 3-way matching and no holds on AR: registration validates that the document has a non-empty due schedule summing to the document total and that the line and distribution totals reconcile, then moves the document forward. For `SALES_ORDER`-sourced lines the linked sales order's billing status is recalculated in the same transaction. Registration always succeeds when validation passes — there is no hold mechanism that blocks it.

## Modules Commands Used

- [account-receivable] registerAccountReceivableDocument

## Exception Handling

| Error Code | Description |
| --- | --- |
| ACCOUNT_RECEIVABLE_DOCUMENT_NOT_FOUND | No account receivable document exists for the given ID. |
| ACCOUNT_RECEIVABLE_INVALID_DOCUMENT_STATUS | The document is not in DRAFT status; only DRAFT documents can be registered. |
| ACCOUNT_RECEIVABLE_DUE_SCHEDULE_INVALID | The due schedule does not reconcile with the document total. |
| ACCOUNT_RECEIVABLE_LINE_TOTAL_MISMATCH | The sum of line amounts does not reconcile with the document total. |
| ACCOUNT_RECEIVABLE_MINIMUM_LINES_NOT_MET | The document has no lines to register. |
| ACCOUNT_RECEIVABLE_SALES_ORDER_BILLING_SYNC_FAILED | The linked sales order's billing status could not be recalculated. |
