# SalesOrder type


A sales order: a customer's order for goods, which MAX reserves stock for, ships and tracks
until it is paid and completed.

## Fields

### id

[`UUID!`](/chameleoon-max/type/uuid)

The order's MAX id.

### number

`String`

The order's number. Null while the order is a draft.

### status

[`SalesOrderStatus!`](/chameleoon-max/type/sales-order-status)

The order's status in its life cycle.

### legalEntityId

[`UUID`](/chameleoon-max/type/uuid)

The MAX id of the legal entity (the company) that sells. Null when the order has no legal entity.

### source

`String`

The code of the external source that placed the order. Null for an order created in MAX. Also
null, together with `externalId` and `externalNumber`, when your API key is limited to other
partners.

### externalId

`String`

The order's id in the external source.

### externalNumber

`String`

The order number the customer saw in the e-shop.

### sourceUrl

`String`

A link to the order in the e-shop's administration.

### orderedAt

[`Time!`](/chameleoon-max/type/time)

When the customer placed the order.

### confirmedAt

[`Time`](/chameleoon-max/type/time)

When the order was confirmed, on the MAX clock.

### fulfilmentStatus

[`SalesOrderFulfilmentStatus!`](/chameleoon-max/type/sales-order-fulfilment-status)

How much of the order has left the warehouse.

### paymentStatus

[`SalesOrderPaymentStatus!`](/chameleoon-max/type/sales-order-payment-status)

Whether the order is paid.

### currencyCode

`String!`

The ISO 4217 code of the order's currency.

### pricesIncludeVat

`Boolean`

Whether the order's prices include VAT, as its priced items say. If no item is priced, as its
charges other than `ROUNDING` say. Null when neither has a price.

### totalNet

[`Decimal!`](/chameleoon-max/type/decimal)

The amount owed without VAT, excluding cancelled quantities.

### totalVat

[`Decimal!`](/chameleoon-max/type/decimal)

The VAT on `totalNet`.

### totalGross

[`Decimal!`](/chameleoon-max/type/decimal)

The amount owed including VAT.

### paidAmount

[`Decimal!`](/chameleoon-max/type/decimal)

The amount the customer has paid, less refunds.

### discountPercent

[`Decimal`](/chameleoon-max/type/decimal)

The order-wide discount in percent, taken off every goods line after the line's own discount.
`lineTotal` and the totals already include it. Charges are not discounted. Null when there is
none.

### invoiceNumber

`String`

The number of the invoice that another system issued for this order
([`setSalesOrderInvoice`](/chameleoon-max/mutation/set-sales-order-invoice)). Null while there is none. A change of it is a transition
in the order's events (see `events`). `invoiceExternalId` is not tracked there, so a change of
it alone still publishes `sales_order.changed`, with no transition.

### invoiceExternalId

`String`

The invoice's id in the system that issued it. Null while there is none.

### vatTreatment

[`VatTreatment`](/chameleoon-max/type/vat-treatment)

The VAT regime. For an order from [`createSalesOrder`](/chameleoon-max/mutation/create-sales-order), what the external source
stated. For an order entered in MAX, what MAX determined. Null when neither applies.

### vatDestinationCountry

`String`

The state of a `DESTINATION_VAT` regime, as stated or else as determined.

- Requires the `partner.read` permission (otherwise `FORBIDDEN_ROLE`) and the customer in your
  API key's partner scope (otherwise `FORBIDDEN_SCOPE`).
- Null once the customer is erased.

### customerId

[`UUID!`](/chameleoon-max/type/uuid)

The customer's MAX id. Returned to every API key that can read the order.

### customer

[`Partner`](/chameleoon-max/type/partner)

The customer who ordered.

- Requires the `partner.read` permission. Without it, null with `FORBIDDEN_ROLE`.
- Outside your API key's partner scope, null with `FORBIDDEN_SCOPE` (`extensions.scope`
  `PARTNER`).
- An erased customer is returned with `name` null.

### billingAddress

[`SalesOrderAddress`](/chameleoon-max/type/sales-order-address)

The version of the billing address that the order keeps, unchanged since the order took it.

- Requires the `partner.read` permission (otherwise `FORBIDDEN_ROLE`) and the customer in your
  API key's partner scope (otherwise `FORBIDDEN_SCOPE`).
- Null once the customer is erased.

### deliveryAddress

[`SalesOrderAddress`](/chameleoon-max/type/sales-order-address)

The version of the delivery address that the order keeps, unchanged since the order took it.

- Requires the `partner.read` permission (otherwise `FORBIDDEN_ROLE`) and the customer in your
  API key's partner scope (otherwise `FORBIDDEN_SCOPE`).
- Null once the customer is erased.

### pickupPoint

[`PickupPoint`](/chameleoon-max/type/pickup-point)

The carrier's collection point, when the order is delivered to one.

### sourceDeliveryMethod

[`Method`](/chameleoon-max/type/method)

The delivery method in the external source's own words.

### carrier

[`CarrierProfile`](/chameleoon-max/type/carrier-profile)

The carrier and profile that ship the order. Null when none was selected, or when the
requested pair was unknown or unverified; those problems are listed in `exceptions`.

### paymentMethod

[`PaymentMethod!`](/chameleoon-max/type/payment-method)

How the customer intends to pay.

### sourcePaymentMethod

[`Method`](/chameleoon-max/type/method)

The payment method in the external source's own words.

### contactEmail

`String`

The e-mail the customer gave for this order.

- Requires the `partner.read` permission (otherwise `FORBIDDEN_ROLE`) and the customer in your
  API key's partner scope (otherwise `FORBIDDEN_SCOPE`).
- Null once the customer is erased.

### contactPhone

`String`

The phone the customer gave for this order.

- Requires the `partner.read` permission (otherwise `FORBIDDEN_ROLE`) and the customer in your
  API key's partner scope (otherwise `FORBIDDEN_SCOPE`).
- Null once the customer is erased.

### preferredWarehouseId

[`UUID`](/chameleoon-max/type/uuid)

The MAX id of the warehouse the order reserves stock from, when it has one.

### preferredWarehouse

[`Warehouse`](/chameleoon-max/type/warehouse)

The warehouse the order reserves stock from.

- Requires the `warehouse.read` permission. Without it, null with `FORBIDDEN_ROLE`.
- Outside your API key's warehouse scope, null with `FORBIDDEN_SCOPE` (`extensions.scope`
  `WAREHOUSE`).

### note

`String`

What the customer wrote with the order. Null once the customer is erased.

### internalNote

`String`

The internal remark on the order (from the external source's internal note), never the
customer's. Null once the customer is erased.

### billingAddressEditedInErp

`Boolean!`

Whether a user changed the billing address in MAX since the external source last sent it.
When `true`, a new billing address from the external source is a conflict that a user in MAX
resolves. An integration that writes the MAX address back to the external source can tell that
it is the MAX user's choice.

### deliveryAddressEditedInErp

`Boolean!`

Whether a user changed the delivery address in MAX since the external source last sent it.
Same meaning as `billingAddressEditedInErp`, for the delivery address.

### itemsEditedInErp

`Boolean!`

Whether a user changed the order's goods or charges in MAX since the external source last sent them.

### customerErased

`Boolean!`

Whether the customer was erased. Then the order's personal data reads null, never "none".

### items

[`SalesOrderItemConnection`](/chameleoon-max/type/sales-order-item-connection)

Arguments:

- `first`: `Int`
- `after`: `String`
- `last`: `Int`
- `before`: `String`

The goods lines, by line number, then id.

- A connection, paged with `first`/`after` or `last`/`before`, at most 250 a page. Its
  cursors belong to this order's items; any other connection refuses them.
- A set is one item. The lines of its components, which are what is reserved, picked and
  shipped, are not items here but the set's `components`.
- Null, with an error at its path, when its page cannot be read, for example because of a
  cursor of another parent. The rest of the response is returned.
- A page costs 2 + first (or last) × the cost of one node.

### charges

[`SalesOrderChargeConnection`](/chameleoon-max/type/sales-order-charge-connection)

Arguments:

- `first`: `Int`
- `after`: `String`
- `last`: `Int`
- `before`: `String`

Everything on the order that is not goods, by line number, then id.

- A connection, paged with `first`/`after` or `last`/`before`, at most 250 a page. Its
  cursors belong to this order's charges; any other connection refuses them.
- Null, with an error at its path, when its page cannot be read, for example because of a
  cursor of another parent. The rest of the response is returned.
- A page costs 2 + first (or last) × the cost of one node.

### blocked

[`SalesOrderBlock`](/chameleoon-max/type/sales-order-block)

Why no consignment of the order may proceed. Null when nothing blocks it.

### exceptions

[`RecordExceptionConnection`](/chameleoon-max/type/record-exception-connection)

Arguments:

- `first`: `Int`
- `after`: `String`
- `last`: `Int`
- `before`: `String`

The problems the order was created with that need a user in MAX, open and resolved, oldest first
(by `createdAt`, then id). Empty when there were none.

- A connection, paged with `first`/`after` or `last`/`before`, at most 250 a page. Its
  cursors belong to this order's exceptions; any other connection refuses them.
- Null, with an error at its path, when its page cannot be read, for example because of a
  cursor of another parent. The rest of the response is returned.
- A page costs 2 + first (or last) × the cost of one node.

### externalRefs

[`ExternalRefConnection`](/chameleoon-max/type/external-ref-connection)

Arguments:

- `first`: `Int`
- `after`: `String`
- `last`: `Int`
- `before`: `String`

The ids that other systems know the order by, sorted by external source code, then parent id
(none first), external id and the reference's own id. `source` and `externalId` above are one
of them: the one the request named, otherwise the oldest.

- A connection, paged with `first`/`after` or `last`/`before`, at most 250 a page. Its
  cursors belong to this order's references; any other connection refuses them.
- Read together with the order: requires the `order.read` permission, not `integration.read`.
  Without it, null with `FORBIDDEN_ROLE` at its path.
- When your API key is limited to partners other than the order's customer, null with
  `FORBIDDEN_SCOPE` (`extensions.scope` `PARTNER`).
- Null, with an error at its path, when its page cannot be read, for example because of a
  cursor of another parent. The rest of the response is returned.
- A page costs 2 + first (or last) × the cost of one node.

### documents

[`DocumentConnection`](/chameleoon-max/type/document-connection)

Arguments:

- `first`: `Int`
- `after`: `String`
- `last`: `Int`
- `before`: `String`
- `kinds`: [`[DocumentKind!]`](/chameleoon-max/type/document-kind)

The files attached to the order ([`attachDocument`](/chameleoon-max/mutation/attach-document)), oldest first. `kinds` narrows
the list to those kinds. Removed documents are left out.

- A connection, paged with `first`/`after` or `last`/`before`, at most 250 a page. Its
  cursors belong to this order's documents; any other connection refuses them.
- Requires the `order.read` permission.
- Null, with an error at its path, when its page cannot be read, for example because of a
  cursor of another parent. The rest of the response is returned.
- A page costs 2 + first (or last) × the cost of one node.

### changedAt

[`Time`](/chameleoon-max/type/time)

When the order's last event was published (see `events`). Null only for an order that was
never published.

### fulfilments

[`FulfilmentConnection`](/chameleoon-max/type/fulfilment-connection)

Arguments:

- `first`: `Int`
- `after`: `String`
- `last`: `Int`
- `before`: `String`

The order's fulfilments, oldest first. A fulfilment is what one warehouse sends of the order;
an order shipped from two warehouses has two.

- Requires the `fulfilment.read` permission. Without it, null with `FORBIDDEN_ROLE` at its
  path. The rest of the order is returned.
- Fulfilments in warehouses outside your API key's warehouse scope are left out.

A connection, paged with `first`/`after` or `last`/`before`, at most 250 a page. For the next
page, send the same query with `after` set to `pageInfo.endCursor`, while
`pageInfo.hasNextPage` is true.

Null, with an error at its path, when its page cannot be read, for example because of a cursor
of another parent. The rest of the response is returned.

A page costs 2 + first (or last) × the cost of one node.

### invoices

[`SalesOrderInvoiceConnection`](/chameleoon-max/type/sales-order-invoice-connection)

Arguments:

- `kinds`: [`[InvoiceKind!]`](/chameleoon-max/type/invoice-kind)
- `first`: `Int`
- `after`: `String`
- `last`: `Int`
- `before`: `String`

The invoices linked to the order, newest issued first. `kinds` narrows the list: `INVOICE` for
invoices proper, `ADVANCE`, `CREDIT_NOTE`. Without `kinds`, every kind. `totalCount` counts the
same invoices.

- A connection, paged with `first`/`after` or `last`/`before`, at most 250 a page.
- Requires the `invoice.read` permission. Without it, null with `FORBIDDEN_ROLE` at its path,
  and the rest of the response is returned.
- Null, with an error at its path, when its page cannot be read, for example because of a
  cursor of another parent. The rest of the response is returned.
- A page costs 2 + first (or last) × the cost of one node.

### governingInvoice

[`Invoice`](/chameleoon-max/type/invoice)

The linked invoice that governs the order's invoice reference.

Of the linked issued invoices of kind `INVOICE` that are `CREATED`, not cancelled and have a
number, it is the one with the latest issue date (then the greatest id). While one governs:

- The order's `invoiceNumber` and `invoiceExternalId` are its number and id.
- [`setSalesOrderInvoice`](/chameleoon-max/mutation/set-sales-order-invoice) refuses another invoice (`INVOICE_GOVERNED`).

Null when none governs, or when the governing invoice is outside your API key's scope.
Requires the `invoice.read` permission. Without it, null with `FORBIDDEN_ROLE` at its path.

### invoicePdfReady

`Boolean`

Whether the order's invoice has a PDF to send now: what the `orderInvoice` attachment of
[`sendEmail`](/chameleoon-max/mutation/send-email) would find. Use it to wait before an invoice e-mail when the PDF
arrives later; a workflow does this with `waitUntil` on `erpOrder.invoicePdfReady`.

With a governing invoice, it is `true` when any of these exists:

- The accounting system's PDF attached to the invoice ([`attachInvoiceDocument`](/chameleoon-max/mutation/attach-invoice-document)).
- The order's document of the invoice's kind under the invoice's number. This counts on any
  order the invoice is linked to.
- MAX's own render, where the invoice's external source allows it
  (`ExternalSource.invoicePrintAllowed`). Then it is `true` as soon as the invoice governs. A
  foreign-currency invoice synced without its home-currency VAT is still refused when sent
  (`HOME_VAT_MISSING`).

Without a governing invoice, it is `true` when the order has an `INVOICE` document.

- It is a fact of the order, not of your API key's permissions. Sending still requires the
  read permissions that [`sendEmail`](/chameleoon-max/mutation/send-email) lists.
- Null, with an error at its path, when it cannot be read. The rest of the order is returned.
- Costs 2 points.

### shipments

[`ShipmentConnection`](/chameleoon-max/type/shipment-connection)

Arguments:

- `first`: `Int`
- `after`: `String`
- `last`: `Int`
- `before`: `String`

The order's carrier shipments, oldest first. Live and cancelled shipments are listed; a
shipment that never reached the carrier is not.

- Requires the `shipment.read` permission. Without it, null with `FORBIDDEN_ROLE` at its path.
- Shipments outside your API key's legal-entity or warehouse scope are left out.

A connection, paged with `first`/`after` or `last`/`before`, at most 250 a page.

Null, with an error at its path, when its page cannot be read, for example because of a cursor
of another parent. The rest of the response is returned.

A page costs 2 + first (or last) × the cost of one node.

## Used by

- [`salesOrder`](/chameleoon-max/query/sales-order) (query)
- [`CreateSalesOrderResult`](/chameleoon-max/type/create-sales-order-result)
- [`Document`](/chameleoon-max/type/document)
- [`ReportExternalIssueResult`](/chameleoon-max/type/report-external-issue-result)
- [`SalesOrderAddressesResult`](/chameleoon-max/type/sales-order-addresses-result)
- [`SalesOrderChangeResult`](/chameleoon-max/type/sales-order-change-result)
- [`SalesOrderConnection`](/chameleoon-max/type/sales-order-connection)
- [`SalesOrderDetailsResult`](/chameleoon-max/type/sales-order-details-result)
- [`SalesOrderEdge`](/chameleoon-max/type/sales-order-edge)
- [`SalesOrderItemsResult`](/chameleoon-max/type/sales-order-items-result)
