> For the complete documentation index, see [llms.txt](https://developers.portos.sk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.portos.sk/api-reference/orders.md).

# Orders

After each ticket update, orders are automatically generated. Each order includes contextual information about the products and specifies the order endpoint where the products will be processed.

Order is represented by [`Order`](/data-models.md#order) class.

## API methods

## Get orders

<mark style="color:blue;">`GET`</mark> `http://{server-address}/orders`

Returns all orders that matches query parameters. Result is of type [`QueryResult<Order>`](/data-models.md#queryresult).

#### Query Parameters

| Name          | Type      | Description                                                                                                              |
| ------------- | --------- | ------------------------------------------------------------------------------------------------------------------------ |
| deviceName    | string    | Supports NData syntax.                                                                                                   |
| $skip         | int       | Pagination property. Describing number of records to skip from beginning of result collection.                           |
| $take         | int       | Pagination property. Maximum count of items to be returned.                                                              |
| $sort         | string\[] | <p>Comma separated list of property names. Please see NData syntax.<br></p>                                              |
| $count        | bool      | If set to `true`, response will not contain `items` collection. Use to get resource count, not the resources themselves. |
| id            | string    | Supports NData syntax.                                                                                                   |
| number        | int       | Supports NData syntax.                                                                                                   |
| ticketId      | string    | Supports NData syntax.                                                                                                   |
| ticketName    | string    | Supports NData syntax.                                                                                                   |
| userUserName  | string    | Supports NData syntax.                                                                                                   |
| isProcessed   | bool      | Supports NData syntax.                                                                                                   |
| isProcessable | bool      | Supports NData syntax.                                                                                                   |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

{% tabs %}
{% tab title="200: OK Successful response" %}

```javascript
{
    "items":
    [
        {
            "id": "64b70e39fa08b1c38bfc5c56",
            "number": 2,
            "deviceName": "PDA1",
            "user":
            {
                "name": "Cashier",
                "userName": "999",
                "featureName": null
            },
            "ticket":
            {
                "id": "64b70d71fa08b1c38bfc5c55",
                "name": "G-01-01",
                "location":
                {
                    "zoneName": "Garden",
                    "tableName": "G-01"
                },
                "purchaseType": "WalkIn",
                "customer": null,
                "version": 2
            },
            "items":
            [
                {
                    "id": 1,
                    "plu":
                    {
                        "name": "Pilsner",
                        "code": 405,
                        "stockName": "S01"
                    },
                    "quantity":
                    {
                        "amount": 2.0,
                        "unit": "ks"
                    },
                    "comment": null,
                    "endpoints":
                    [
                        {
                            "name": "Bar",
                            "statusChanges":
                            [
                                {
                                    "status": "Created",
                                    "date": "2023-07-18T13:12:09.344Z"
                                },
                                {
                                    "status": "Processed",
                                    "date": "2023-07-18T13:12:09.706Z"
                                }
                            ],
                            "orderItemStatus": "Processed",
                            "isProcessed": true,
                            "isProcessable": false
                        }
                    ],
                    "courseNumber": null,
                    "isProcessable": false,
                    "isProcessed": true
                },
                {
                    "id": 2,
                    "plu":
                    {
                        "name": "Chicken wings",
                        "code": 172,
                        "stockName": "S01"
                    },
                    "quantity":
                    {
                        "amount": 1.0,
                        "unit": "ks"
                    },
                    "comment": "Extra spicy, please!",
                    "endpoints":
                    [
                        {
                            "name": "Kitchen",
                            "statusChanges":
                            [
                                {
                                    "status": "Created",
                                    "date": "2023-07-18T13:12:09.346Z"
                                },
                                {
                                    "status": "Processed",
                                    "date": "2023-07-18T13:12:09.706Z"
                                }
                            ],
                            "orderItemStatus": "Processed",
                            "isProcessed": true,
                            "isProcessable": false
                        }
                    ],
                    "courseNumber": null,
                    "isProcessable": false,
                    "isProcessed": true
                }
            ],
            "isProcessed": true,
            "isProcessable": false
        }
    ],
    "count": 1,
    "totalCount": 1
}
```

{% endtab %}
{% endtabs %}

## Get order

<mark style="color:blue;">`GET`</mark> `http://{server-address}/orders/{id}`

Result is of type [`Order`](/data-models.md#order).

#### Path Parameters

| Name                                 | Type   | Description              |
| ------------------------------------ | ------ | ------------------------ |
| id<mark style="color:red;">\*</mark> | string | Unique order identifier. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

{% tabs %}
{% tab title="200: OK Resource found." %}

```javascript
{
    "id": "64b70e39fa08b1c38bfc5c56",
    "number": 2,
    "deviceName": "PDA1",
    "user":
    {
        "name": "Cashier",
        "userName": "999",
        "featureName": null
    },
    "ticket":
    {
        "id": "64b70d71fa08b1c38bfc5c55",
        "name": "G-01-01",
        "location":
        {
            "zoneName": "Garden",
            "tableName": "G-01"
        },
        "purchaseType": "WalkIn",
        "customer": null,
        "version": 2
    },
    "items":
    [
        {
            "id": 1,
            "plu":
            {
                "name": "Pilsner",
                "code": 405,
                "stockName": "S01"
            },
            "quantity":
            {
                "amount": 2.0,
                "unit": "ks"
            },
            "comment": null,
            "endpoints":
            [
                {
                    "name": "Bar",
                    "statusChanges":
                    [
                        {
                            "status": "Created",
                            "date": "2023-07-18T13:12:09.344Z"
                        },
                        {
                            "status": "Processed",
                            "date": "2023-07-18T13:12:09.706Z"
                        }
                    ],
                    "orderItemStatus": "Processed",
                    "isProcessed": true,
                    "isProcessable": false
                }
            ],
            "courseNumber": null,
            "isProcessable": false,
            "isProcessed": true
        },
        {
            "id": 2,
            "plu":
            {
                "name": "Chicken wings",
                "code": 172,
                "stockName": "S01"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "comment": "Extra spicy, please!",
            "endpoints":
            [
                {
                    "name": "Kitchen",
                    "statusChanges":
                    [
                        {
                            "status": "Created",
                            "date": "2023-07-18T13:12:09.346Z"
                        },
                        {
                            "status": "Processed",
                            "date": "2023-07-18T13:12:09.706Z"
                        }
                    ],
                    "orderItemStatus": "Processed",
                    "isProcessed": true,
                    "isProcessable": false
                }
            ],
            "courseNumber": null,
            "isProcessable": false,
            "isProcessed": true
        }
    ],
    "isProcessed": true,
    "isProcessable": false
}
```

{% endtab %}

{% tab title="404: Not Found Given resource was not found." %}

```javascript
{
    "title": "Zdroj nebol nájdený",
    "status": 404
}
```

{% endtab %}
{% endtabs %}

## Process order

<mark style="color:green;">`POST`</mark> `http://{server-address}/orders`

Invokes order processing. Method accepts [`ProcessOrdersContext`](/data-models.md#processorderscontext) in request body, that is used to specify orders to be processed, using [`Ticket`](/data-models.md#ticket) identifiers. Collection of all affected [`Order`](/data-models.md#order) models is returned.

**Required rights**

Authorized user must have `OrderProcess` [right ](/user-rights.md)assigned.

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

#### Request Body

| Name                                     | Type                 | Description                         |
| ---------------------------------------- | -------------------- | ----------------------------------- |
| (body)<mark style="color:red;">\*</mark> | ProcessOrdersContext | Conext to specify order processing. |

{% tabs %}
{% tab title="202: Accepted Order processing is accepted and may continue after API response is sent to caller." %}

```javascript
[
    {
        "id": "64b70e39fa08b1c38bfc5c56",
        "number": 2,
        "deviceName": "PDA1",
        "user":
        {
            "name": "Cashier",
            "userName": "999",
            "featureName": null
        },
        "ticket":
        {
            "id": "64b70d71fa08b1c38bfc5c55",
            "name": "G-01-01",
            "location":
            {
                "zoneName": "Garden",
                "tableName": "G-01"
            },
            "purchaseType": "WalkIn",
            "customer": null,
            "version": 2
        },
        "items":
        [
            {
                "id": 1,
                "plu":
                {
                    "name": "Pilsner",
                    "code": 405,
                    "stockName": "S01"
                },
                "quantity":
                {
                    "amount": 2.0,
                    "unit": "ks"
                },
                "comment": null,
                "endpoints":
                [
                    {
                        "name": "Bar",
                        "statusChanges":
                        [
                            {
                                "status": "Created",
                                "date": "2023-07-18T13:12:09.344Z"
                            },
                            {
                                "status": "Processed",
                                "date": "2023-07-18T13:12:09.706Z"
                            }
                        ],
                        "orderItemStatus": "Processed",
                        "isProcessed": true,
                        "isProcessable": false
                    }
                ],
                "courseNumber": null,
                "isProcessable": false,
                "isProcessed": true
            },
            {
                "id": 2,
                "plu":
                {
                    "name": "Chicken wings",
                    "code": 172,
                    "stockName": "S01"
                },
                "quantity":
                {
                    "amount": 1.0,
                    "unit": "ks"
                },
                "comment": "Extra spicy, please!",
                "endpoints":
                [
                    {
                        "name": "Kitchen",
                        "statusChanges":
                        [
                            {
                                "status": "Created",
                                "date": "2023-07-18T13:12:09.346Z"
                            },
                            {
                                "status": "Processed",
                                "date": "2023-07-18T13:12:09.706Z"
                            }
                        ],
                        "orderItemStatus": "Processed",
                        "isProcessed": true,
                        "isProcessable": false
                    }
                ],
                "courseNumber": null,
                "isProcessable": false,
                "isProcessed": true
            }
        ],
        "isProcessed": true,
        "isProcessable": false
    }
]
```

{% endtab %}
{% endtabs %}

## Set order status

<mark style="color:green;">`POST`</mark> `http://{server-address}/orders/{id}/status`

Manually changes status for entire order (for all items and all associated order endpoints). Method accepts [`OrderStatusContext`](/data-models.md#orderstatuscontext) in request body. Updated [`Order`](/data-models.md#order) is returned.

**Required rights**

Authorized user must have `OrderUpdate` [right ](/user-rights.md)assigned.

#### Path Parameters

| Name                                 | Type   | Description             |
| ------------------------------------ | ------ | ----------------------- |
| id<mark style="color:red;">\*</mark> | string | Order unique identifier |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

#### Request Body

| Name                                     | Type               | Description |
| ---------------------------------------- | ------------------ | ----------- |
| (body)<mark style="color:red;">\*</mark> | OrderStatusContext |             |

{% tabs %}
{% tab title="200: OK Order status updated." %}

```javascript
{
    "id": "64b70e39fa08b1c38bfc5c56",
    "number": 2,
    "deviceName": "PDA1",
    "user":
    {
        "name": "Cashier",
        "userName": "999",
        "featureName": null
    },
    "ticket":
    {
        "id": "64b70d71fa08b1c38bfc5c55",
        "name": "G-01-01",
        "location":
        {
            "zoneName": "Garden",
            "tableName": "G-01"
        },
        "purchaseType": "WalkIn",
        "customer": null,
        "version": 2
    },
    "items":
    [
        {
            "id": 1,
            "plu":
            {
                "name": "Pilsner",
                "code": 405,
                "stockName": "S01"
            },
            "quantity":
            {
                "amount": 2.0,
                "unit": "ks"
            },
            "comment": null,
            "endpoints":
            [
                {
                    "name": "Bar",
                    "statusChanges":
                    [
                        {
                            "status": "Created",
                            "date": "2023-07-18T13:12:09.344Z"
                        },
                        {
                            "status": "Processed",
                            "date": "2023-07-18T13:12:09.706Z"
                        }
                    ],
                    "orderItemStatus": "Processed",
                    "isProcessed": true,
                    "isProcessable": false
                }
            ],
            "courseNumber": null,
            "isProcessable": false,
            "isProcessed": true
        },
        {
            "id": 2,
            "plu":
            {
                "name": "Chicken wings",
                "code": 172,
                "stockName": "S01"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "comment": "Extra spicy, please!",
            "endpoints":
            [
                {
                    "name": "Kitchen",
                    "statusChanges":
                    [
                        {
                            "status": "Created",
                            "date": "2023-07-18T13:12:09.346Z"
                        },
                        {
                            "status": "Processed",
                            "date": "2023-07-18T13:12:09.706Z"
                        }
                    ],
                    "orderItemStatus": "Processed",
                    "isProcessed": true,
                    "isProcessable": false
                }
            ],
            "courseNumber": null,
            "isProcessable": false,
            "isProcessed": true
        }
    ],
    "isProcessed": true,
    "isProcessable": false
}
```

{% endtab %}
{% endtabs %}

## Set order item status

<mark style="color:green;">`POST`</mark> `http://{server-address}/orders/{id}/items/{itemId}/status`

Manually changes order status for specified [order item](/data-models.md#orderitem). Status is set for all [order endpoints ](/data-models.md#orderitemendpoint)associated with given order item. Method accepts [`OrderStatusContext`](/data-models.md#orderstatuscontext) in request body. Updated [`Order`](/data-models.md#order) is returned.

**Required rights**

Authorized user must have `OrderUpdate` [right ](/user-rights.md)assigned.

#### Path Parameters

| Name                                     | Type   | Description             |
| ---------------------------------------- | ------ | ----------------------- |
| id<mark style="color:red;">\*</mark>     | string | Order unique identifier |
| itemId<mark style="color:red;">\*</mark> | int    | Order item identifier   |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

#### Request Body

| Name   | Type               | Description |
| ------ | ------------------ | ----------- |
| (body) | OrderStatusContext |             |

{% tabs %}
{% tab title="200: OK Order item status updated." %}

```javascript
{
    "id": "64b70e39fa08b1c38bfc5c56",
    "number": 2,
    "deviceName": "PDA1",
    "user":
    {
        "name": "Cashier",
        "userName": "999",
        "featureName": null
    },
    "ticket":
    {
        "id": "64b70d71fa08b1c38bfc5c55",
        "name": "G-01-01",
        "location":
        {
            "zoneName": "Garden",
            "tableName": "G-01"
        },
        "purchaseType": "WalkIn",
        "customer": null,
        "version": 2
    },
    "items":
    [
        {
            "id": 1,
            "plu":
            {
                "name": "Pilsner",
                "code": 405,
                "stockName": "S01"
            },
            "quantity":
            {
                "amount": 2.0,
                "unit": "ks"
            },
            "comment": null,
            "endpoints":
            [
                {
                    "name": "Bar",
                    "statusChanges":
                    [
                        {
                            "status": "Created",
                            "date": "2023-07-18T13:12:09.344Z"
                        },
                        {
                            "status": "Processed",
                            "date": "2023-07-18T13:12:09.706Z"
                        }
                    ],
                    "orderItemStatus": "Processed",
                    "isProcessed": true,
                    "isProcessable": false
                }
            ],
            "courseNumber": null,
            "isProcessable": false,
            "isProcessed": true
        },
        {
            "id": 2,
            "plu":
            {
                "name": "Chicken wings",
                "code": 172,
                "stockName": "S01"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "comment": "Extra spicy, please!",
            "endpoints":
            [
                {
                    "name": "Kitchen",
                    "statusChanges":
                    [
                        {
                            "status": "Created",
                            "date": "2023-07-18T13:12:09.346Z"
                        },
                        {
                            "status": "Processed",
                            "date": "2023-07-18T13:12:09.706Z"
                        }
                    ],
                    "orderItemStatus": "Processed",
                    "isProcessed": true,
                    "isProcessable": false
                }
            ],
            "courseNumber": null,
            "isProcessable": false,
            "isProcessed": true
        }
    ],
    "isProcessed": true,
    "isProcessable": false
}
```

{% endtab %}
{% endtabs %}

## Set order endpoint status

<mark style="color:green;">`POST`</mark> `http://{server-address}/orders/{id}/endpoints/{endpointName}/status`

Manually change the order status for a specified [order item](/data-models.md#orderitem) on a specific [order endpoint](/data-models.md#orderitemendpoint). Method accepts [`OrderStatusContext`](/data-models.md#orderstatuscontext) in request body. Updated [`Order`](/data-models.md#order) is returned.

**Required rights**

Authorized user must have `OrderUpdate` [right ](/user-rights.md)assigned.

#### Path Parameters

| Name                                           | Type   | Description             |
| ---------------------------------------------- | ------ | ----------------------- |
| id<mark style="color:red;">\*</mark>           | string | Order unique identifier |
| endpointName<mark style="color:red;">\*</mark> | string | Order endpoint name     |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

#### Request Body

| Name   | Type               | Description |
| ------ | ------------------ | ----------- |
| (body) | OrderStatusContext |             |

{% tabs %}
{% tab title="200: OK Order endpoint status updated." %}

```javascript
{
    "id": "64b70e39fa08b1c38bfc5c56",
    "number": 2,
    "deviceName": "PDA1",
    "user":
    {
        "name": "Cashier",
        "userName": "999",
        "featureName": null
    },
    "ticket":
    {
        "id": "64b70d71fa08b1c38bfc5c55",
        "name": "G-01-01",
        "location":
        {
            "zoneName": "Garden",
            "tableName": "G-01"
        },
        "purchaseType": "WalkIn",
        "customer": null,
        "version": 2
    },
    "items":
    [
        {
            "id": 1,
            "plu":
            {
                "name": "Pilsner",
                "code": 405,
                "stockName": "S01"
            },
            "quantity":
            {
                "amount": 2.0,
                "unit": "ks"
            },
            "comment": null,
            "endpoints":
            [
                {
                    "name": "Bar",
                    "statusChanges":
                    [
                        {
                            "status": "Created",
                            "date": "2023-07-18T13:12:09.344Z"
                        },
                        {
                            "status": "Processed",
                            "date": "2023-07-18T13:12:09.706Z"
                        }
                    ],
                    "orderItemStatus": "Processed",
                    "isProcessed": true,
                    "isProcessable": false
                }
            ],
            "courseNumber": null,
            "isProcessable": false,
            "isProcessed": true
        },
        {
            "id": 2,
            "plu":
            {
                "name": "Chicken wings",
                "code": 172,
                "stockName": "S01"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "comment": "Extra spicy, please!",
            "endpoints":
            [
                {
                    "name": "Kitchen",
                    "statusChanges":
                    [
                        {
                            "status": "Created",
                            "date": "2023-07-18T13:12:09.346Z"
                        },
                        {
                            "status": "Processed",
                            "date": "2023-07-18T13:12:09.706Z"
                        }
                    ],
                    "orderItemStatus": "Processed",
                    "isProcessed": true,
                    "isProcessable": false
                }
            ],
            "courseNumber": null,
            "isProcessable": false,
            "isProcessed": true
        }
    ],
    "isProcessed": true,
    "isProcessable": false
}
```

{% endtab %}
{% endtabs %}

## Delete order

<mark style="color:red;">`DELETE`</mark> `http://{server-address}/orders/{id}`

**Required rights**

Authorized user must have `OrderDelete` [right ](/user-rights.md)assigned.

#### Path Parameters

| Name                                 | Type   | Description              |
| ------------------------------------ | ------ | ------------------------ |
| id<mark style="color:red;">\*</mark> | string | Unique order identifier. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

{% tabs %}
{% tab title="200: OK Successfuly deleted." %}

```javascript
{
    "id": "64b70e39fa08b1c38bfc5c56",
    "number": 2,
    "deviceName": "PDA1",
    "user":
    {
        "name": "Cashier",
        "userName": "999",
        "featureName": null
    },
    "ticket":
    {
        "id": "64b70d71fa08b1c38bfc5c55",
        "name": "G-01-01",
        "location":
        {
            "zoneName": "Garden",
            "tableName": "G-01"
        },
        "purchaseType": "WalkIn",
        "customer": null,
        "version": 2
    },
    "items":
    [
        {
            "id": 1,
            "plu":
            {
                "name": "Pilsner",
                "code": 405,
                "stockName": "S01"
            },
            "quantity":
            {
                "amount": 2.0,
                "unit": "ks"
            },
            "comment": null,
            "endpoints":
            [
                {
                    "name": "Bar",
                    "statusChanges":
                    [
                        {
                            "status": "Created",
                            "date": "2023-07-18T13:12:09.344Z"
                        },
                        {
                            "status": "Processed",
                            "date": "2023-07-18T13:12:09.706Z"
                        }
                    ],
                    "orderItemStatus": "Processed",
                    "isProcessed": true,
                    "isProcessable": false
                }
            ],
            "courseNumber": null,
            "isProcessable": false,
            "isProcessed": true
        },
        {
            "id": 2,
            "plu":
            {
                "name": "Chicken wings",
                "code": 172,
                "stockName": "S01"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "comment": "Extra spicy, please!",
            "endpoints":
            [
                {
                    "name": "Kitchen",
                    "statusChanges":
                    [
                        {
                            "status": "Created",
                            "date": "2023-07-18T13:12:09.346Z"
                        },
                        {
                            "status": "Processed",
                            "date": "2023-07-18T13:12:09.706Z"
                        }
                    ],
                    "orderItemStatus": "Processed",
                    "isProcessed": true,
                    "isProcessable": false
                }
            ],
            "courseNumber": null,
            "isProcessable": false,
            "isProcessed": true
        }
    ],
    "isProcessed": true,
    "isProcessable": false
}
```

{% endtab %}

{% tab title="404: Not Found Given resource was not found." %}

```javascript
{
    "title": "Zdroj nebol nájdený",
    "status": 404
}
```

{% endtab %}
{% endtabs %}
