<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <data>
        <template id="point_of_sale.pos_order_receipt">
            <html id="pos-receipt">
                <head>
                    <meta charset="UTF-8"></meta>  <!--  Needed for wkhtmltoimage to render UTF-8 characters properly -->
                    <t t-call="point_of_sale.pos_order_receipt_style" />
                </head>
                <div style="padding-left: 3px; padding-right: 3px;">
                    <div class="w-100 text-normal mb-3">
                        <t t-call="point_of_sale.pos_order_receipt_header" />
                        <div class="w-100 mt-3">
                            <table t-foreach="lines" t-as="line" style="width:100%" t-att-class="{'mt-2': not line['combo_parent_id'], 'mt-1': line['combo_parent_id']}">
                                <tbody>
                                    <t t-call="point_of_sale.pos_orderline_receipt" />
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="w-100 mb-3" name="prices" t-if="not conditions['basic_receipt']">
                        <table class="w-100 text-large">
                            <tbody>
                                <tr>
                                    <td class="text-start w-70" name="subtotal">Subtotal:</td>
                                    <td class="text-end w-30"><t t-out="extra_data['prices']['subtotal_amount']" /></td>
                                </tr>
                                <t t-foreach="extra_data['prices']['taxes']" t-as="tax">
                                    <tr name="taxes_line">
                                        <td class="text-start w-70">
                                            <span><t t-out="tax['name']" /></span>
                                        </td>
                                        <td class="text-end w-30 text-break">
                                            <span class="font-monospace"><t t-out="tax['amount']" /></span>
                                        </td>
                                    </tr>
                                    <tr t-if="not extra_data['prices']['same_tax_base']">
                                        <td class="text-start w-70">
                                            <span>Base <t t-out="tax['name']" /></span>
                                        </td>
                                        <td class="text-end w-30 text-break">
                                            <span class="font-monospace"><t t-out="tax['amount_base']" /></span>
                                        </td>
                                    </tr>
                                </t>
                                <tr class="text-bold" t-if="extra_data['prices'].get('rounding_amount')">
                                    <td class="text-start w-70" name="rounding">Rounding:</td>
                                    <td class="text-end w-30 rounding-amount font-monospace" t-out="extra_data['prices']['rounding_amount']" />
                                </tr>
                                <tr class="text-bold">
                                    <td class="text-start w-70" name="total">Total:</td>
                                    <td class="text-end w-30"><span class="total-amount font-monospace" t-out="extra_data['prices']['total_amount']" /></td>
                                </tr>
                                <tr class="text-bold" t-if="extra_data['prices'].get('discount_amount')">
                                    <td class="text-start w-70" name="discount">Discount:</td>
                                    <td class="text-end w-30 discount-amount font-monospace" t-out="extra_data['prices']['discount_amount']" />
                                </tr>
                                <t t-foreach="payments" t-as="payment" name="payments">
                                    <tr class="payment-line">
                                        <td class="text-start w-70" t-out="payment['payment_method_data']['name']" />
                                        <td class="text-end w-30 font-monospace" t-out="payment['amount']" />
                                    </tr>
                                </t>
                                <tr class="text-bold" t-if="order.get('amount_return') != 0">
                                    <td class="text-start w-70" name="change">Change:</td>
                                    <td class="text-end w-30 change-amount font-monospace" t-out="order['amount_return']" />
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="w-100" t-if="conditions['use_self_invoicing'] and not conditions['basic_receipt']">
                        <table class="w-100">
                            <tbody>
                                <tr>
                                    <td class="w-25" t-if="conditions['display_qr_code']">
                                        <img class="invoice-qr-code" t-att-src="image['invoice_qr_code']" />
                                    </td>
                                    <td class="text-start top w-75 ps-1" t-if="conditions['display_url']">
                                        <div class="text-bold text-normal">Need an invoice?</div>
                                        <div class="text-small" t-out="extra_data['self_invoicing_url']" />
                                        <div class="text-small">Code: <t t-out="order['ticket_code']"/></div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div t-if="extra_data.get('tips_configuration')" class="w-100 text-center mt-3 mb-3 ">
                        <span class="mb-2">For convenience, we are providing the following gratuity calculations:</span>
                        <table class="w-100 mt-2 mb-1">
                            <tbody>
                                <tr>
                                    <td class="text-start w-33 text-center text-normal">
                                        <span class="mb-1">15%</span><br/>
                                        <span class="font-monospace" t-out="extra_data['tips_configuration']['15']" />
                                    </td>
                                    <td class="text-center w-33 text-center text-normal">
                                        <span class="mb-1">20% </span><br/>
                                        <span class="font-monospace" t-out="extra_data['tips_configuration']['20']" />
                                    </td>
                                    <td class="text-end w-33 text-center text-normal">
                                        <span class="mb-1">25%</span><br/>
                                        <span class="font-monospace" t-out="extra_data['tips_configuration']['25']" />
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div name="before-footer" />
                    <t t-call="point_of_sale.pos_order_receipt_footer" />
                </div>
            </html>
        </template>

        <template id="point_of_sale.pos_order_receipt_header">
            <div class="w-100 text-center mb-3" name="logo">
                <img t-if="image['logo']" t-att-src="image['logo']" class="w-50" />
            </div>
            <div class="w-100 text-center">
                <div name="ticket_reference">
                    <span name="ticket">Ticket</span> <t t-if="conditions['display_vat']">VAT </t>
                    <t t-out="order['pos_reference']" />
                </div>
                <span t-out="extra_data['formated_date_order']" />
            </div>
            <div class="w-100 text-center mb-2" t-if="extra_data['cashier_name']" name="cashier_name">
                <span name="served_by">Served by:</span> <span class="cashier-name" t-out="extra_data['cashier_name']" />
            </div>
            <div class="w-100 text-center" t-if="partner" name="partner_info">
                <div t-out="partner['name']" />
                <div t-if="partner['pos_contact_address']" t-out="partner['pos_contact_address']" />
                <div t-if="partner['vat']">
                    <t t-out="extra_data['partner_vat_label']"/> <t t-out="partner['vat']" />
                </div>
                <div t-if="partner['phone']">
                    Tel: <t t-out="partner['phone']" />
                </div>
            </div>
            <div class="w-100 text-center" t-if="preset">
                <span t-out="preset['name']" />
                <span t-if="extra_data['preset_datetime']">: <t t-out="extra_data['preset_datetime']" /></span>
            </div>
            <div class="w-100 text-center" t-if="order['tracking_number'] and conditions['module_pos_restaurant']" name="tracking-number">
                <span class="text-insane" t-out="order['tracking_number']" />
            </div>
            <div name="header" />
            <div t-if="order['state'] == 'draft'" class="text-center fs-2 mb-1">Pro forma receipt</div>
            <div t-if="config['receipt_header']" class="text-center mb-1" style="white-space:pre-line" t-out="config['receipt_header']" />
        </template>

        <template id="point_of_sale.pos_orderline_receipt">
            <tr t-if="not line['combo_parent_id']" name="standard-line" class="lines">
                <td class="text-start w-10 top">
                    <span class="qty text-large"><t t-out="line['qty']" /></span>
                </td>
                <td class="text-start w-60 top">
                    <t t-call="point_of_sale.pos_orderline_receipt_information" />
                </td>
                <td t-if="not conditions['basic_receipt']" class="text-end w-30 text-large top price-incl font-monospace" t-out="line['price_subtotal_incl']" />
            </tr>
            <tr t-else="" name="combo-child-line" class="lines">
                <td class="text-start w-5 top"/>
                <td class="text-start w-10 top">
                    <span class="combo-child-qty text-large"><t t-out="line['qty']" /></span>
                </td>
                <td class="text-start w-80 top">
                    <t t-call="point_of_sale.pos_orderline_receipt_information" />
                </td>
            </tr>
        </template>

        <template id="point_of_sale.pos_orderline_receipt_information">
            <div class="name text-large" t-out="line['product_data']['display_name']" />
            <span class="text-normal price-unit font-monospace" name="standard-unit-price" t-if="not conditions['basic_receipt'] and not len(line['combo_line_ids'])">
                <t t-out="line['unit_price']" /> / <t t-out="line['product_uom_name']" />
            </span>
            <div t-if="line['discount'] and not conditions['basic_receipt'] and not line['combo_parent_id']" class="text-small no-discount-price">
                <t t-out="line['discount']"/>% discount off on <t t-out="line['no_discount_price']"/>
            </div>
            <div t-if="line['customer_note']" class="text-normal">
                <strong>Note: </strong>
                <span class="line-note" t-out="line['customer_note']" />
            </div>
            <div t-if="line['lot_names']" class="text-normal">
                <ul t-foreach="line['lot_names']" t-as="lot_name" style="list-style: none; padding: 0; margin: 0;">
                    <li class="lot-number" t-out="lot_name" />
                </ul>
            </div>
            <div name="extra-info" />
        </template>

        <template id="point_of_sale.pos_order_receipt_footer">
            <div class="w-100 text-center mt-3">
                <div class="w-100 mt-2" name="footer" />
                <div t-if="extra_data['formated_shipping_date']" class="mt-2 mb-2 w-100 text-start text-normal">
                    <span>Expected delivery:</span> <span class="shipping-date" style="float:right;" t-out="extra_data['formated_shipping_date']"/>
                </div>
                <t t-call="point_of_sale.company_info_receipt" />
                <div t-if="config['receipt_footer']" class="w-100 text-center mt-2 mb-2" style="white-space:pre-line" t-out="config['receipt_footer']" />
                <div class="w-100 text-center mt-3">
                    Powered by <strong>Odoo</strong>
                </div>
            </div>
        </template>
    </data>
</odoo>
