---
title: "The document chain | Docs | ERP by R&D Copilot"
description: "How a sales order, a purchase order and a work order lead to their documents, and which operation creates each one."
canonical: "https://erp.rdcopilot.com/docs/concepts/the-document-chain/"
language: en
updated: 2026-11-22
---

# The document chain

How a sales order, a purchase order and a work order lead to their documents, and which operation creates each one.

Nothing is typed twice. Each document is made from the one before it, carries a link to it, and takes its numbers and amounts from it.

## Selling

| Document | Operation | Number looks like | Made from |
| --- | --- | --- | --- |
| Sales order | `createSalesOrder` | `CV-1048` | A customer and lines |
| Delivery | `createDelivery` | `LIV-2026-01844` | A `reserved` sales order |
| Invoice | `createInvoice` | `FCT-2026-00419` | A `delivered` sales order |

The order links forward: `deliveryId`, `deliveryNumber`, `invoiceId` and `invoiceNumber` are filled when those documents exist. Payments belong to the invoice and are recorded with `recordInvoicePayment`.

## Buying

| Document | Operation | Number looks like | Made from |
| --- | --- | --- | --- |
| Purchase order | `createPurchaseOrder` | `CA-0732` | A supplier and lines with agreed prices |
| Receipt | `createReceipt` | `RE-0459` | A purchase order and the quantities that arrived |
| Supplier bill | `createSupplierBill` | `FF-0608` | A purchase order and what the supplier bills |

A supplier bill is compared with its order and the receipts of that order; see [Match a supplier bill](https://erp.rdcopilot.com/docs/guides/match-a-supplier-bill/). A receipt adds the units to stock at once.

## Making

| Document | Operation | Number looks like | Made from |
| --- | --- | --- | --- |
| Work order | `createWorkOrder` | `OP-0214` | A made item and a quantity |

Finishing a work order takes the components of its bill of materials out of stock and adds the made items. See [Run a work order](https://erp.rdcopilot.com/docs/guides/run-a-work-order/).

## One change, one event

Every operation that changes a record sends exactly one event, named after the record and what happened to it. The [Event catalogue](https://erp.rdcopilot.com/docs/events/event-catalogue/) lists them all.
