# Purchase orders

> Raise a purchase order with lines, an account and an item each, route it for approval when you want, e-mail it to the supplier as a PDF, mark it open or billed, cancel it, and convert one or many into a bill. The PO number flows to the bill and to the supplier's e-invoice order reference (BT-13), so a received Peppol bill links to its order by itself.

Source: /help/en/bills/purchase-orders

A **purchase order** is what you agreed to buy from a supplier before the bill arrives: the lines, quantities and prices, the cost account each line will take, and the expected delivery. In Alya Books it lives next to [bills](/help/en/bills/record-and-approve-a-bill) under **Purchase Orders** in the menu. It posts nothing to the ledger: the bill does, when it is accepted. The order's job is to carry a number the supplier quotes back, so the bill can be matched to what was ordered, and to keep the order open until it is billed.

## Raise an order

**Purchase Orders → New purchase order.**

1. **Supplier.** Pick the contact (its TRN, e-mail and default currency are taken over) or type a name. Choose the order date, the expected delivery date and the currency; a foreign currency takes an exchange rate for the estimate.
2. **Lines.** Each line has a description, a quantity with its unit, a unit price, the VAT category and rate (VAT is estimated on standard-rated lines only), the **cost account** the bill line will take (without one, the supplier's default expense account, else the purchases account), an optional **item** from the catalogue (the picker fills the description, unit, price and VAT) and an expected date of its own. Drag the handle to reorder lines.
3. **Save as draft** keeps it editable; **Save and mark open** records it as confirmed and waiting for the bill. The number comes from the **purchase_order** series (`PO-0001`, `PO-0002`, …; the template is yours to change under Settings → Documents → Numbering).
4. **Reference**, **Deliver to** and **Notes to the supplier** print on the PDF.

The order page shows its status (**Draft**, **Sent**, **Open**, **Partially billed**, **Billed**, **Cancelled**), the bills linked to it and how much of it is billed. Its header shows the next step: **Send to supplier** for a draft, **Mark open** once sent, then **Convert to bill**; the other actions are under **More**. The page shows the order and all its cards at once; select **Tabs** in the header to see the cards as icon tabs instead, and **All in one** to switch back (the choice is remembered in this browser for every document page).

## Approval (optional)

An order can be routed to approvers before it goes out, with the same approvers as bills: the supplier's own approvers (level 1, from the contact) and the organisation's default levels (Settings → Accounting → Bill approvals), or the people you name on the **Approval** card. Nothing routes an order by itself; you ask when you want a second pair of eyes. While the request is pending the order is neither sent, marked open nor converted (`po_awaiting_approval`); after a decline it waits for a new request (`po_approval_declined`). Approvers decide in the **Approvals** inbox.

## Send it to the supplier

**Preview** shows the PDF the supplier receives (the purchase order layout: supplier block, order details, lines and totals, delivery address and notes, in the order's language). **Download PDF** saves it; without a PDF service the printable page opens instead. **Send to supplier** e-mails the PDF with the **Purchase order** e-mail template (Settings → Documents → E-mail templates, English or Arabic), to the supplier's e-mail by default; a draft becomes **Sent** and the delivery is logged on the page. **More** → **Mark as sent** records an order handed over outside the app. **Mark open** confirms an order with the supplier without sending it again (in the header once the order is sent, under **More** for a draft).

The e-mail asks the supplier to quote the PO number on their tax invoice. That is the point: it comes back in **BT-13**, the order reference of their e-invoice.

## From order to bill

There are three ways an order is billed, and all three end with the bill naming the order. The order shows **Billed** at once for a bill you record or convert, and once you accept it for a bill that arrived.

- **Convert to bill.** On the order page, or after selecting several orders on the list, **Convert to bill** makes **one draft bill** from one or many orders of the same supplier and currency: every unbilled line becomes a bill line naming its order line (quantity, price, VAT, account), the bill carries the order numbers as its order reference and origin **Purchase order**, and you may enter the supplier's bill number and dates, or accept the bill at once so it [posts](/help/en/bills/record-and-approve-a-bill) immediately. The bill is then reviewed, accepted and [paid](/help/en/bills/pay-bills-and-remittance-advice) like any bill.
- **The supplier's e-invoice arrives with the PO number.** A bill received over Peppol (or by e-mail or upload) whose order reference (BT-13) equals the number of a sent, open or partially billed order **of the same supplier** (the contact, else the TRN) is linked on import, without any step on your side: the bill page shows **From purchase order** with a link and the order lists the bill. The order keeps its status while that bill is a draft or in review, and shows **Billed** once you accept it. A credit note quoting the number is never linked; a reference that names no order of that supplier leaves the bill unlinked, and correcting the reference during review links it.
- **Link by hand.** A bill recorded here or received without the reference offers **Link to purchase order** on the bill page, listing the supplier's billable orders; **Unlink** undoes it (a converted bill stays linked).

## Partially billed, billed, open again

The order's status follows its bills, never the other way round. A bill line that names an order line counts towards that line's **billed quantity**; when every line is fully billed the order is **Billed**, when some are it is **Partially billed**. A received bill linked at the head bills the whole order once you accept it: a bill that arrived (by upload, e-mail, the network, the API, a mailbox or file source, or the supplier portal) does not count while it is a draft or in review, so nothing closes an order before a person has decided. A bill you recorded yourself, or converted from the order, counts from its draft. Only bills that are neither rejected nor voided count: **void** a bill and the order is open again for the next one. Converting a partially billed order bills the remaining quantities; correct the quantity on a draft bill line when the supplier delivered less, and the order shows it. **More** → **Mark billed** closes an order by hand when nothing more is expected; it stays billed whatever its lines say.

A draft is **deleted**; anything else is **cancelled** with a reason (**More** → **Cancel order**), which also cancels a pending approval request. An order with a bill that counts toward it is not cancelled (`po_billed`): void or unlink the bill first. An order that reads open because the only bill naming it is a received one nobody has accepted yet (a draft or one in review) is not cancelled either, and the message names the bill (`po_bill_waiting`): reject the bill, or open it and take the order off it (**Unlink** beside the order on the bill), then cancel the order. A received bill that quotes the order number stays unlinked once you take the order off it. A billed or cancelled order changes notes, reference and expected date only.

## What the supplier sees

When the supplier portal is on and a person of the supplier is invited (see [The supplier portal](/help/en/portal/supplier-portal)), that person reads the supplier's orders under **Purchase orders** in the portal:

- **Which orders.** Every order once it is sent: **Sent**, **Open**, **Partly billed** and **Billed**. A draft, a cancelled order and an order whose approval is still waiting or was declined never appear.
- **What of an order.** The issue and expected dates, the reference, the delivery address, the notes, each line with what was ordered and what is billed (*3 of 10 billed*), the unit price and the net, and the totals. **Download PDF** gives the same PDF you email. The cost account, the item and the approval never show.
- **The bills against it.** Each bill linked to the order, with its status as the supplier may know it (**Received**, **In review**, **Accepted**, **Rejected**) and, once accepted, whether it is paid.
- **Upload a bill.** While the order can still be billed, the supplier uploads its bill against it from the order's page. The bill arrives under **Incoming Invoices** as a draft (**To review**) that names the order, with the line **Uploaded by the supplier in the portal**; nothing accepts it by itself, and it bills the order once you accept it, as any bill that arrived does. A fully billed order reads *This order is fully billed: no further bill can be uploaded against it.*

## API and MCP

- `GET /purchase-orders?status=billable` lists orders with their lines, billed quantities and bills; `POST /purchase-orders` creates one (`PurchaseOrderInput`: supplier, dates, currency, lines with `accountId`, `itemId`, `expectedDate`); `PATCH /purchase-orders/{id}` edits (lines replaced, keep `id` on a kept line); `DELETE` removes a draft; `POST /purchase-orders/{id}/send` e-mails the PDF (`preview: true` composes only); `GET /purchase-orders/{id}/pdf`; `POST …/open`, `…/close`, `…/cancel`; `POST` and `DELETE …/approval`; `POST /purchase-orders/convert { ids, invoiceNumber, issueDate, dueDate, status }` makes the bill; `POST /bills/{id}/purchase-order { purchaseOrderId }` links by hand. Bills carry `purchaseOrderId`.
- MCP: `create_purchase_order`, `list_purchase_orders`, `get_purchase_order`, `send_purchase_order`, `cancel_purchase_order`, `convert_purchase_orders_to_bill`, `request_purchase_order_approval`; `list_approvals` and `decide_approvals` cover the approval.
- Refusals: `po_not_billable` (a draft or cancelled order), `po_awaiting_approval`, `po_approval_declined`, `po_approvers_missing`, `contact_mismatch` and `currency_mismatch` (orders of different suppliers or currencies in one bill, or a bill linked to another supplier's order), `nothing_to_bill`, `po_billed`, `po_not_editable`, `po_line_billed`, `duplicate_po_number`.

The audit log records `purchase_order.created`, `.updated`, `.sent`, `.opened`, `.closed`, `.cancelled`, `.converted` and `bill.po_linked` / `bill.po_unlinked`.
