# Розділення рахунку (Split Bill)

## Процес розділення рахунку

Для індикації того що конкретний рахунок можна розділити, при передачі[ /callback/getBill](/api/messages/getbill.md#callback-getbill) параметр "`splitAvailable`" має містити значення <mark style="color:green;">`true`</mark>.\
Для коректної роботи сервісу при передачі[ /callback/getBill](/api/messages/getbill.md#callback-getbill) також має бути вказаний параметр `"positionId": "string"`

{% hint style="info" %}
**За замовчуванням** для ресторану ця функціональність вимкенна.&#x20;

Для її активації зверніться до аккаунт-менеджера що веде ресторан.
{% endhint %}

***

При розділенні рахунку, Expirenza надсилатиме наступне повідомлення:

<details>

<summary>splitOrder</summary>

```json
{
  
    "operation": "splitOrder",
    "rID": "manual16",
    "billId":"4afc3774-cc50-4e07-ad81-dd65f166244a",
    "controlSum":  1080.6,
    "positions": [
        {"id": "8e2ad560-938b-4972-ba60-8098aac99f8b", "quantity": 1},
        {"id": "c53e1948-7ffe-4dea-8e25-9e6773fa8768", "quantity": 1},
        {"id": "0e857f96-d53b-4649-bae0-0674c6d59496", "quantity": 1}
    ]
}
```

</details>

При створенні нового рахунку необхідно:

1. Перенести потрібні позиції
2. Скопіювати знижки (за наявності) в створене замовлення
3. Скопіювати деталі оригінального замовлення:
   * Номер столу
   * Офіціант
   * Тип замовлення

У відповідь в коллбек ми очікуємо 2 рахунки (orders): \
1\) "Parent" - нова версія рахунку після відокремлення страв\
2\) Дочірній об'єкт - те що обрав юзер при розділенні рахунку.

Відповідь обробки операції необхідно надіслати в наступному вигляді, відповідь аналогічна getBill:

{% openapi src="/files/FP4fnp4a478jKwiQabat" path="callback/splitOrder" method="post" %}
[splitOrder03.02.2024\_updated.json](https://115752690-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUrrjxJkhEuwfb0dGwW06%2Fuploads%2FZ188DbP7FKbdFUM7RcZK%2FsplitOrder03.02.2024_updated.json?alt=media\&token=2afa3e86-08f0-49fd-8387-0f80bd0065db)
{% endopenapi %}

<details>

<summary><strong>Payload example: <code>/callback/splitOrder</code></strong></summary>

{% code fullWidth="true" %}

```json
{
    "rID": "manual16",
    "state": "SUCCESS",
    "tableNumber": 1,
    "orders": [
        {
            "billId": "4afc3774-cc50-4e07-ad81-dd65f166244a",
            "orderNumber": 460,
            "totalSum": 720.4,
            "rawSum": 721.0,
            "discounts": {
                "list": [
                    {
                        "id": "4c1e2f7c-09b2-479e-90f9-5e4f67d2665d",
                        "name": "Знижка",
                        "sum": 0.6
                    }
                ]
            },
            "waiterId": "4f433631-2e15-4f05-8a70-e63eda55ce41",
            "waiter": "test",
            "guests": [
                {
                    "name": "Гость 1",
                    "dishes": [
                        {
                            "categoryId": "-1",
                            "category": "Блюдо без категорії",
                            "positionId": "aaa85a2d-8ea4-434a-a235-666bcc0c2d07",
                            "name": "Гриби",
                            "count": 2.0,
                            "sum": 0.0,
                            "orderNumber": 460,
                            "type": "dish",
                            "dishId": "f791662d-e104-4f24-a16a-643d392b7c51"
                        },
                        {
                            "categoryId": "-1",
                            "category": "Блюдо без категорії",
                            "positionId": "9319918b-3582-4de7-b678-4249be2acdcb",
                            "name": "Куриця",
                            "count": 3.0,
                            "sum": 0.0,
                            "orderNumber": 460,
                            "type": "dish",
                            "dishId": "5ea84688-bc1b-4cb1-a107-833f46cbf9cb"
                        },
                        {
                            "categoryId": "-1",
                            "category": "Блюдо без категорії",
                            "positionId": "d8bd2fd9-37ec-4017-9ba8-da686daf57cf",
                            "name": "*",
                            "count": 2.0,
                            "sum": 0.0,
                            "orderNumber": 460,
                            "type": "dish",
                            "dishId": "8edb5f44-969b-4a86-9a78-32c5a5dfba8f"
                        },
                        {
                            "categoryId": "-1",
                            "category": "Блюдо без категорії",
                            "positionId": "a1954115-dc8d-460a-8de5-e6973fe030d0",
                            "name": "Кукурудза",
                            "count": 2.0,
                            "sum": 19.4,
                            "orderNumber": 460,
                            "type": "dish",
                            "dishId": "cf56075a-c4a9-47a4-a279-2284e26afe0b"
                        },
                        {
                            "categoryId": "04e705cf-0f9f-36cd-0183-a2be58c00093",
                            "category": "Фіскальний",
                            "positionId": "d4d3e228-c093-4fc3-8101-d7f8fa8612be",
                            "name": "Kopke",
                            "count": 2.0,
                            "sum": 701.0,
                            "orderNumber": 460,
                            "type": "dish",
                            "dishId": "50391936-2733-48a1-980c-5b7a3c9635f6"
                        }
                    ]
                }
            ],
            "state": "New",
            "tableId": "aaabfb9b-ba7f-076e-0183-59bcbe5a0068",
            "isBanquetOrder": false,
            "isDelivery": false,
            "created": "2023.10.02 14:10:56",
            "bonusSum": 0.0
        },
        {
            "billId": "a11ecd3a-0fa3-4db1-88d6-975cf83da0fb",
            "orderNumber": 461,
            "totalSum": 360.2,
            "rawSum": 360.5,
            "discounts": {
                "list": [
                    {
                        "id": "4c1e2f7c-09b2-479e-90f9-5e4f67d2665d",
                        "name": "Знижка",
                        "sum": 0.3
                    }
                ]
            },
            "waiterId": "4f433631-2e15-4f05-8a70-e63eda55ce41",
            "waiter": "test",
            "guests": [
                {
                    "name": "Гiсть",
                    "dishes": [
                        {
                            "categoryId": "-1",
                            "category": "Блюдо без категорії",
                            "positionId": "8e2ad560-938b-4972-ba60-8098aac99f8b",
                            "name": "*",
                            "count": 1.0,
                            "sum": 0.0,
                            "orderNumber": 461,
                            "type": "dish",
                            "dishId": "8edb5f44-969b-4a86-9a78-32c5a5dfba8f"
                        },
                        {
                            "categoryId": "-1",
                            "category": "Блюдо без категорії",
                            "positionId": "c53e1948-7ffe-4dea-8e25-9e6773fa8768",
                            "name": "Кукурудза",
                            "count": 1.0,
                            "sum": 9.7,
                            "orderNumber": 461,
                            "type": "dish",
                            "dishId": "cf56075a-c4a9-47a4-a279-2284e26afe0b"
                        },
                        {
                            "categoryId": "04e705cf-0f9f-36cd-0183-a2be58c00093",
                            "category": "Фіскальний",
                            "positionId": "0e857f96-d53b-4649-bae0-0674c6d59496",
                            "name": "Kopke",
                            "count": 1.0,
                            "sum": 350.5,
                            "orderNumber": 461,
                            "type": "dish",
                            "dishId": "50391936-2733-48a1-980c-5b7a3c9635f6"
                        }
                    ]
                }
            ],
            "state": "New",
            "tableId": "aaabfb9b-ba7f-076e-0183-59bcbe5a0068",
            "isBanquetOrder": false,
            "isDelivery": false,
            "created": "2023.10.02 14:23:45",
            "bonusSum": 0.0
        }
    ]
}
```

{% endcode %}

</details>

<details>

<summary>F.A.Q</summary>

Q. Як відпрацьовується ситуація, коли одну і ту ж позицію забрали різні гості?

A. Хто перший забрав позицію - той і оплачує. Решта гостей отримають помилку.

***

Q. Чи можна поділити блюдо по 0.5 на гостя? Приклад: Один салат розділити на двох.

A. На цей час це зробити не можливо

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.expirenza.com/api/messages/split-bill.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
