# invoice-create-form

## Overview

Creates a vendor invoice in DRAFT status. The form opens with an invoice-type toggle — "What is this invoice for?" — offering two modes:

- **Purchase Order invoice (matched to a PO)** — links the invoice to an existing ORDERED purchase order. Lines are derived from the PO and shown read-only. Submitting invokes the [createAccountPayableDocument](../resolver/createAccountPayableDocument.md) resolver.
- **Other invoice (no PO — freight, fees, adjustments)** — captures a standalone invoice not tied to a PO. The user selects a supplier and enters manual lines. Submitting invokes the [createAccountPayableDocument](../resolver/createAccountPayableDocument.md) resolver with amount-only lines.

## Screen Type

Form

### Form Details

#### Input Fields

**Invoice-Type Toggle:** A control at the top of the form ("What is this invoice for?") with two options: "Purchase Order invoice (matched to a PO)" and "Other invoice (no PO — freight, fees, adjustments)". Switching modes resets the mode-specific fields.

**PO mode:**

| Field Name | Field Type | Required (Yes/No) | Options / Lookup |
| --- | --- | --- | --- |
| Purchase Order | Combobox (searchable by supplier name / PO number) | Yes | PurchaseOrder lookup — ORDERED POs only |

On PO selection, a **read-only preview of lines** derived from the PO is shown (item description, quantity, unit price, amount). The supplier is derived from the PO.

**Other mode:**

| Field Name | Field Type | Required (Yes/No) | Options / Lookup |
| --- | --- | --- | --- |
| Supplier | Combobox (searchable by name) | Yes | SupplierAccount lookup; selecting it prefills the distribution account from `defaultExpenseAccountId` when configured |

**Manual lines (Other mode only):** A line editor with add/remove rows.

| Field Name | Field Type | Required (Yes/No) | Options / Lookup | Description |
| --- | --- | --- | --- | --- |
| Description | text | Yes | — | Free-text line description |
| Amount | number | Yes | — | Line amount (must be positive) |

Rows can be added and removed. At least one line is required.

**Shared fields (both modes):**

| Field Name | Field Type | Required (Yes/No) | Options / Lookup |
| --- | --- | --- | --- |
| Payable Control Account | Combobox (searchable) | Yes | Account lookup — LIABILITY accounts only |
| Distribution Account | Combobox (searchable) | Yes | Account lookup — non-LIABILITY accounts; initially empty in Other mode, then prefilled from the selected supplier's default expense account when configured, and remains editable |
| Document Date | date | No | Defaults to today when omitted |
| Supplier Invoice # | text | No | `externalDocumentNumber` |

**Actions:**

- Create — submits the form; both modes call [createAccountPayableDocument](../resolver/createAccountPayableDocument.md) (PO mode derives `PURCHASE_ORDER`-sourced lines, Other mode sends amount-only lines).
- Cancel — discards and returns to previous screen.

## Access Control

- [purchaser](../actor/purchaser.md)
