From 9d61030b2b2376af37d6486b21bb7d584ef64e01 Mon Sep 17 00:00:00 2001 From: Pablo Montenegro Date: Thu, 3 Oct 2024 19:12:15 -0300 Subject: [PATCH] =?UTF-8?q?[FIX]=20l10n=5Fuy=5Freports:=20formulario=202-1?= =?UTF-8?q?81.=20Ticket:=2080568=20Error=20de=20l=C3=B3gica=20al=20momento?= =?UTF-8?q?=20de=20descargar=20el=20txt=20del=20formulario=202-181=20de=20?= =?UTF-8?q?Uruguay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- l10n_uy_reports/wizards/form_report_wiz.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/l10n_uy_reports/wizards/form_report_wiz.py b/l10n_uy_reports/wizards/form_report_wiz.py index 61b01541..1f14ee40 100644 --- a/l10n_uy_reports/wizards/form_report_wiz.py +++ b/l10n_uy_reports/wizards/form_report_wiz.py @@ -49,7 +49,7 @@ def _get_invoices_domain(self): """ domain = [ ('company_id', '=', self.company_id.id), ('state', '=', 'posted'), - ('date', '>=', self.date_from), ('date', '<', self.date_to), + ('date', '>=', self.date_from), ('date', '<=', self.date_to), ('partner_id.vat', '!=', False), ('l10n_latam_document_type_id.code', '!=', '0'), ('l10n_latam_document_type_id.code', '!=', False) @@ -140,18 +140,23 @@ def _get_form_2181_data(self): for rut_partner, invoices in data.items(): amount_total = {} - group_by_subtotal_values = list(inv.tax_totals.get('groups_by_subtotal').values())[0] if list(inv.tax_totals.get('groups_by_subtotal').values()) else [] for inv in invoices: + group_by_subtotal_values = list(inv.tax_totals.get('groups_by_subtotal').values())[0] if list(inv.tax_totals.get('groups_by_subtotal').values()) else [] for item in group_by_subtotal_values: tax_group_id = item.get('tax_group_id') if tax_group_id in taxes_group_ids: - inv_amount = item.get('tax_group_amount') + # los comprobantes exentos tienen 0.0 en tax_group_amount, entonces tomamos tax_group_base_amount + inv_amount = item.get('tax_group_amount') if not tax_group_id == self.env.ref('l10n_uy_account.tax_group_vat_exempt').id else item.get('tax_group_base_amount') # No estaba ene especifcacion pero vimos via un ejemplo que los montos reportados siempre son en # pesos. aun qu el comprobamte sea de otra moneda, es por eso que hacemos esta conversion if inv.currency_id != UYU_currency: - inv_amount = inv_amount * inv.l10n_uy_currency_rate + inv_amount = inv_amount * (inv.l10n_uy_currency_rate or (inv.currency_id._convert(1.0, inv.company_id.currency_id, inv.company_id, inv.date, round=False))) key = (tax_group_id, 'sale' if 'out_' in inv.move_type else 'purchase') - amount_total[key] = amount_total.get(key, 0.0) + (amount_total.get(tax_group_id, 0.0)) + inv_amount + sing = '+' if inv.move_type in ['out_invoice', 'in_invoice', 'out_receipt', 'in_receipt'] else '-' + if sing == '+': + amount_total[key] = amount_total.get(key, 0.0) + (amount_total.get(tax_group_id, 0.0)) + inv_amount + else: + amount_total[key] = amount_total.get(key, 0.0) + (amount_total.get(tax_group_id, 0.0)) - inv_amount for tax in amount_total: if not tax_code.get(tax):