Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] l10n_uy_reports: formulario 2-181. #250

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion l10n_uy_reports/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Uruguay - Accounting Reports

* Agrega la posibilidad de ver/exportar xls con el libro de IVA Compras/Ventas Uruguayo, esto en el menu "Tax Reports"
* Agrega el menu Resumen de IVA para uruguay, reporte que se puee usar para analizar los datos de facturacióneed
* Nuevo asistente que permite generar los archivos TXT para presentar el Formulario 2/181 (hasta el momento solo repota impuestos de iva compra/venta)
* Nuevo asistente que permite generar los archivos TXT para presentar el Formulario 2/181 (hasta el momento solo repota impuestos de iva compra/venta). Instructivos: https://www.gub.uy/direccion-general-impositiva/comunicacion/publicaciones/instructivo-para-confeccion-presentacion-declaraciones-aplicacion-beta y https://www.gub.uy/direccion-general-impositiva/comunicacion/publicaciones/informacion-sobre-formulario-2181

Installation
============
Expand Down
15 changes: 10 additions & 5 deletions l10n_uy_reports/wizards/form_report_wiz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down