<?xml version="1.0"?>
<AddToOrder
    version="{{ xml_gateway_version|default('1.50', true) }}"
    device="102"
>
    <Order
        badge="{{ employee }}"
        department="{{ department }}"
        table="{{ table }}"
        {%- if name %}
        name="{{ name }}"
        {%- endif %}
        {%- if guest_count %}
        covers="{{ guest_count }}"
        {%- endif %}
    >
        {%- if user_info %}
        <Member
            account="{{ user_info.account_number }}"
            lastname="{{ user_info.last_name }}"
            firstname="{{ user_info.first_name }}"
        />
        {%- endif %}
        <Department num="{{ department }}">
            <Seat num="1">
                {%- for item in items %}
                <Item
                    id="{{ item.menu_item_id }}"
                    {%- if item.menu_item.open %}
                    price="{{ cents_to_dollars(item.price_per_unit) }}"
                    {%- endif %}
                    {%- if item.discounts %}
                    promo="{{ item.discounts[0].discount_id }}"
                    {%- endif %}
                    {%- if item.comment %}
                    name="{{ item.comment }}"
                    {%- endif %}
                />
                {%- if item.quantity > 1 %}
                <Qty amount="{{ convert_to_squirrel_decimal(item.quantity) }}" />
                {%- endif %}
                {%- for modifier in item.modifiers %}
                <Item id="{{ modifier.menu_modifier_id }}"
                    {%- if modifier.menu_modifier.open %}
                    price="{{ cents_to_dollars(modifier.price_per_unit) }}"
                    {%- endif %}
                />
                {%- endfor %}
                {%- endfor %}

                {%- for discount in discounts %}
                <Promo id="{{ discount.discount_id }}" />
                {%- endfor %}
            </Seat>
        </Department>
        {%- for payment in payments %}
        <Payment
            id="{{ payment.tender_type_id }}"
            amount="{{ payment.amount }}"
            tip="{{ payment.tip }}"
            {% if payment.type == "card" %}
            account="{{ payment.account }}"
            expiration="{{ payment.expiration }}"
            cvv="{{ payment.cvv }}"
            {% endif %}
        />
        {%- endfor %}
    </Order>
</AddToOrder>