<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <PostTransactionEx xmlns="http://micros-hosting.com/EGateway/">
            <vendorCode />
            <pGuestCheck>
                {%- if fire_date_time %}
                <CheckDateToFire>{{ fire_date_time }}</CheckDateToFire>
                {%- endif %}
                {%- if check_status_bits is not none %}
                <CheckStatusBits>{{ check_status_bits }}</CheckStatusBits>
                {%- endif %}
                <CheckEmployeeObjectNum>{{ employee_num }}</CheckEmployeeObjectNum>
                {%- if guest_count is not none %}
                <CheckGuestCount>{{ guest_count }}</CheckGuestCount>
                {%- endif %}
                <CheckOrderType>{{ order_type }}</CheckOrderType>
                <CheckRevenueCenterID>{{ revenue_center }}</CheckRevenueCenterID>
                {%- if table_number is not none %}
                <CheckTableObjectNum>{{ table_number }}</CheckTableObjectNum>
                {%- endif %}
                {%- if name is not none %}
                <CheckID>{{ name }}</CheckID>
                {%- endif %}
            </pGuestCheck>
            <ppMenuItems>
                {%- if items is not none %}
                {%- for item in items %}
                <SimphonyPosApi_MenuItem>
                    {%- if item.modifiers %}
                    <Condiments>
                        {%- for modifier in item.modifiers %}
                        <SimphonyPosApi_MenuItemDefinition>
                            <ItemDiscount>
                                <DiscObjectNum>0</DiscObjectNum>
                            </ItemDiscount>
                            {% set mod_obj_num = modifier.menu_modifier.id.split('-')[0] %}
                            <MiObjectNum>{{ mod_obj_num }}</MiObjectNum>
                            {%- if modifier.comment is not none %}
                            <MiReference>{{ modifier.comment }}</MiReference>
                            {%- endif %}
                            <MiWeight />
                            <MiMenuLevel>{{ modifier.main_level }}</MiMenuLevel>
                            <MiSubLevel>{{ modifier.sub_level }}</MiSubLevel>
                            {%- if modifier.price_per_unit is not none %}
                            <MiOverridePrice>{{ cents_to_dollars(modifier.price_per_unit) }}</MiOverridePrice>
                            {%- endif %}
                        </SimphonyPosApi_MenuItemDefinition>
                        {%- endfor %}
                    </Condiments>
                    {%- endif %}
                    <MenuItem>
                        {%- for item_discount in item.discounts %}
                        <ItemDiscount>
                            <DiscAmountOrPercent>{{ get_micros_discount_price(item_discount) }}</DiscAmountOrPercent>
                            <DiscObjectNum>{{ item_discount.discount.id }}</DiscObjectNum>
                            {%- if item_discount.comment is not none %}
                            <DiscReference>{{ item_discount.comment }}</DiscReference>
                            {%- endif %}
                        </ItemDiscount>
                        {%- endfor %}
                        {% set mi_obj_num = item.menu_item.id.split('-')[0] %}
                        <MiObjectNum>{{ mi_obj_num }}</MiObjectNum>
                        {%- if item.comment is not none %}
                        <MiReference>{{ item.comment }}</MiReference>
                        {%- endif %}
                        <MiWeight />
                        <MiMenuLevel>{{ item.main_level }}</MiMenuLevel>
                        <MiSubLevel>{{ item.sub_level }}</MiSubLevel>
                        <MiPriveLevel>0</MiPriveLevel>
                        {%- if item.price_per_unit is not none %}
                        <MiOverridePrice>{{ cents_to_dollars(item.price_per_unit) }}</MiOverridePrice>
                        {%- endif %}
                    </MenuItem>
                </SimphonyPosApi_MenuItem>
                {%- endfor %}
                {%- endif %}
            </ppMenuItems>
            <ppComboMeals>
                {%- for combo in combos %}
                {%- set combo_generated_item = combo.generated_item %}
                <SimphonyPosApi_ComboMeal>
                    <ComboMealObjectNum>{{ combo.menu_combo.id }}</ComboMealObjectNum>
                    <ComboMealMenuItem>
                        <Condiments>
                            {%- for modifier in combo_generated_item.modifiers %}
                            <SimphonyPosApi_MenuItemDefinition>
                                <ItemDiscount>
                                    <DiscObjectNum>0</DiscObjectNum>
                                </ItemDiscount>
                                {% set mod_obj_num = modifier.menu_modifier.id.split('-')[0] %}
                                <MiObjectNum>{{ mod_obj_num }}</MiObjectNum>
                                {%- if modifier.comment is not none %}
                                <MiReference>{{ modifier.comment }}</MiReference>
                                {%- endif %}
                                <MiWeight />
                                <MiMenuLevel>{{ modifier.main_level }}</MiMenuLevel>
                                <MiSubLevel>{{ modifier.sub_level }}</MiSubLevel>
                                {%- if modifier.price_per_unit is not none %}
                                <MiOverridePrice>{{ cents_to_dollars(modifier.price_per_unit) }}</MiOverridePrice>
                                {%- endif %}
                            </SimphonyPosApi_MenuItemDefinition>
                            {%- endfor %}
                        </Condiments>
                        <MenuItem>
                            <ItemDiscount>
                                <DiscObjectNum>0</DiscObjectNum>
                            </ItemDiscount>
                            {% set combo_generated_item_obj_num = combo_generated_item.menu_combo_item.menu_item.id.split('-')[0] %}
                            <MiObjectNum>{{ combo_generated_item_obj_num }}</MiObjectNum>
                            {%- if combo_generated_item.comment is not none %}
                            <MiReference>{{ combo_generated_item.comment }}</MiReference>
                            {%- endif %}
                            <MiWeight />
                            <MiMenuLevel>0</MiMenuLevel>
                            <MiSubLevel>0</MiSubLevel>
                            <MiPriveLevel>0</MiPriveLevel>
                        </MenuItem>
                    </ComboMealMenuItem>
                    {%- set combo_main_item = combo.order_items[0] %}
                    <ComboMealMainItem>
                        <Condiments>
                            {%- for modifier in combo_main_item.modifiers %}
                            <SimphonyPosApi_MenuItemDefinition>
                                <ItemDiscount>
                                    <DiscObjectNum>0</DiscObjectNum>
                                </ItemDiscount>
                                {% set mod_obj_num = modifier.menu_modifier.id.split('-')[0] %}
                                <MiObjectNum>{{ mod_obj_num }}</MiObjectNum>
                                {%- if modifier.comment is not none %}
                                <MiReference>{{ modifier.comment }}</MiReference>
                                {%- endif %}
                                <MiWeight />
                                <MiMenuLevel>{{ modifier.main_level }}</MiMenuLevel>
                                <MiSubLevel>{{ modifier.sub_level }}</MiSubLevel>
                                {%- if modifier.price_per_unit is not none %}
                                <MiOverridePrice>{{ cents_to_dollars(modifier.price_per_unit) }}</MiOverridePrice>
                                {%- endif %}
                            </SimphonyPosApi_MenuItemDefinition>
                            {%- endfor %}
                        </Condiments>
                        <MenuItem>
                            <ItemDiscount>
                                <DiscObjectNum>0</DiscObjectNum>
                            </ItemDiscount>
                            {% set combo_main_mi_obj_num = combo_main_item.menu_combo_item.id.split('-')[1] %}
                            <MiObjectNum>{{ combo_main_mi_obj_num }}</MiObjectNum>
                            {%- if combo_main_item.comment is not none %}
                            <MiReference>{{ combo_main_item.comment }}</MiReference>
                            {%- endif %}
                            <MiWeight />
                            <MiMenuLevel>{{ combo_main_item.main_level }}</MiMenuLevel>
                            <MiSubLevel>{{ combo_main_item.sub_level }}</MiSubLevel>
                            <MiPriveLevel>0</MiPriveLevel>
                        </MenuItem>
                    </ComboMealMainItem>
                    <SideItems>
                        {%- for item in combo.order_items[1:] %}
                        <SimphonyPosApi_MenuItem>
	                        <Condiments>
                                {%- for modifier in item.modifiers %}
                                <SimphonyPosApi_MenuItemDefinition>
                                    <ItemDiscount>
                                        <DiscObjectNum>0</DiscObjectNum>
                                    </ItemDiscount>
                                    {% set mod_obj_num = modifier.menu_modifier.id.split('-')[0] %}
                                    <MiObjectNum>{{ mod_obj_num }}</MiObjectNum>
                                    {%- if modifier.comment is not none %}
                                    <MiReference>{{ modifier.comment }}</MiReference>
                                    {%- endif %}
                                    <MiWeight />
                                    <MiMenuLevel>{{ modifier.main_level }}</MiMenuLevel>
                                    <MiSubLevel>{{ modifier.sub_level }}</MiSubLevel>
                                    {%- if modifier.price_per_unit is not none %}
                                    <MiOverridePrice>{{ cents_to_dollars(modifier.price_per_unit) }}</MiOverridePrice>
                                    {%- endif %}
                                </SimphonyPosApi_MenuItemDefinition>
                                {%- endfor %}
                            </Condiments>
	                        <MenuItem>
                                <ItemDiscount>
                                    <DiscObjectNum>0</DiscObjectNum>
                                </ItemDiscount>
                                {% set mi_obj_num = item.menu_combo_item.id.split('-')[1] %}
                                <MiObjectNum>{{ mi_obj_num }}</MiObjectNum>
                                {%- if item.comment is not none %}
                                <MiReference>{{ item.comment }}</MiReference>
                                {%- endif %}
                                <MiWeight />
                                <MiMenuLevel>{{ item.main_level }}</MiMenuLevel>
                                <MiSubLevel>{{ item.sub_level }}</MiSubLevel>
                                <MiPriveLevel>0</MiPriveLevel>
	                        </MenuItem>
	                    </SimphonyPosApi_MenuItem>
                        {%- endfor %}
                    </SideItems>
                </SimphonyPosApi_ComboMeal>
                {%- endfor %}
            </ppComboMeals>
            {%- if service_charge is defined and service_charge is not none %}
            <pServiceChg>
                <SvcChgObjectNum>{{ service_charge.service_charge.id }}</SvcChgObjectNum>
                <SvcChgAmountOrPercent>{{ get_micros_service_charge_price(service_charge) }}</SvcChgAmountOrPercent>
                {%- if service_charge.comment is not none %}
                <SvcChgReference>{{ service_charge.comment }}</SvcChgReference>
                {%- endif %}
            </pServiceChg>
            {%- endif %}
            {%- if ticket_discount is defined and ticket_discount is not none %}
            <pSubTotalDiscount>
                <DiscObjectNum>{{ ticket_discount.discount.id }}</DiscObjectNum>
                <DiscAmountOrPercent>{{ get_micros_discount_price(ticket_discount) }}</DiscAmountOrPercent>
                {%- if ticket_discount.comment is not none %}
                <DiscReference>{{ ticket_discount.comment }}</DiscReference>
                {%- endif %}
            </pSubTotalDiscount>
            {%- endif %}
            <pTmedDetail>
                {%- if payment is defined and payment is not none %}
                <TmedEPayment>
                    <AccountDataSource>SOURCE_UNDEFINED</AccountDataSource>
                    <AccountType>ACCOUNT_TYPE_UNDEFINED</AccountType>
                    <ExpirationDate>0001-01-01T00:00:00</ExpirationDate>
                    <IssueNumber>0</IssueNumber>
                    <PaymentCommand>NO_E_PAYMENT</PaymentCommand>
                    <TipAmount>{{ cents_to_dollars(payment['tip']) }}</TipAmount>
                    <StartDate>0001-01-01T00:00:00</StartDate>
                </TmedEPayment>
                <TmedObjectNum>{{ payment['tender_type'].id }}</TmedObjectNum>
                <TmedPartialPayment>{{ cents_to_dollars(payment['amount']) }}</TmedPartialPayment>
                {%- if payment['comment'] is not none %}
                <TmedReference>{{ payment['comment'] }}</TmedReference>
                {%- endif %}
                {%- else %}
                <TmedEPayment></TmedEPayment>
                <TmedObjectNum>{{ save_check_tender }}</TmedObjectNum>
                {%- endif %}
            </pTmedDetail>
        </PostTransactionEx>
    </soap:Body>
</soap:Envelope>
