# createManualAccountReceivableInvoice

## Overview

Creates a DRAFT customer invoice (an `AccountReceivableDocument` of `documentType` INVOICE) that is **not** tied to a sales order — used for services, fees, adjustments, and spot sales. The caller supplies the customer (business partner) directly and a set of amount-only lines (`description`, `amount`). Each line carries no source, quantity, unit price, or unit; each is booked in full to `distributionAccountId`. The header carries `receivableControlAccountId` as the receivable (asset) account. `companyId` is resolved from the customer's `companyId`. Currency is resolved from the customer's `preferredCurrencyId`, falling back to the company's `baseCurrencyId`. A one-line due schedule (the whole amount, due on the document date) is attached so the document can later be registered. When `documentDate` is omitted it defaults to today.

## Modules Commands Used

- [account-receivable] createAccountReceivableDocument

## Exception Handling

| Error Code | Description |
| --- | --- |
| ACCOUNT_RECEIVABLE_COMPANY_NOT_FOUND | The company resolved from the customer does not exist. |
| ACCOUNT_RECEIVABLE_BUSINESS_PARTNER_NOT_FOUND | The customer (business partner) does not exist. |
| ACCOUNT_RECEIVABLE_CURRENCY_NOT_FOUND | Neither the customer's preferred currency nor the company's base currency could be resolved. |
| ACCOUNT_RECEIVABLE_ACCOUNT_NOT_FOUND | The receivable control account or distribution account does not exist. |
| ACCOUNT_RECEIVABLE_ACCOUNT_INACTIVE | The receivable control account or distribution account is not ACTIVE. |
| ACCOUNT_RECEIVABLE_INVALID_AMOUNT | A line amount is invalid (e.g., non-positive). |
| ACCOUNT_RECEIVABLE_LINE_TOTAL_MISMATCH | The sum of line amounts does not reconcile with the document total. |
| ACCOUNT_RECEIVABLE_LINE_SOURCE_INCONSISTENT | A line's source references are inconsistent. |
| ACCOUNT_RECEIVABLE_DUE_SCHEDULE_INVALID | The attached due schedule does not reconcile with the document total. |
| ACCOUNT_RECEIVABLE_MINIMUM_LINES_NOT_MET | The document has no lines. |
