Skip to content

Commit 9d61030

Browse files
[FIX] l10n_uy_reports: formulario 2-181.
Ticket: 80568 Error de lógica al momento de descargar el txt del formulario 2-181 de Uruguay
1 parent 32dfe55 commit 9d61030

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

l10n_uy_reports/wizards/form_report_wiz.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def _get_invoices_domain(self):
4949
"""
5050
domain = [
5151
('company_id', '=', self.company_id.id), ('state', '=', 'posted'),
52-
('date', '>=', self.date_from), ('date', '<', self.date_to),
52+
('date', '>=', self.date_from), ('date', '<=', self.date_to),
5353
('partner_id.vat', '!=', False),
5454
('l10n_latam_document_type_id.code', '!=', '0'),
5555
('l10n_latam_document_type_id.code', '!=', False)
@@ -140,18 +140,23 @@ def _get_form_2181_data(self):
140140

141141
for rut_partner, invoices in data.items():
142142
amount_total = {}
143-
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 []
144143
for inv in invoices:
144+
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 []
145145
for item in group_by_subtotal_values:
146146
tax_group_id = item.get('tax_group_id')
147147
if tax_group_id in taxes_group_ids:
148-
inv_amount = item.get('tax_group_amount')
148+
# los comprobantes exentos tienen 0.0 en tax_group_amount, entonces tomamos tax_group_base_amount
149+
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')
149150
# No estaba ene especifcacion pero vimos via un ejemplo que los montos reportados siempre son en
150151
# pesos. aun qu el comprobamte sea de otra moneda, es por eso que hacemos esta conversion
151152
if inv.currency_id != UYU_currency:
152-
inv_amount = inv_amount * inv.l10n_uy_currency_rate
153+
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)))
153154
key = (tax_group_id, 'sale' if 'out_' in inv.move_type else 'purchase')
154-
amount_total[key] = amount_total.get(key, 0.0) + (amount_total.get(tax_group_id, 0.0)) + inv_amount
155+
sing = '+' if inv.move_type in ['out_invoice', 'in_invoice', 'out_receipt', 'in_receipt'] else '-'
156+
if sing == '+':
157+
amount_total[key] = amount_total.get(key, 0.0) + (amount_total.get(tax_group_id, 0.0)) + inv_amount
158+
else:
159+
amount_total[key] = amount_total.get(key, 0.0) + (amount_total.get(tax_group_id, 0.0)) - inv_amount
155160
for tax in amount_total:
156161

157162
if not tax_code.get(tax):

0 commit comments

Comments
 (0)