# Для складских операций

#### Инструкции:

* [Как использовать шаблоны из библиотеки и создавать свои шаблоны документов](https://help.keycrm.app/ru/products-and-warehouse-management/kak-sozdat-novyi-shablon-dokumienta-dlia-skladu-dlia-piechati-dlia-administratorov);
* [Справочник доступных тегов, функций и фильтров Twig](https://help.keycrm.app/ru/keycrm-api/spravochnik-dostupnykh-tieghov-funktsii-i-fil-trov-twig);
* [Примеры решений и ответы на частые вопросы](https://help.keycrm.app/ru/products-and-warehouse-management/voprosy-i-otviety-faq-po-sozdaniiu-dokumientov-dlia-skladskikh-opieratsii).

### 1. Оприходование

{% tabs %}
{% tab title="Внешний вид" %}
![](/files/IU5p91ufJG5fIRC5IeVK)
{% endtab %}

{% tab title="Код шаблона" %}
**Тип шаблона:** Складские операции.

```
<!doctype html>
<html lang="uk">
<head>
    <meta charset="UTF-8">
    <title>Оприходование товаров</title>
</head>
<body>

<div class="container">

    <!-- Заголовок -->
    <h2 class="text-center">АКТ ОПРИХОДОВАНИЯ ТОВАРОВ №: {{ model.id }}</h2>

    <br>

    <!-- Демо реквизиты компании -->
    <table class="width100">
        <tr>
            <td valign="top" class="label" style="width:50%">
                <span style="background-color: yellow">Поставщик: Ваша компания</span><br />
                <span style="background-color: yellow">ФЛП / ООО</span><br />
                <span style="background-color: yellow">г. Киев, ул. Примерная, 1</span><br />
                <span style="background-color: yellow">тел.: (000)000-00-00</span><br />
            </td>

            <td valign="top">
                <strong>Дата:</strong> {{ model.created_at|date("d.m.Y H:i") }}<br>
                <strong>Тип операции:</strong> {{ model.event }}<br>
                <strong>Менеджер:</strong> {{ model.manager }}<br>
                <strong>Склад:</strong> {{ model.destination }}
            </td>
        </tr>
    </table>

    {% if model.comment %}
        <br>
        <strong>Комментарий:</strong> {{ model.comment }}
    {% endif %}

    <br><br>

    <!-- Таблица товаров -->
    <table class="width100 border">
        <thead>
        <tr>
            <th>№</th>
            <th>Изображение</th>
            <th>Артикул</th>
            <th>Название товара</th>
            <th>Закупочная цена</th>
            <th>Количество</th>
            <th>Сумма закупки</th>
        </tr>
        </thead>
        <tbody>

        {% set total = 0 %}
        {% set total_qty = 0 %}
        {% set currency = model.inventories[0].currency_code ?? 'UAH' %}

        {% for key, inventory in model.inventories %}
            {% set row_sum = inventory.quantity * inventory.price %}
            {% set total = total + row_sum %}
            {% set total_qty = total_qty + inventory.quantity %}

            <tr>
                <td class="text-center">{{ key + 1 }}</td>
                <td class="text-center"><img src="{{ inventory.offer_picture }}" style="width: 60px;"></td>
                <td class="text-center">{{ inventory.offer_sku }}</td>
                <td class="text-center">{{ inventory.product_name }}</td>
                <td class="text-center">
                    {{ inventory.price|format_currency(currency, locale='uk') }}
                </td>
                <td class="text-center">{{ inventory.quantity }}</td>
                <td class="text-center">
                    {{ row_sum|format_currency(currency, locale='uk') }}
                </td>
            </tr>
        {% endfor %}

        </tbody>

        <!-- Итоги -->
<tfoot>
<tr>
    <td colspan="5" class="text-right"><strong>Итого:</strong></td>
    <td class="text-center"><strong>{{ total_qty }} {{ model.inventories[0].product_unit_type ?? '' }}</strong></td>
    <td class="text-center">
        <strong>{{ total|format_currency(currency, locale='uk') }}</strong>
    </td>
</tr>
</tfoot>
    </table>

    <br><br>

<!-- Дополнительный итог -->
   <p>
    <strong>Всего позиций:</strong> {{ model.inventories|length }} <br>
    
    <strong>Общее количество:</strong> 
    {{ total_qty }} 
    {{ model.inventories[0].product_unit_type ?? '' }} <br>
    
    <strong>Общая сумма закупки:</strong> 
    {{ total|format_currency(currency, locale='uk') }}
</p>

    <br><br>

    <!-- Подписи -->
    <table class="width100">
        <tr>
            <td>Принял: _______________________</td>
            <td class="text-right">Подпись: _______________________</td>
        </tr>
    </table>

</div>

</body>

<style>
    body {
        font-family: sans-serif;
        font-size: 14px;
    }

    .container {
        width: 100%;
    }

    .text-center {
        text-align: center;
    }

    .text-right {
        text-align: right;
    }

    .label {
        font-weight: bold;
    }

    table {
        border-collapse: collapse;
        width: 100%;
    }

    th, td {
        border: 1px solid #000;
        padding: 6px;
    }

    th {
        background: #eee;
    }

    .border {
        border: 2px solid #000;
    }
</style>

</html>
```

{% endtab %}
{% endtabs %}

### 2. Перемещение

{% tabs %}
{% tab title="Внешний вид" %}
![](/files/U9oMQqbN3WHmA7eG8s65)
{% endtab %}

{% tab title="Код шаблона" %}
**Тип шаблона:** Складские операции.

{% code fullWidth="true" %}

```
<!doctype html>
<html lang="uk">
<head>
    <meta charset="UTF-8">
    <title>Перемещение товаров</title>
</head>
<body>

<div class="container">

    <!-- Заголовок -->
    <h2 class="text-center">
        НАКЛАДНАЯ ПЕРЕМЕЩЕНИЯ №: {{ model.id }}
    </h2>

    <br>

    <!-- Демо реквизиты -->
    <table class="width100">
        <tr>
            <td valign="top" class="label" style="width:50%">
                <span style="background-color: yellow">Ваша компания</span><br />
                <span style="background-color: yellow">ФЛП / ООО</span><br />
                <span style="background-color: yellow">г. Киев, ул. Примерная, 1</span><br />
                <span style="background-color: yellow">тел.: (000)000-00-00</span><br />
            </td>

            <td valign="top">
                <strong>Дата:</strong> {{ model.created_at|date("d.m.Y H:i") }}<br>
                <strong>Менеджер:</strong> {{ model.manager }}<br>
                <strong>Тип:</strong> {{ model.event }}
            </td>
        </tr>
    </table>

    <br>

    <!-- Склады -->
    <table class="width100 border">
        <tr>
            <td>
                <strong>Склад-отправитель:</strong><br>
                {{ model.target }}
            </td>
            <td>
                <strong>Склад-получатель:</strong><br>
                {{ model.destination }}
            </td>
        </tr>
    </table>

    {% if model.comment %}
        <br>
        <strong>Комментарий:</strong> {{ model.comment }}
    {% endif %}

    <br><br>

    <!-- Таблица товаров -->
    <table class="width100 border">
        <thead>
        <tr>
            <th>№</th>
            <th>Изображение</th>
            <th>Артикул</th>
            <th>Название товара</th>
            <th>Ед.</th>
            <th>Количество (отправлено)</th>
            <th>Количество (получено)</th>
            <th>Цена</th>
            <th>Сумма</th>
        </tr>
        </thead>
        <tbody>

        {% set total = 0 %}
        {% set total_qty = 0 %}
        {% set currency = model.inventories[0].currency_code ?? 'UAH' %}

        {% for key, inventory in model.inventories %}
            {% set row_sum = inventory.quantity * inventory.price %}
            {% set total = total + row_sum %}
            {% set total_qty = total_qty + inventory.quantity %}

            <tr>
                <td class="text-center">{{ key + 1 }}</td>
                <td class="text-center">
                    <img src="{{ inventory.offer_picture }}" style="width: 50px;">
                </td>
                <td class="text-center">{{ inventory.offer_sku }}</td>
                <td>{{ inventory.product_name }}</td>
                <td class="text-center">{{ inventory.product_unit_type }}</td>

                <!-- отправлено -->
                <td class="text-center">
                    {{ inventory.quantity }}
                </td>

                <!-- получено (пустое для заполнения) -->
                <td class="text-center">
                    __________
                </td>

                <td class="text-right">
                    {{ inventory.price|format_currency(currency, locale='uk') }}
                </td>

                <td class="text-right">
                    {{ row_sum|format_currency(currency, locale='uk') }}
                </td>
            </tr>
        {% endfor %}

        </tbody>

        <!-- Итоги -->
        <tfoot>
        <tr>
            <td colspan="5" class="text-right"><strong>Итого:</strong></td>
            <td class="text-center">
                <strong>{{ total_qty }}</strong>
            </td>
            <td></td>
            <td></td>
            <td class="text-right">
                <strong>{{ total|format_currency(currency, locale='uk') }}</strong>
            </td>
        </tr>
        </tfoot>
    </table>

    <br><br>

    <!-- Дополнительный итог -->
    <p>
        <strong>Всего позиций:</strong> {{ model.inventories|length }} <br>

        <strong>Отправлено:</strong>
        {{ total_qty }} {{ model.inventories[0].product_unit_type ?? '' }} <br>

        <strong>Сумма товаров:</strong>
        {{ total|format_currency(currency, locale='uk') }}
    </p>

    <br><br>

    <!-- Подписи -->
    <table class="width100">
        <tr>
            <td>
                Отгрузил (склад-отправитель): <br><br>
                _______________________
            </td>

            <td>
                Принял (склад-получатель): <br><br>
                _______________________
            </td>
        </tr>
    </table>

</div>

</body>

<style>
    body {
        font-family: sans-serif;
        font-size: 14px;
    }

    .container {
        width: 100%;
    }

    .text-center {
        text-align: center;
    }

    .text-right {
        text-align: right;
    }

    .label {
        font-weight: bold;
    }

    table {
        border-collapse: collapse;
        width: 100%;
    }

    th, td {
        border: 1px solid #000;
        padding: 6px;
    }

    th {
        background: #eee;
    }

    .border {
        border: 2px solid #000;
    }
</style>

</html>
```

{% endcode %}
{% endtab %}
{% endtabs %}

### 3. Инвентаризация

{% tabs %}
{% tab title="Внешний вид" %}
![](/files/vUucLuHplU8SK8dIdIn5)
{% endtab %}

{% tab title="Код шаблона" %}
**Тип шаблона:** Складские операции.

```
<!doctype html>
<html lang="uk">
<head>
    <meta charset="UTF-8">
    <title>Инвентаризация</title>
</head>
<body>

<div class="container">

    <!-- Заголовок -->
    <h2 class="text-center">
        АКТ ИНВЕНТАРИЗАЦИИ №: {{ model.id }}
    </h2>

    <br>

    <!-- Демо реквизиты -->
    <table class="width100">
        <tr>
            <td valign="top" class="label" style="width:50%">
                <span style="background-color: yellow">Ваша компания</span><br />
                <span style="background-color: yellow">ФЛП / ООО</span><br />
                <span style="background-color: yellow">г. Киев, ул. Примерная, 1</span><br />
                <span style="background-color: yellow">тел.: (000)000-00-00</span><br />
            </td>

            <td valign="top">
                <strong>Дата:</strong> {{ model.created_at|date("d.m.Y H:i") }}<br>
                <strong>Менеджер:</strong> {{ model.manager }}<br>
                <strong>Склад:</strong> {{ model.destination }}<br>
                <strong>Тип:</strong> {{ model.event }}
            </td>
        </tr>
    </table>

    {% if model.comment %}
        <br>
        <strong>Комментарий:</strong> {{ model.comment }}
    {% endif %}

    <br><br>

    <!-- Таблица -->
    <table class="width100 border">
        <thead>
        <tr>
            <th>№</th>
            <th>Изображение</th>
            <th>Артикул</th>
            <th>Название товара</th>
            <th>Ед.</th>
            <th>Было в системе</th>
            <th>Фактически</th>
            <th>Разница</th>
        </tr>
        </thead>
        <tbody>

       {% set total_system = 0 %}
{% set total_fact = 0 %}
{% set total_diff = 0 %}

{% for key, inventory in model.inventories %}

    {% set system_qty = inventory.quantity_before ? inventory.quantity_before : 0 %}

    {# quantity = это разница #}
    {% set diff = inventory.quantity ? inventory.quantity : 0 %}

    {# фактический остаток = было + разница #}
    {% set fact_qty = system_qty + diff %}

    {% set total_system = total_system + system_qty %}
    {% set total_fact = total_fact + fact_qty %}
    {% set total_diff = total_diff + diff %}

    <tr>
        <td class="text-center">{{ key + 1 }}</td>

        <td class="text-center">
            <img src="{{ inventory.offer_picture }}" style="width: 50px;">
        </td>

        <td class="text-center">{{ inventory.offer_sku }}</td>

        <td>
            {{ inventory.product_name }}
        </td>

        <td class="text-center">{{ inventory.product_unit_type }}</td>

        <!-- было -->
        <td class="text-center">
            {{ system_qty }}
        </td>

        <!-- фактически -->
        <td class="text-center">
            {{ fact_qty }}
        </td>

        <!-- разница -->
        <td class="text-center">
            {% if diff > 0 %}
                +{{ diff }}
            {% else %}
                {{ diff }}
            {% endif %}
        </td>
    </tr>

{% endfor %}

        </tbody>

        <!-- Итоги -->
        <tfoot>
        <tr>
            <td colspan="5" class="text-right"><strong>Итого:</strong></td>

            <td class="text-center">
                <strong>{{ total_system }}</strong>
            </td>

            <td class="text-center">
                <strong>{{ total_fact }}</strong>
            </td>

            <td class="text-center">
                <strong>
                    {% if total_diff > 0 %}
                        +{{ total_diff }}
                    {% else %}
                        {{ total_diff }}
                    {% endif %}
                </strong>
            </td>
        </tr>
        </tfoot>
    </table>

    <br><br>

    <!-- Дополнительный итог -->
    <p>
        <strong>Всего позиций:</strong> {{ model.inventories|length }} <br>

        <strong>Было в системе:</strong>
        {{ total_system }} {{ model.inventories[0].product_unit_type ?? '' }} <br>

        <strong>Фактически:</strong>
        {{ total_fact }} {{ model.inventories[0].product_unit_type ?? '' }} <br>

        <strong>Разница:</strong>
        {% if total_diff > 0 %}
            +{{ total_diff }}
        {% else %}
            {{ total_diff }}
        {% endif %}
    </p>

    <br><br>

    <!-- Подписи -->
    <table class="width100">
        <tr>
            <td>
                Провёл инвентаризацию: <br><br>
                _______________________
            </td>

            <td>
                Проверил: <br><br>
                _______________________
            </td>
        </tr>
    </table>

</div>

</body>

<style>
    body {
        font-family: sans-serif;
        font-size: 14px;
    }

    .container {
        width: 100%;
    }

    .text-center {
        text-align: center;
    }

    .text-right {
        text-align: right;
    }

    .label {
        font-weight: bold;
    }

    table {
        border-collapse: collapse;
        width: 100%;
    }

    th, td {
        border: 1px solid #000;
        padding: 6px;
    }

    th {
        background: #eee;
    }

    .border {
        border: 2px solid #000;
    }
</style>

</html>
```

{% endtab %}
{% endtabs %}


---

# 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://templates.keycrm.app/ru/sklad.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.
