{%- import "macros.jinja2" as macros %}
<Orders>
    {{ macros.emit_user_info(user_info) }}
    <NewOrder>
        <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>
                {%- if terminal_number %}
                <TerminalNumber>{{ terminal_number }}</TerminalNumber>
                {%- endif %}
                {%- if user_info %}
                <Account>
                    <AccountNumber>{{ user_info.account_number or '' }}</AccountNumber>
                    <LastName>{{ user_info.last_name|e or '' }}</LastName>
                    <FirstName>{{ user_info.first_name|e or '' }}</FirstName>
                    <MiddleInitial>{{ user_info.middle_initial|e or '' }}</MiddleInitial>
                </Account>
                {%- endif %}
                {%- if fire_time %}
                <AdvanceOrderDate>{{ fire_date }}</AdvanceOrderDate>
                <AdvanceOrderTime>{{ fire_time }}</AdvanceOrderTime>
                {%- if fire_offset %}
                <AdvanceOrderOffset>{{ fire_offset }}</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>