220 lines
5.2 KiB
Markdown
220 lines
5.2 KiB
Markdown
# `POST /quote/{id}/order`
|
|
|
|
Protected. Requires a valid session cookie (`credentials: 'include'`).
|
|
|
|
Create order from quote
|
|
|
|
Creates a sales order from an existing quote for the authenticated user's selected company.
|
|
Copies lines and customer entity from the quote.
|
|
Sets external reference (externalNumber) to the quote number unless explicitly overridden.
|
|
If the order number is omitted, it is auto-allocated from the sequence.
|
|
Fails with 400 (No entity selected) if neither the quote nor the request body specifies a customer entity.
|
|
|
|
|
|
## Path parameters
|
|
|
|
| Param | Required | Type | Description |
|
|
|-------|----------|------|-------------|
|
|
| `id` | yes | integer | Quote ID |
|
|
|
|
## Body (JSON) — _optional_
|
|
|
|
| Field | Required | Type | Description |
|
|
|-------|----------|------|-------------|
|
|
| `number` | no | string | Optional sales order number. Auto-allocated from sequence if omitted. |
|
|
| `date` | no | string | Optional order date (ISO format). Defaults to current date. |
|
|
| `createdAt` | no | string | Optional creation timestamp. |
|
|
| `entityId` | no | integer | Customer entity ID override. Defaults to quote's entityId. |
|
|
| `externalNumber` | no | string | External customer reference override. Defaults to quote's number. |
|
|
| `lines` | no | ManifestLineInput[] | Optional line items override. Defaults to quote's lines. |
|
|
|
|
```json
|
|
{
|
|
"number": "…",
|
|
"date": "…",
|
|
"createdAt": "2026-08-10T00:00:00.000Z",
|
|
"entityId": 1,
|
|
"externalNumber": "…",
|
|
"lines": [
|
|
{
|
|
"sku": "…",
|
|
"name": "…",
|
|
"pu": 1,
|
|
"amount": 1,
|
|
"net": 1,
|
|
"taxrate": 1,
|
|
"rebate": 1,
|
|
"comment": "…",
|
|
"shippable": true
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
## Response `201`
|
|
|
|
Created order
|
|
|
|
```json
|
|
{
|
|
"order": {
|
|
"id": 1,
|
|
"number": "…",
|
|
"type": "order",
|
|
"entityId": 1,
|
|
"externalNumber": "…",
|
|
"date": "2026-08-10T00:00:00.000Z",
|
|
"createdAt": "2026-08-10T00:00:00.000Z",
|
|
"lines": [
|
|
{
|
|
"id": 1,
|
|
"sku": "…",
|
|
"name": "…",
|
|
"pu": 1,
|
|
"amount": 1,
|
|
"net": 1,
|
|
"rebate": 1,
|
|
"taxrate": 1,
|
|
"comment": "…",
|
|
"shippable": true
|
|
}
|
|
],
|
|
"shipping": {
|
|
"id": 1,
|
|
"manifestId": 1,
|
|
"number": "…",
|
|
"trackingCode": "…",
|
|
"carrierId": 1,
|
|
"carrier": "…",
|
|
"type": "…",
|
|
"state": "…"
|
|
},
|
|
"shippings": [
|
|
{
|
|
"id": 1,
|
|
"manifestId": 1,
|
|
"number": "…",
|
|
"trackingCode": "…",
|
|
"carrierId": 1,
|
|
"carrier": "…",
|
|
"type": "…",
|
|
"state": "…"
|
|
}
|
|
],
|
|
"payment": {
|
|
"id": 1,
|
|
"accountId": 1,
|
|
"manifestId": 1,
|
|
"type": "…",
|
|
"amount": 1
|
|
},
|
|
"payments": [
|
|
{
|
|
"id": 1,
|
|
"accountId": 1,
|
|
"manifestId": 1,
|
|
"type": "…",
|
|
"amount": 1
|
|
}
|
|
],
|
|
"paid": true,
|
|
"shipped": true,
|
|
"delivered": true,
|
|
"orderTotal": 1,
|
|
"paidTotal": 1,
|
|
"orderedQuantity": 1,
|
|
"shippedQuantity": 1,
|
|
"shipments": [
|
|
{
|
|
"id": 1,
|
|
"number": "…",
|
|
"type": "shipment",
|
|
"entityId": 1,
|
|
"externalNumber": "…",
|
|
"date": "…",
|
|
"createdAt": "…",
|
|
"lineCount": 1,
|
|
"packageCount": 1,
|
|
"lines": [
|
|
{
|
|
"id": 1,
|
|
"sku": "…",
|
|
"name": "…",
|
|
"pu": 1,
|
|
"amount": 1,
|
|
"net": 1,
|
|
"rebate": 1,
|
|
"taxrate": 1,
|
|
"comment": "…",
|
|
"shippable": true
|
|
}
|
|
],
|
|
"shippings": [
|
|
{
|
|
"id": 1,
|
|
"manifestId": 1,
|
|
"number": "…",
|
|
"trackingCode": "…",
|
|
"carrierId": 1,
|
|
"carrier": "…",
|
|
"type": "…",
|
|
"state": "…"
|
|
}
|
|
],
|
|
"files": [
|
|
{
|
|
"id": 1,
|
|
"manifestId": 1,
|
|
"fileId": 1,
|
|
"sort": 1,
|
|
"hash": "…",
|
|
"mimetype": "…",
|
|
"name": "…",
|
|
"size": 1,
|
|
"created": "2026-08-10T00:00:00.000Z",
|
|
"modified": "2026-08-10T00:00:00.000Z",
|
|
"skeledash": "…",
|
|
"thumbx": 1,
|
|
"thumby": 1,
|
|
"meta": {}
|
|
}
|
|
],
|
|
"state": "new"
|
|
}
|
|
],
|
|
"files": [
|
|
{
|
|
"id": 1,
|
|
"manifestId": 1,
|
|
"fileId": 1,
|
|
"sort": 1,
|
|
"hash": "…",
|
|
"mimetype": "…",
|
|
"name": "…",
|
|
"size": 1,
|
|
"created": "2026-08-10T00:00:00.000Z",
|
|
"modified": "2026-08-10T00:00:00.000Z",
|
|
"skeledash": "…",
|
|
"thumbx": 1,
|
|
"thumby": 1,
|
|
"meta": {}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
```
|
|
|
|
## Errors
|
|
|
|
| Status | Description |
|
|
|--------|-------------|
|
|
| 400 | No company selected, no entity selected, invalid quote id, or invalid order data — `{"error":"…"}` |
|
|
| 401 | Unauthorized — `{"error":"…"}` |
|
|
| 403 | Not authorized for company — `{"error":"…"}` |
|
|
| 404 | Quote not found or entity not found — `{"error":"…"}` |
|
|
| 500 | Server error — `{"error":"…"}` |
|
|
|
|
---
|
|
|
|
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._
|