<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <template id="report_invoice_document" inherit_id="account.report_invoice_document">
        <xpath expr="//span[@name='payment_term']" position="after">
            <p t-if="o.company_id.country_id.code == 'AE' and o.partner_id.country_id.code != 'AE' and o.env.ref('l10n_ae.gcc_countries_group') in o.partner_id.country_id.country_group_ids">
                Supply between <b>United Arab Emirates</b> and
                <b>
                    <span t-field="o.partner_id.country_id.name"/>
                </b>
            </p>
        </xpath>
        <xpath expr="//h2/span" position="before">
            <span t-if="o.company_id.country_id.code == 'AE' and o.move_type in ['out_invoice', 'out_refund']">TAX
            </span>
        </xpath>

        <xpath expr="//thead//th[@name='th_taxes']" position="replace">
            <th name="th_taxes"
                t-attf-class="text-start {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
                <span t-if="o.company_id.country_id.code == 'AE'">VAT</span>
                <span t-else="">Taxes</span>
            </th>
            <th t-if="o.company_id.country_id.code == 'AE'" name="tax_amount"
                t-attf-class="text-start {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
                <span>VAT Amount</span>
            </th>
        </xpath>

        <xpath expr="//span[@id='line_tax_ids']/.." position="after">
            <td t-if="o.company_id.country_id.code == 'AE'">
                <span t-field="line.l10n_ae_vat_amount" id="line_tax_amount"/>
            </td>
        </xpath>
    </template>

    <template id="document_tax_totals_company_currency_template" inherit_id="account.document_tax_totals_company_currency_template">
        <xpath expr="//p[hasclass('tax_computation_company_currency')]" position="after">
            <tr t-if="o.company_id.country_id.code == 'AE'">
                <t t-set="exchange_rate"
                   t-value="abs(o.amount_total_signed) / o.amount_total"/>
                <td>Exchange Rate</td>
                <td class="text-end" t-out="exchange_rate" t-options='{"widget": "float", "precision": 5}'/>
            </tr>
        </xpath>
    </template>
</odoo>
