<?xml version="1.0"?>
<PriceOrder
    version="{{ xml_gateway_version|default('1.80', true) }}"
    device="102"
>
    <Order
        badge="{{ employee }}"
        department="{{ department }}"
        table="{{ table }}"
        {%- if guest_count %}
        covers="{{ guest_count }}"
        {%- endif %}
    >
        <Department num="{{ department }}">
            {%- for seat_num, seat_entities in entities_by_seat.iteritems() %}
            <Seat num="{{ seat_num }}">
                {%- for item in seat_entities['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 %}
                    {%- if modifier.comment %}
                    name="{{ modifier.comment }}"
                    {%- endif %}
                />
                {%- endfor %}
                {%- endfor %}

                {%- for discount in seat_entities['ticket_discounts']%}
                <Promo id="{{ discount.discount_id }}" />
                {%- endfor %}
            </Seat>
            {%- endfor %}
        </Department>
    </Order>
</PriceOrder>