Skip to content

Commit

Permalink
[WIP] l10n_do: cleaning report_invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
jose-pcg committed Mar 22, 2023
1 parent 3195a20 commit df88b1e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 71 deletions.
7 changes: 5 additions & 2 deletions addons/l10n_do/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,11 @@ def _get_l10n_do_amounts(self, company_currency=False):

def _get_name_invoice_report(self):
self.ensure_one()
if self.l10n_latam_use_documents and self.country_code == "DO":
return "l10n_do.report_invoice_document_inherited"
if (
self.l10n_latam_use_documents
and self.company_id.account_fiscal_country_id.code == "DO"
):
return "l10n_do.report_invoice_document"
return super()._get_name_invoice_report()

@api.constrains("move_type", "l10n_latam_document_type_id")
Expand Down
110 changes: 41 additions & 69 deletions addons/l10n_do/views/report_invoice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
<span t-field="o.invoice_date"/>
</span>
<br/>
<span t-if="o.invoice_date_due and o.move_type == 'out_invoice' and o.state == 'posted' and not ecf_representation">
<span
t-if="o.invoice_date_due and o.move_type == 'out_invoice' and o.state == 'posted'">
<strong>Vence:</strong>
<span t-field="o.invoice_date_due"/>
</span>
Expand All @@ -47,33 +48,24 @@
<h2>
<span t-field="o.l10n_latam_document_type_id.report_name"/>
</h2>
<strong t-if="o.l10n_do_fiscal_number">
<t t-if="ecf_representation">e-NCF:</t>
<t t-else="">NCF:</t>
<strong t-if="o.l10n_latam_document_number">
<t>NCF:</t>
</strong>
<span t-field="o.l10n_do_fiscal_number"/>
<span t-field="o.l10n_latam_document_number"/>
<br/>
<span t-if="(o.move_type == 'out_refund' or o.move_type == 'in_refund' or o.debit_origin_id) and (o.l10n_do_origin_ncf != False)">
<span
t-if="(o.move_type == 'out_refund' or o.move_type == 'in_refund' or o.debit_origin_id) and o.reversed_entry_id">
<strong>NCF modificado:</strong>
<span t-field="o.l10n_do_origin_ncf"/>
<t t-if="ecf_representation">
<br/>
<strong>Código Modificación:</strong>
<span t-field="o.l10n_do_ecf_modification_code"/>
</t>
<span t-field="o.reversed_entry_id.l10n_latam_document_number"/>
<br/>
</span>
<span id="fiscal_exp_date"
t-if="o.l10n_latam_use_documents
and o.move_type in ['out_invoice', 'out_refund']
and o.is_sale_document()
and o.state == 'posted'
and o.l10n_do_fiscal_number
and o.l10n_latam_document_number
and o.l10n_latam_document_type_id
and o.l10n_latam_document_type_id.doc_code_prefix[1:] not in ('32', '34', '02')">
<strong>
<t t-if="ecf_representation">Vencimiento e-NCF:</t>
<t t-else="">Válida hasta:</t>
</strong>
<span id="ecf_exp_date"
t-field="o.l10n_do_ncf_expiration_date"/>
</span>
Expand All @@ -89,7 +81,7 @@
<t t-elif="vat_len == 11">Cédula:</t>
<t t-else="">ID Cliente:</t>
</strong>
<span class="m-0" t-esc="o.commercial_partner_id.vat or ''"/>
<span class="m-0" t-out="o.commercial_partner_id.vat or ''"/>
<br/>
<strong>
<t t-if="vat_len == 9">Razón Social:</t>
Expand Down Expand Up @@ -154,13 +146,13 @@
<t t-foreach="tax_totals['subtotals']" t-as="subtotal">
<tr class="border-black o_subtotal">
<td>
<strong t-esc="subtotal['name']"/>
<strong t-out="subtotal['name']"/>
</td>

<td class="text-right">
<span
t-att-class="oe_subtotal_footer_separator"
t-esc="subtotal['formatted_amount']"
t-out="subtotal['formatted_amount']"
/>
</td>
</tr>
Expand All @@ -174,26 +166,28 @@
<t>
<td>
<span class="text-nowrap"
t-esc="tax_aml.tax_line_id.description"/>
t-out="tax_aml.tax_line_id.invoice_label"/>
</td>
<td class="text-right o_price_total">
<span class="text-nowrap" t-esc="l10n_do_tax_amount"
<span class="text-nowrap" t-out="l10n_do_tax_amount"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</t>
</tr>
</t>

<t t-set="total_amount_taxed" t-value="l10n_do_amounts['itbis_taxable_amount']"/>
<t t-set="total_exempt_amount" t-value="l10n_do_amounts['itbis_exempt_amount']"/>
<t t-set="total_amount_taxed"
t-value="l10n_do_amounts['itbis_taxable_amount']"/>
<t t-set="total_exempt_amount"
t-value="l10n_do_amounts['itbis_exempt_amount']"/>

<tr class="border-black o_total" t-if="ecf_representation">
<td>Monto Gravado</td>
<td class="text-right o_price_total">
<!-- MontoGravadoTotal consiste en la suma de la base imponible de todas las lineas gravadas con ITBIS -->
<span class="text-nowrap"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'
t-esc="total_amount_taxed"/>
t-out="total_amount_taxed"/>
</td>
</tr>
<tr t-if="ecf_representation">
Expand All @@ -202,7 +196,7 @@
<!-- MontoExento consiste en la suma de la base imponible de todas las lineas exentas -->
<span class="text-nowrap"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'
t-esc="total_exempt_amount"/>
t-out="total_exempt_amount"/>
</td>
</tr>

Expand All @@ -214,7 +208,7 @@

<t t-set="l10n_do_amount_total" t-value="l10n_do_amounts['invoice_total']"/>
<td class="text-right">
<span class="text-nowrap" t-esc="l10n_do_amount_total"
<span class="text-nowrap" t-out="l10n_do_amount_total"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
Expand All @@ -227,10 +221,10 @@
<t>
<td>
<span class="text-nowrap"
t-esc="tax_aml.tax_line_id.description"/>
t-out="tax_aml.tax_line_id.invoice_label"/>
</td>
<td class="text-right o_price_total">
<span class="text-nowrap" t-esc="l10n_do_wh_amount"
<span class="text-nowrap" t-out="l10n_do_wh_amount"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</t>
Expand All @@ -239,12 +233,11 @@

</template>

<template id="report_invoice_document_inherited"
inherit_id="account.report_invoice_document" primary="True">
<template id="report_invoice_document" inherit_id="account.report_invoice_document"
primary="True">

<t t-set="o" position="after">
<t t-set="custom_header" t-value="'l10n_do_accounting.custom_header'"/>
<t t-set="ecf_representation" t-value="o.is_ecf_invoice"/>
<t t-set="custom_header" t-value="'l10n_do.custom_header'"/>
<t t-set="is_l10n_do_invoice"
t-value="o.l10n_latam_use_documents and o.company_id.country_id and o.country_code == 'DO'"/>
</t>
Expand All @@ -254,7 +247,7 @@

<!-- replace information section and use dominican style -->
<div id="informations" position="replace">
<t t-call="l10n_do_accounting.informations"/>
<t t-call="l10n_do.informations"/>
</div>

<xpath
Expand All @@ -269,24 +262,6 @@

<xpath expr="//div[@id='total']/.." position="after">
<div class="row">
<div class="col-6"
style="display: inline-block; float: left; font-size:11px;">
<t t-if="o.l10n_do_electronic_stamp">
<div>
<img t-att-src="'/report/barcode/?type=QR&amp;width=100&amp;height=100&amp;value=' + o.l10n_do_electronic_stamp if o.l10n_do_electronic_stamp else ''"/>
</div>
<t t-if="o.l10n_do_ecf_security_code">
<strong>Código de Seguridad:</strong>
<span t-esc="o.l10n_do_ecf_security_code"/>
</t>
<br/>
<t t-if="o.l10n_do_ecf_sign_date">
<strong>Fecha Firma Digital:</strong>
<span
t-esc="context_timestamp(o.l10n_do_ecf_sign_date).strftime('%d-%m-%Y')"/>
</t>
</t>
</div>
<div t-if="is_l10n_do_invoice" class="text-muted text-right col-6"
style="float: right;">
<span>
Expand Down Expand Up @@ -319,37 +294,34 @@
t-value="line.price_unit * (1 - (line.discount / 100.0))"/>
<t t-set="discount_amount"
t-value="abs(price_unit_wo_discount) if line.discount else 0"/>
<span class="text-nowrap" t-esc="discount_amount"
<span class="text-nowrap" t-out="discount_amount"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</xpath>
<xpath expr="//span[@id='line_tax_ids']" position="attributes">
<attribute name="t-esc">
', '.join(map(lambda x: (x.description or x.name), line.tax_ids)) if not ecf_representation else '%s %s' % (o.currency_id.symbol, '{0:,.2f}'.format(line.l10n_do_itbis_amount))
</attribute>
</xpath>

<xpath expr="//div[@id='total']/div/table/t[@t-call='account.document_tax_totals']"
position="replace">
<t t-call="l10n_do_accounting.document_tax_totals"/>
</xpath>
<!--<xpath
expr="//div[@id='total']/div/table/t[@t-call='account.document_tax_totals']"
position="replace">
<t t-call="l10n_do.document_tax_totals"/>
</xpath>-->
<t t-call="account.document_tax_totals" position="attributes">
<attribute name="t-call">l10n_do.document_tax_totals</attribute>
</t>

</template>

<template id="report_invoice" inherit_id="account.report_invoice">
<xpath expr='//t[@t-call="account.report_invoice_document"]' position="after">
<t t-if="o._get_name_invoice_report() == 'l10n_do_accounting.report_invoice_document_inherited'"
t-call="l10n_do_accounting.report_invoice_document_inherited"
t-lang="lang"/>
<t t-if="o._get_name_invoice_report() == 'l10n_do.report_invoice_document'"
t-call="l10n_do.report_invoice_document" t-lang="lang"/>
</xpath>
</template>

<template id="report_invoice_with_payments"
inherit_id="account.report_invoice_with_payments">
<xpath expr='//t[@t-call="account.report_invoice_document"]' position="after">
<t t-if="o._get_name_invoice_report() == 'l10n_do.report_invoice_document_inherited'"
t-call="l10n_do.report_invoice_document_inherited"
t-lang="lang"/>
<t t-if="o._get_name_invoice_report() == 'l10n_do.report_invoice_document'"
t-call="l10n_do.report_invoice_document" t-lang="lang"/>
</xpath>
</template>

Expand Down

0 comments on commit df88b1e

Please sign in to comment.