<?xml version="1.0" ?>
<odoo>
    <data>
        <record id="l10n_cl_edi_email_template_invoice" model="mail.template" forcecreate="True">
            <field name="name">DTE - Send by Email</field>
            <field name="model_id" ref="account.model_account_move"/>
            <field name="report_template_ids" eval="[(4, ref('l10n_cl_edi.account_invoices_cedible'))]"/>
            <field name="email_from">{{ (object.company_id.l10n_cl_dte_email or object.company_id.email) }}</field>
            <field name="email_to">{{ (object.partner_id.l10n_cl_dte_email or object.commercial_partner_id.l10n_cl_dte_email) }}</field>
            <field name="use_default_to" eval="False"/>
            <field name="subject">{{ object.company_id.name }} DTE (Ref {{ (object.name or 'n/a') }})</field>
            <field name="auto_delete" eval="False"/>
            <field name="body_html" type="html">
<div style="margin: 0px; padding: 0px;">
    <div style="margin: 0px; padding: 0px; background-color: #f9f9f9; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;">
        <table border="0" cellpadding="0" cellspacing="0" width="100%" style="background-color: #f9f9f9; padding: 20px;">
            <tr>
                <td align="center">
                    <table border="0" cellpadding="0" cellspacing="0" width="600" style="background-color: #ffffff; border-radius: 5px; overflow: hidden; box-shadow: 0px 2px 5px rgba(0,0,0,0.1);">
                        <!-- Header -->
                        <tr>
                            <td align="center" style="background-color: #5E5AE3; padding: 20px; color: #ffffff;">
                                <h2 style="margin: 0; font-size: 24px;">
                                    <t t-if="object.l10n_latam_document_type_id">
                                        <span t-out="object.l10n_latam_document_type_id.name or 'Documento Tributario Electrónico'">Documento Tributario Electrónico</span>
                                    </t>
                                    <t t-else="">
                                        Documento Tributario Electrónico
                                    </t>
                                </h2>
                            </td>
                        </tr>
                        <!-- Body -->
                        <tr>
                            <td style="padding: 30px; color: #333333; font-size: 14px; line-height: 1.6;">
                                <p style="margin: 0 0 15px 0;">
                                    Estimado/a 
                                    <t t-if="object.commercial_partner_id">
                                        <strong t-out="object.commercial_partner_id.name or ''">Cliente</strong>,
                                    </t>
                                    <t t-else="">
                                        <strong t-out="object.partner_id.name or ''">Cliente</strong>,
                                    </t>
                                </p>
                                <p style="margin: 0 0 15px 0;">
                                    Adjunto encontrará su documento tributario electrónico 
                                    <strong t-out="object.name or ''">INV/2021/001</strong>
                                    emitido por <strong t-out="object.company_id.name or ''">Su Empresa</strong>.
                                    <t t-if="object.invoice_origin">
                                        <br/>(Referencia: <span t-out="object.invoice_origin or ''">S00056</span>)
                                    </t>
                                </p>
                                <div style="background-color: #f5f5f5; padding: 15px; border-radius: 4px; margin-bottom: 20px;">
                                    <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                        <tr>
                                            <td style="padding: 5px 0;"><strong>Monto Total:</strong></td>
                                            <td align="right" style="padding: 5px 0;"><strong t-out="format_amount(object.amount_total, object.currency_id) or ''">$ 100.000</strong></td>
                                        </tr>
                                        <tr>
                                            <td style="padding: 5px 0;"><strong>Fecha Emisión:</strong></td>
                                            <td align="right" style="padding: 5px 0;"><span t-out="object.invoice_date or ''">2023-10-27</span></td>
                                        </tr>
                                        <t t-if="object.invoice_date_due">
                                            <tr>
                                                <td style="padding: 5px 0;"><strong>Fecha Vencimiento:</strong></td>
                                                <td align="right" style="padding: 5px 0;"><span t-out="object.invoice_date_due or ''">2023-11-27</span></td>
                                            </tr>
                                        </t>
                                    </table>
                                </div>
                                <p style="margin: 0 0 15px 0;">
                                    <t t-if="object.payment_state in ('paid', 'in_payment')">
                                        <span style="color: #28a745; font-weight: bold;">Este documento ya se encuentra pagado. ¡Gracias!</span>
                                    </t>
                                    <t t-else="">
                                        Por favor, proceda con el pago a su más pronta conveniencia.
                                    </t>
                                </p>
                                <p style="margin: 0;">
                                    Si tiene alguna duda, no dude en contactarnos.
                                </p>
                            </td>
                        </tr>
                        <!-- Download Button -->
                        <tr>
                            <td align="center" style="padding: 0 0 30px 0;">
                                <a t-att-href="object.get_portal_url(report_type='pdf', download=True)" 
                                   style="display: inline-block; padding: 12px 24px; background-color: #5E5AE3; color: #ffffff; text-decoration: none; border-radius: 5px; font-weight: bold; font-size: 14px;">
                                    Descargar Documento (PDF)
                                </a>
                                <br/>
                                <div style="margin-top: 10px;">
                                    <a t-att-href="object.get_portal_url()" style="color: #5E5AE3; text-decoration: underline; font-size: 12px;">
                                        Ver en Portal de Clientes
                                    </a>
                                </div>
                            </td>
                        </tr>
                        <!-- Footer -->
                        <tr>
                            <td align="center" style="background-color: #2D3748; padding: 15px; font-size: 12px; color: #ffffff;">
                                <p style="margin: 0;">Enviado automáticamente</p>
                                <p style="margin: 5px 0 0 0;">
                                    <strong>Bitsur SPA</strong><br/>
                                    <span style="display: inline-block; margin-top: 5px;">
                                        WhatsApp: <a href="https://wa.me/56972697097" style="color: #ffffff; text-decoration: none;">+56 9 72697097</a> | 
                                        Email: <a href="mailto:contacto@bitsur.cl" style="color: #ffffff; text-decoration: none;">contacto@bitsur.cl</a>
                                    </span>
                                </p>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
</div>
            </field>
        </record>

        <record id="email_template_receipt_ack" model="mail.template">
            <field name="name">DTE Receipt Acknowledgment</field>
            <field name="subject">Acknowledgment of Receipt - {{ object.name }}</field>
            <field name="email_from">{{ object.company_id.l10n_cl_dte_email }}</field>
            <field name="email_to">{{ (object.partner_id.l10n_cl_dte_email or object.commercial_partner_id.l10n_cl_dte_email) }}</field>
            <field name="use_default_to" eval="False"/>
            <field name="model_id" ref="l10n_cl_edi.model_account_move"/>
            <field name="auto_delete" eval="False"/>
            <field name="body_html">
            <![CDATA[
                <header>
                <strong>Electronic Invoice - Receipt Acknowledge of DTE Sending
                <t t-out="object.name or ''"></t></strong>
                </header>
                <p>In the attached File you will find the result of the revision an validation process of a sent Tax Document made by you.</p>
                <br />
                <p>This is an automatic application, thus you should not answer this email or make comments to the origin email address..</p>
                <br /><br /><br /><br />
                <p>Sent Using Odoo</p>
            ]]>
            </field>
        </record>
        <record id="email_template_receipt_commercial_accept" model="mail.template">
            <field name="name">DTE Receipt Commercial Accepted</field>
            <field name="subject">Commercial Acceptance Response - {{ object.name }}</field>
            <field name="email_from">{{ object.company_id.l10n_cl_dte_email }}</field>
            <field name="email_to">{{ (object.partner_id.l10n_cl_dte_email or object.commercial_partner_id.l10n_cl_dte_email) }}</field>
            <field name="use_default_to" eval="False"/>
            <field name="model_id" ref="account.model_account_move" />
            <field name="auto_delete" eval="False"/>
            <field name="body_html">
            <![CDATA[
                <header>
                <strong>Electronic Invoicing - Commercial Acceptance Response - <t t-out="object.display_name or ''"></t></strong>
                </header>
                <p>In the attached file you will find the commercial acceptance of your Electronic Tax Document(s).</p>
                <br /><br /><br /><br />
                <p>Sent Using Odoo</p>
            ]]>
            </field>
        </record>
        <record id="email_template_claimed_ack" model="mail.template">
            <field name="name">DTE Commercial Reject</field>
            <field name="subject">Commercial Rejection response - {{ object.name }}</field>
            <field name="email_from">{{ object.company_id.l10n_cl_dte_email }}</field>
            <field name="email_to">{{ (object.partner_id.l10n_cl_dte_email or object.commercial_partner_id.l10n_cl_dte_email) }}</field>
            <field name="use_default_to" eval="False"/>
            <field name="model_id" ref="l10n_cl_edi.model_account_move"/>
            <field name="auto_delete" eval="False"/>
            <field name="body_html">
            <![CDATA[
                <header>
                <strong>Electronic Invoicing - Commercial Rejection response <t t-out="object.name or ''"></t></strong>
                </header>
                <p>In the attached file you will find the response for a commercial rejection of Electronic Tax Documents sent by you.</p>
                <br />
                <p>This is an automatic application, thus you should not answer this email or make comments to the origin email address..</p>
                <br /><br /><br /><br />
                <p>Sent Using Odoo</p>
            ]]>
            </field>
        </record>
        <record id="email_template_receipt_goods" model="mail.template">
            <field name="name">DTE Reception of Services Or Goods</field>
            <field name="subject">DTE Reception of Services Or Goods - {{ object.name }}</field>
            <field name="email_from">{{ object.company_id.l10n_cl_dte_email }}</field>
            <field name="email_to">{{ object.partner_id.l10n_cl_dte_email or object.commercial_partner_id.l10n_cl_dte_email }}</field>
            <field name="use_default_to" eval="False"/>
            <field name="model_id" ref="account.model_account_move" />
            <field name="auto_delete" eval="False"/>
            <field name="body_html">
            <![CDATA[
                <header>
                <strong>Electronic Invoicing - Reception of Services or Goods RG 19.983 - <t t-out="object.display_name or ''"></t></strong>
                </header>
                <p>In the attached file you will find the reception of goods RG 19.983 for Electronic Tax Document(s).</p>
                <p>El acuse de recibo que se declara en este acto, de acuerdo a lo dispuesto en la letra b)
                del Art. 4, y la letra c) del Art. 5 de la Ley 19.983, acredita que la entrega de
                mercaderias o servicio(s) prestado(s) ha(n) sido recibido(s).</p>
                <br /><br /><br /><br />
                <p>Sent Using Odoo</p>
            ]]>
            </field>
        </record>
    </data>
</odoo>