Skip to content

Commit

Permalink
[MIG] l10n_uy_reports: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
docker-odoo authored and jue-adhoc committed Dec 20, 2024
1 parent b50e996 commit ef2a85e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions l10n_uy_reports/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Uruguay - Accounting Reports',
'version': "17.0.1.0.0",
'version': "18.0.1.0.0",
'author': 'ADHOC SA',
'license': 'LGPL-3',
'category': 'Localization',
Expand All @@ -23,5 +23,5 @@
],
},
'auto_install': True,
'installable': False,
'installable': True,
}
1 change: 0 additions & 1 deletion l10n_uy_reports/data/account_financial_report_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<field name="load_more_limit" eval="80"/>
<field name="column_ids">
<record id="l10n_uy_vat_book_report_column_invoice_date" model="account.report.column">
<!-- TODO revisar que realmente es el campo invoice_date y no el campo date -->
<field name="name">Date</field>
<field name="expression_label">date</field>
<field name="figure_type">date</field>
Expand Down
2 changes: 1 addition & 1 deletion l10n_uy_reports/models/l10n_uy_vat_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def _get_custom_display_config(self):
},
}

def _dynamic_lines_generator(self, report, options, all_column_groups_expression_totals, warnings=None):
def _dynamic_lines_generator(self, report, options):
# dict of the form {move_id: {column_group_key: {expression_label: value}}}
move_info_dict = {}

Expand Down
8 changes: 4 additions & 4 deletions l10n_uy_reports/report/account_uy_vat_line_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
</record>

<record id="view_account_uy_vat_line_tree" model="ir.ui.view">
<field name="name">account.uy.vat.line.tree</field>
<field name="name">account.uy.vat.line.list</field>
<field name="model">account.uy.vat.line</field>
<field name="arch" type="xml">
<tree editable="bottom">
<list editable="bottom">
<field name="date"/>
<field name="move_id"/>
<field name="partner_id"/>
Expand All @@ -46,7 +46,7 @@
<field name="other_taxes" sum="Total"/>
<field name="total" sum="Total"/>
<button name="open_journal_entry" string="Open" type="object" icon="fa-external-link" help="Open journal entry"/>
</tree>
</list>
</field>
</record>

Expand All @@ -70,7 +70,7 @@
<record id="action_account_uy_vat_line" model="ir.actions.act_window">
<field name="name">VAT Summary</field>
<field name="res_model">account.uy.vat.line</field>
<field name="view_mode">pivot,tree</field>
<field name="view_mode">pivot,list</field>
<field name="context">{'search_default_posted': 1, 'time_ranges': {'field': 'date', 'range': 'last_month'}}</field>
</record>

Expand Down
49 changes: 25 additions & 24 deletions l10n_uy_reports/wizards/form_report_wiz.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,20 @@ def _search_tax(self, tax_amount, tax_type):
return res

def _get_form_2181_data(self):
""" Prepara the content of the file
"""
Prepara the content of the file
Este es un solo archivo TXT el cual contiene.
En el Rubro 5 se ingresan agrupados por Identificación del contribuyente y número de línea
correspondiente al concepto declarado e importe.
Agrupado por partner, por periodo y fecha de factura la información de los impuestos generados
return the string with the lines of the file to write """
Devuelve un string con las lineas de la carpeta a escribir
"""
lines = []

# Importante. aca este el archivo generado mezcla iva compras e iva ventas.
# Importante: el archivo generado mezcla iva compras e iva ventas.
line_code = {
self._search_tax(22.0, 'sale'): '502', # 502 IVA Ventas Tasa Básica a Contribuyentes
self._search_tax(10.0, 'sale'): '503', # 503 IVA Ventas Tasa Mínima a Contribuyentes
Expand Down Expand Up @@ -142,24 +144,23 @@ def _get_form_2181_data(self):
for rut_partner, invoices in data.items():
amount_total = {}
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:
# 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 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')
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:
subtotals = inv.tax_totals.get('subtotals', [])
currency_is_uyu = inv.currency_id == UYU_currency
is_sale = 'out_' in inv.move_type
sign = 1 if inv.move_type in ['out_invoice', 'in_invoice', 'out_receipt', 'in_receipt'] else -1

for item in subtotals:
tax_group_ids = item.get('tax_groups', [])
# No estaba ene especifcacion pero vimos via un ejemplo que los montos reportados siempre son en
# pesos, aunque el comprobamte sea de otra moneda, es por eso que utilizamos el monto convertido
tax_amount = item.get('tax_amount') if currency_is_uyu else item.get('tax_amount_currency')
for tax_group_id in tax_group_ids:
tax_id = tax_group_id['id']
if tax_id in taxes_group_ids:
key = (tax_id, 'sale' if is_sale else 'purchase')
amount_total[key] = amount_total.get(key, 0.0) + (sign * tax_amount)

for tax in amount_total:
if not tax_code.get(tax):
continue

Expand All @@ -172,13 +173,13 @@ def _get_form_2181_data(self):
# Campo 2 - Formulario. Num 5
content_data += "{: 5d};".format(int(self.uy_form_id))

# Campo 3 - Período (AAAAMM) Num 6. Ejemplo: 200306
# Campo 3 - Período (AAAAMM) Num 6. Ejemplo: 202406
content_data += "{};".format(self.date_period)

# Campo 4 - RUT Informado. Num 12
content_data += rut_partner.zfill(12) + ";"

# Campo 5 - Factura AAAAMM Num 6. Ejemplo: 200305
# Campo 5 - Factura AAAAMM Num 6. Ejemplo: 202405
content_data += "{};".format(line.move_id.date.strftime("%Y%m"))

# Campo 6 - Línea del Rubro 5 del Formulario
Expand All @@ -199,7 +200,7 @@ def action_get_files(self):
if self.company_id.country_id.code != 'UY':
raise UserError(_("Solo puede generar este reporte para compañias Uruguayas"))

data = getattr(self, '_get_form_%s_data' % self.uy_form_id)()
data = getattr(self, '_get_form_%s_data' % self.uy_form_id)() if self.uy_form_id else None
if data:
self.res_filename = self.company_id.name[:4] + "Formulario2-181DGI_" + self.date_period[-2:] + self.date_period[:4] + ".txt"
# TODO No sabemos realmente cual es el formato, solo tomamos de ejemplo el que genera uruware
Expand Down

0 comments on commit ef2a85e

Please sign in to comment.