<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <template id="peru_quotation_view">
        <t t-call="web.html_container">
            <t t-foreach="docs" t-as="o">
                <t t-call="web.external_layout">
                    <div class="page">
                        <div class="row" style="margin-bottom:10px;margin-top:-45px;">
                            <div class="col-8">
                                <br/><br/>
                                <p>Sr(es): <span t-field="o.partner_id"/></p>
                            </div>
                            <div class="col-4" style="text-align:center;">
                                <h4 t-field="o.name"/>
                                <p>Cotización</p>
                                <h6>Fecha: <span t-esc="o.date_order" t-options="{'widget': 'date'}"/></h6>
                            </div>
                        </div>
                        <table class="table table-sm table-bordered" border="0" cellpadding="0" cellspacing="0">
                            <thead>
                                <tr style="background-color:#AAB7B8;">
                                    <td><strong>Detalle</strong></td>
                                    <td><strong>Cantidad</strong></td>
                                    <td><strong>P.Unitario</strong></td>
                                    <td><strong>Total/Mes</strong></td>
                                    <td><strong>Total/1er Año</strong></td>
                                    <td><strong>Total/2er Año</strong></td>
                                </tr>
                            </thead>
                            <tbody>
                                <t t-set="sub_total_year" t-value="0"/>
                                <t t-foreach="o.order_line.filtered(lambda line: line.product_id.default_code != 'SVC8')" t-as="line">
                                    <tr>
                                        <td><span t-field="line.product_id"/></td>
                                        <td><span t-field="line.product_uom_qty"/></td>
                                        <td><span t-field="line.price_unit" t-options='{"widget": "monetary", "display_currency": line.currency_id}'/></td>
                                        <td><span t-field="line.price_subtotal" t-options='{"widget": "monetary", "display_currency": line.currency_id}'/></td>
                                        <t t-set="year" t-value="line.price_subtotal*12" />
                                        <t t-set="sub_total_year" t-value="sub_total_year+year"/>
                                        <td><span t-esc="year" t-options='{"widget": "monetary", "display_currency": line.currency_id}'/></td>
                                        <td><span t-esc="year" t-options='{"widget": "monetary", "display_currency": line.currency_id}'/></td>
                                    </tr>
                                </t>
                                <tr style="background-color:#16A085;">
                                    <td colspan="4">
                                        <strong>Total (licencias/alojamiento)/Año</strong>
                                    </td>
                                    <td><span t-esc="sub_total_year" t-options='{"widget": "monetary", "display_currency": line.currency_id}'/></td>
                                    <td><span t-esc="sub_total_year" t-options='{"widget": "monetary", "display_currency": line.currency_id}'/></td>
                                </tr>
                                <t t-foreach="o.order_line.filtered(lambda line: line.product_id.default_code == 'SVC8')" t-as="line2">
                                    <tr>
                                        <td colspan="4" style="background-color:#16A085;">
                                            <strong>Total Implementacion de modulos*</strong>
                                        </td>
                                        <td style="background-color:#16A085;"><span t-esc="line2.price_subtotal" t-options='{"widget": "monetary", "display_currency": line.currency_id}'/></td>
                                        <td/>
                                    </tr>
                                </t>
                                <t t-set="sub_total_year_1" t-value="sub_total_year+(line2.price_subtotal)"/>
                                <tr>
                                    <td colspan="4">
                                        <strong>Sub total</strong>
                                    </td>
                                    <td><span t-esc="sub_total_year_1" t-options='{"widget": "monetary", "display_currency": line.currency_id}'/></td>
                                    <td><span t-esc="sub_total_year" t-options='{"widget": "monetary", "display_currency": line.currency_id}'/></td>
                                </tr>
                                <t t-set="igv_year_1" t-value="round(sub_total_year_1*0.18, 2)" />
                                <t t-set="igv_year_2" t-value="round(sub_total_year*0.18, 2)" />
                                <t t-set="total_year_1" t-value="round(sub_total_year_1+igv_year_1, 2)" />
                                <t t-set="total_year_2" t-value="round(sub_total_year+igv_year_2, 2)" />
                                <tr>
                                    <td colspan="4">
                                        <strong>IGV 18%</strong>
                                    </td>
                                    <td><span t-esc="igv_year_1" t-options='{"widget": "monetary", "display_currency": line.currency_id}'/></td>
                                    <td><span t-esc="igv_year_2" t-options='{"widget": "monetary", "display_currency": line.currency_id}'/></td>
                                </tr>
                                <tr style="background-color:#FAD7A0;">
                                    <td colspan="4">
                                        <strong>Total/Año**</strong>
                                    </td>
                                    <td><span t-esc="total_year_1" t-options='{"widget": "monetary", "display_currency": line.currency_id}'/></td>
                                    <td><span t-esc="total_year_2" t-options='{"widget": "monetary", "display_currency": line.currency_id}'/></td>
                                </tr>
                                <tr/>
                                <tr style="background-color:#AAB7B8;">
                                    <td><strong>Detalle</strong></td>
                                    <td><strong>Cantidad</strong></td>
                                    <td><strong>P.Unitario</strong></td>
                                    <td><strong>Total/Mes</strong></td>
                                    <td><strong>Total/1er Año</strong></td>
                                    <td><strong>Total/2er Año</strong></td>
                                </tr>
                                <t t-set="payroll" t-value="o.order_line.filtered(lambda line: line.product_id.default_code == 'payroll')"/>
                                <t t-set="qty" t-value="payroll.product_uom_qty"/>
                                <t t-set="p_unit_odoo" t-value="10.90"/>
                                <t t-set="total_month_odoo" t-value="qty*p_unit_odoo"/>
                                <t t-set="total_year_odoo" t-value="total_month_odoo*12"/>
                                <tr>
                                    <td style="background-color:#FAD7A0;">Licencia de Odoo</td>
                                    <td style="background-color:#FAD7A0;"><span t-esc="qty"/></td>
                                    <td style="background-color:#FAD7A0;"><span t-esc="p_unit_odoo" t-options='{"widget": "monetary", "display_currency": line.currency_id}'/></td>
                                    <td style="background-color:#FAD7A0;"><span t-esc="total_month_odoo" t-options='{"widget": "monetary", "display_currency": line.currency_id}'/></td>
                                    <td style="background-color:#FAD7A0;"><span t-esc="total_year_odoo" t-options='{"widget": "monetary", "display_currency": line.currency_id}'/></td>
                                    <td/>
                                </tr>
                                <tr>
                                    <td colspan="5" style="background-color:#FAD7A0;font-size:10px;">
                                        <p>Esto es un estimado. Las licencias de Odoo son contratadas directamente con Odoo.<br/>
                                            El precio se mantendrá fijo durante la vigencia del contrato.<br/>
                                            Los costos por el hosting de odoo.sh no estan incluidos.</p>
                                    </td>
                                    <td/>
                                </tr>
                                <tr>
                                    <td colspan="5" style="background-color:#FAD7A0;font-size:10px;">
                                        <p>Se incluye todos los módulos de Odoo sin configuración.<br/>
                                            Para visualizar la lista, por favor entre al siguiente enlace:<br/>
                                            <a href="https://www.odoo.com/es_ES/page/all-apps">https://www.odoo.com/es_ES/page/all-apps</a></p>
                                    </td>
                                    <td></td>
                                </tr>
                            </tbody>
                        </table>
                        <p>*Módulos implementados/configurados: Uso general de Odoo</p>
                        <p>**Precios cambian de acuerdo a la implementación de nuevos módulos</p>
                        <!-- REVIEW insert QR code -->
                        <t t-set="sale_report_url" t-value="'/my/orders/%s' % (o.id)"/>
                        <div name="footer_left_column" position="inside" style="text-align:right;">
                            <img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('QR', sale_report_url, 400, 400)" alt="QR Code" style="height:100px"/>
                        </div>
                    </div>
                </t>
            </t>
        </t>
    </template>

</odoo>
