<Orders>
   <UpdateOrder>
       <Function>{{ function_value }}</Function>
       <ErrorLevel>2</ErrorLevel>
       <ReferenceNumber>{{ reference_number }}</ReferenceNumber>
       <CheckNumber>{{ ticket_number }}</CheckNumber>
       {%- if sub_ticket_number %}
       <SubCheckNumber>{{sub_ticket_number}}</SubCheckNumber>
       {%- endif %}
       <Check>
           <CheckHeader>
           </CheckHeader>
            {%- for discount in discounts %}
                {%- if discount.is_true_open_discount %}
                    {%- if discount.type == 'dollar' %}
                    <OpenDollarDiscItem>
                        {%- if '-' in discount.menu_item_id|string() %}
                        <ScreenCell>{{ discount.menu_item_id.replace('-', ',') }}</ScreenCell>
                        {%- else %}
                        <ItemNumber>{{ discount.menu_item_id }}</ItemNumber>
                        {%- endif %}
                        <OpenDollarDiscAmt>{{ discount.value }}</OpenDollarDiscAmt>
                    </OpenDollarDiscItem>
                    {%- else %}
                    <OpenPercentDiscItem>
                        {%- if '-' in discount.menu_item_id|string() %}
                        <ScreenCell>{{ discount.menu_item_id.replace('-', ',') }}</ScreenCell>
                        {%- else %}
                        <ItemNumber>{{ discount.menu_item_id }}</ItemNumber>
                        {%- endif %}
                        <OpenPercentDiscPct>{{ discount.value }}</OpenPercentDiscPct>
                    </OpenPercentDiscItem>
                    {%- endif %}
                {%- else %}
                <ItemDetail>
                    {%- if '-' in discount.menu_item_id|string() %}
                    <ScreenCell>{{ discount.menu_item_id.replace('-', ',') }}</ScreenCell>
                    {%- else %}
                    <ItemNumber>{{ discount.menu_item_id }}</ItemNumber>
                    {%- endif %}
                    <Quantity>{{ discount.quantity or 1 }}</Quantity>
                    {%- if discount.value %}
                    <Price>{{ discount.value }}</Price>
                    {%- endif %}
                </ItemDetail>
                {%- endif %}
                {%- if not discount.is_true_open_discount %}
                    {%- if discount.comment %}
                        <ItemDetail>
                            {%- if '-' in comment_id|string() -%}
                            <ScreenCell>{{ comment_id.replace('-', ',') }}</ScreenCell>
                            {%- else %}
                            <ItemNumber>{{ comment_id }}</ItemNumber>
                            {%- endif %}
                            <Memo>{{ discount.comment[0:23] + '_' }}</Memo>
                        </ItemDetail>
                    {%- endif %}
                    {%- for modifier in discount.modifiers %}
                        <ItemDetail>
                            {%- if '-' in modifier.modifier_id|string() %}
                            <ScreenCell>{{ modifier.modifier_id.replace('-', ',') }}</ScreenCell>
                            {%- else %}
                            <ItemNumber>{{ modifier.modifier_id }}</ItemNumber>
                            {%- endif %}
                            <Quantity>{{ modifier.quantity }}</Quantity>
                            {%- if modifier.memo_comment %}
                            <Memo>{{ modifier.memo_comment[0:24] }}</Memo>
                            {%- elif modifier.item_comment %}
                            <Memo>{{ modifier.item_comment[0:23] + '_' }}</Memo>
                            {%- endif %}
                        </ItemDetail>
                        {%- if modifier.comment %}
                        <ItemDetail>
                            {%- if '-' in comment_id|string() %}
                            <ScreenCell>{{ comment_id.replace('-', ',') }}</ScreenCell>
                            {%- else %}
                            <ItemNumber>{{ comment_id }}</ItemNumber>
                            {%- endif %}
                            <Memo>{{ modifier.comment[0:23] + '_' }}</Memo>
                        </ItemDetail>
                        {%- endif %}
                    {%- endfor %}
                {%- endif %}
           {%- endfor %}
       </Check>
   </UpdateOrder>
</Orders>
