{%- import "macros.jinja2" as macros %}
<Orders>
    {%- if user_info and account_maintenance %}
    <AccountMaintenance>
        <AccountDetail>
            {{ macros.emit_user_info(user_info) }}
        </AccountDetail>
    </AccountMaintenance>
    {%- endif %}
    <NewOrder>
        {%- if has_account_number and default_payment_type %}
        <DefaultPaymentType>{{ default_payment_type }}</DefaultPaymentType>
        {%- endif %}
        <Function>{{ function_value }}</Function>
        <ErrorLevel>2</ErrorLevel>
        <ReferenceNumber>{{ reference_number }}</ReferenceNumber>
        <Check>
            <CheckHeader>
                <TableNumber>{{ table_number }}</TableNumber>
                <CostCenter>{{ revenue_center }}</CostCenter>
                <ServerNumber>{{ server_number }}</ServerNumber>
                <NumberInParty>{{ number_in_party }}</NumberInParty>
                <TerminalNumber>{{ terminal_number }}</TerminalNumber>
                {%- if user_info %}
                <Account>
                    {{ macros.emit_user_info(user_info) }}
                </Account>
                {%- endif %}
                {%- if ready_time %}
                <AdvanceOrderDate>{{ ready_date }}</AdvanceOrderDate>
                <AdvanceOrderTime>{{ ready_time }}</AdvanceOrderTime>
                {%- if prep_time_minutes %}
                <AdvanceOrderOffset>{{ prep_time_minutes }}</AdvanceOrderOffset>
                {%- endif %}
                {%- endif %}
            </CheckHeader>
            {%- if ticket_name and ticket_name_item and ticket_name_modifier %}
            <ItemDetail>
                {{ macros.id_node(ticket_name_item) }}
                <Quantity>1</Quantity>
                <ItemName>NAME</ItemName>
            </ItemDetail>
            <ItemDetail>
                {{ macros.id_node(ticket_name_modifier) }}
                <Quantity>1</Quantity>
                <ItemName>NAME</ItemName>
                <Memo>{{ ticket_name|e }}</Memo>
            </ItemDetail>
            {%- endif %}
        </Check>
    </NewOrder>
</Orders>