Write offs
Create a write-off
Creates a write-off from the header and any items in the body, and returns the stored document (201, `Location` header set). Reserves the next internal document number. Requires `Permissions.WriteOffs.Create`.
Get write-off defaults
Returns the instance's configured defaults applied when a write-off is created. Requires `Permissions.WriteOffs.View`.
Get a write-off
Returns one write-off by `documentId`, with its header, items and item variants. Requires `Permissions.WriteOffs.View`.
Delete a write-off
Deletes the write-off together with its items and item variants. Cannot be undone. Call `GET {documentId}/check-delete` first to find out whether the delete is allowed. Requires `Permissions.WriteOffs.Delete`.
Update a write-off
Updates the write-off header and the items sent in the body. Pass `removeItemsNotInRequest=true` to also delete the items the body leaves out. Requires `Permissions.WriteOffs.Update`.
Check whether a write-off can be deleted
Advisory pre-flight for `DELETE {documentId}`. `canBeDeleted` is false when `blockingReasons` holds `HEADER_BLOCKED` or `ITEMS_BLOCKED`. The delete re-checks inside its own transaction, so a positive answer here is an indication rather than a guarantee. Requires `Permissions.WriteOffs.Delete`.
Process a write-off (deprecated)
**Deprecated.** Use `POST {documentId}/process` instead — this alias behaves identically and will be removed. Requires `Permissions.WriteOffs.Update`.
Add items to a write-off
Appends the items in the body to an existing write-off and recalculates the document totals. Requires `Permissions.WriteOffs.Create`.
Delete write-off items
Deletes the items listed in `itemIds` and recalculates the document totals. Call `GET {documentId}/items/check-delete` first to find out whether the delete is allowed. Requires `Permissions.WriteOffs.Delete`.
Check whether write-off items can be deleted
Advisory pre-flight for `DELETE {documentId}/items`. `blockingReasons` holds `ITEMS_BLOCKED` when at least one id in `itemIds` is still referenced elsewhere. At most 1000 ids per call. Requires `Permissions.WriteOffs.Delete`.
Update a write-off item
Replaces one item of the write-off, identified by `itemId`, and recalculates the document totals. Requires `Permissions.WriteOffs.Update`.
Delete a write-off item variant
Deletes one variant row (a size/colour breakdown) of an item and recalculates the document totals. Call the matching `check-delete` endpoint first to find out whether the delete is allowed. Requires `Permissions.WriteOffs.Delete`.
Check whether an item variant can be deleted
Advisory pre-flight for `DELETE {documentId}/items/{itemId}/variants/{variantId}`. `blockingReasons` holds `ITEM_VARIANT_BLOCKED` when the variant is still referenced elsewhere. Requires `Permissions.WriteOffs.Delete`.
Get the lock state of a write-off
Returns whether the write-off is locked against concurrent edits and, when it is, the name of the user holding the lock. Requires `Permissions.WriteOffs.View`.
Lock a write-off
Locks the write-off for the calling user so other users cannot edit or process it. Returns 400 when it is already locked. Release it with `DELETE {documentId}/lock`. Requires `Permissions.WriteOffs.Update`.
Unlock a write-off
Releases the lock on the write-off. Returns 400 when the lock belongs to another user. Requires `Permissions.WriteOffs.Update`.
Get a write-off as PDF
Renders the write-off with its configured print template and returns `application/pdf` inline. 404 when the document has no printable output. Requires `Permissions.WriteOffs.View`.
Process a write-off
Posts the write-off to stock, applying the movement of every item, and marks the document as processed. Fails when the document is already processed, or when another user holds its lock. Processing cannot be reversed through this API. Requires `Permissions.WriteOffs.Update`.
Process a delivery note POST
Posts the delivery note to stock, applying the movement of every item, and marks the document as processed. Fails when the document is already processed, or when another user holds its lock. Processing cannot be reversed through this API. Requires `Permissions.DeliveryNotes.Update`.
Create a write-off POST
Creates a write-off from the header and any items in the body, and returns the stored document (201, `Location` header set). Reserves the next internal document number. Requires `Permissions.WriteOffs.Create`.