From 0879a460e91488237e972a4e87110168fd08d1c3 Mon Sep 17 00:00:00 2001 From: Ignacio Buioli Date: Wed, 19 Jul 2023 20:47:37 -0300 Subject: [PATCH 1/3] [14.0] [IMP] l10n_ar_ledger: VAT reports --- l10n_ar_ledger/__manifest__.py | 2 + l10n_ar_ledger/models/__init__.py | 1 + l10n_ar_ledger/models/account_vat_ledger.py | 17 +- .../models/account_vat_ledger_xlsx.py | 136 ++++++++ .../views/account_vat_ledger_pdf.xml | 313 ++++++++++++++++++ .../views/account_vat_ledger_xlsx.xml | 16 + 6 files changed, 480 insertions(+), 5 deletions(-) create mode 100644 l10n_ar_ledger/models/account_vat_ledger_xlsx.py create mode 100644 l10n_ar_ledger/views/account_vat_ledger_pdf.xml create mode 100644 l10n_ar_ledger/views/account_vat_ledger_xlsx.xml diff --git a/l10n_ar_ledger/__manifest__.py b/l10n_ar_ledger/__manifest__.py index ddc1fde1..ee62a307 100644 --- a/l10n_ar_ledger/__manifest__.py +++ b/l10n_ar_ledger/__manifest__.py @@ -15,6 +15,8 @@ "security/ir.model.access.csv", "security/security.xml", "views/account_vat_ledger.xml", + "views/account_vat_ledger_pdf.xml", + "views/account_vat_ledger_xlsx.xml", ], "maintainers": ["nimarosa", "ibuioli"], "installable": True, diff --git a/l10n_ar_ledger/models/__init__.py b/l10n_ar_ledger/models/__init__.py index afbbfedd..e948b134 100644 --- a/l10n_ar_ledger/models/__init__.py +++ b/l10n_ar_ledger/models/__init__.py @@ -4,4 +4,5 @@ ############################################################################## from . import account_vat_ledger +from . import account_vat_ledger_xlsx from . import l10n_latam_document_type diff --git a/l10n_ar_ledger/models/account_vat_ledger.py b/l10n_ar_ledger/models/account_vat_ledger.py index 7152a77e..4ce25e51 100644 --- a/l10n_ar_ledger/models/account_vat_ledger.py +++ b/l10n_ar_ledger/models/account_vat_ledger.py @@ -399,6 +399,13 @@ def get_REGDIGITAL_CV_ALICUOTAS(self, impo=False): # REGDIGITAL_CV_CBTE Methods + def get_vat_import(self, vat, code): + import_vat = 0 + for v in vat: + if v["Id"] == code: + import_vat = import_vat + v["Importe"] + return import_vat + def _check_partners(self, invoices): if self.type == "purchase": partners = invoices.mapped("commercial_partner_id").filtered( @@ -602,11 +609,11 @@ def get_REGDIGITAL_CV_CBTE(self): else: imp_neto = 0 imp_liquidado = 0 - for mvl_tax in inv.l10n_latam_tax_ids: - tax_group_id = mvl_tax.tax_group_id - if tax_group_id.l10n_ar_vat_afip_code in [3, 4, 5, 6, 8, 9]: - imp_neto += mvl_tax.tax_base_amount - imp_liquidado += mvl_tax.price_subtotal + vats = inv._get_vat() + for v in vats: + if v["Id"] in ["3", "4", "5", "6", "8", "9"]: + imp_neto += v["BaseImp"] + imp_liquidado = v["BaseImp"] + v["Importe"] row.append(self.format_amount(round(imp_liquidado, 2), invoice=inv)) row += [ diff --git a/l10n_ar_ledger/models/account_vat_ledger_xlsx.py b/l10n_ar_ledger/models/account_vat_ledger_xlsx.py new file mode 100644 index 00000000..5690862b --- /dev/null +++ b/l10n_ar_ledger/models/account_vat_ledger_xlsx.py @@ -0,0 +1,136 @@ +############################################################################## +# For copyright and license notices, see __manifest__.py file in module root +# directory +############################################################################## +from odoo import models + + +class AccountVatLedgerXlsx(models.AbstractModel): + _name = "report.l10n_ar_ledger.account_vat_ledger_xlsx" + _inherit = "report.report_xlsx.abstract" + _description = "Report VAT Ledger XLSX" + + def generate_xlsx_report(self, workbook, data, vat_ledger): + if vat_ledger.invoice_ids: + report_name = "IVA Ventas" + if vat_ledger.type == "purchase": + report_name = "IVA Compras" + + sheet = workbook.add_worksheet(report_name[:31]) + h = "#" + money_format = workbook.add_format( + {"num_format": "$ 0" + h + h + "." + h + h + "," + h + h} + ) + bold = workbook.add_format({"bold": True}) + sheet.write(1, 0, vat_ledger.display_name, bold) + + titles = [ + "Fecha", + "Razón Social", + "CUIT", + "Responsabilidad AFIP", + "Tipo de Comprobante", + "Nro Comprobante", + "Neto gravado", + "Neto no gravado", + "Neto exento", + "IVA 27%", + "IVA 21%", + "IVA 10.5%", + "Percepción de IVA", + "Perc IIBB", + "Percepciones Municipales", + "Otras Percepciones", + "Impuestos Internos", + "Otros", + "Total gravado", + "Total", + ] + for i, title in enumerate(titles): + sheet.write(3, i, title, bold) + + row = 4 + index = 0 + sheet.set_column("A:F", 30) + + for obj in vat_ledger.invoice_ids: + sheet.write( + row + index, 0, obj.invoice_date.strftime("%Y-%m-%d") + ) # Fecha + sheet.write(row + index, 1, obj.partner_id.name) # Razón Social + if obj.partner_id.vat: # CUIT + sheet.write(row + index, 2, obj.partner_id.vat) + else: + sheet.write(row + index, 2, "-") + sheet.write( + row + index, + 3, + obj.partner_id.l10n_ar_afip_responsibility_type_id.name, + ) # Responsabilidad AFIP + sheet.write( + row + index, 4, obj.l10n_latam_document_type_id.name + ) # Tipo de Comprobante + sheet.write(row + index, 5, obj.name) # Nro Comprobante + + amounts = obj._l10n_ar_get_amounts() + credit = 1 + if obj.l10n_latam_document_type_id.internal_type == "credit_note": + credit = -1 + + netoG = amounts["vat_taxable_amount"] + sheet.write( + row + index, 6, netoG * credit, money_format + ) # Neto gravado + + netoN = amounts["vat_untaxed_base_amount"] + sheet.write( + row + index, 7, netoN * credit, money_format + ) # Neto no gravado + + netoE = amounts["vat_exempt_base_amount"] + sheet.write(row + index, 8, netoE * credit, money_format) # Neto exento + + iva27 = vat_ledger.get_vat_import(obj._get_vat(), "6") + sheet.write(row + index, 9, iva27 * credit, money_format) # IVA 27% + + iva21 = vat_ledger.get_vat_import(obj._get_vat(), "5") + sheet.write(row + index, 10, iva21 * credit, money_format) # IVA 21% + + iva105 = vat_ledger.get_vat_import(obj._get_vat(), "4") + sheet.write(row + index, 11, iva105 * credit, money_format) # IVA 10.5% + + perc_iva = amounts["vat_perc_amount"] + sheet.write( + row + index, 12, perc_iva * credit, money_format + ) # Perpceción IVA + + perc_iibb = amounts["iibb_perc_amount"] + sheet.write( + row + index, 13, perc_iibb * credit, money_format + ) # Perpceción IIBB + + perc_mun = amounts["mun_perc_amount"] + sheet.write( + row + index, 14, perc_mun * credit, money_format + ) # Percepciones Municipales + + perc_other = amounts["other_perc_amount"] + sheet.write( + row + index, 15, perc_other * credit, money_format + ) # Otras Percepciones + + internal_taxes = amounts["intern_tax_amount"] + sheet.write( + row + index, 16, internal_taxes * credit, money_format + ) # Impuestos Internos + + other = amounts["other_taxes_amount"] + sheet.write(row + index, 17, other * credit, money_format) # Otros + + total_net = netoG + iva27 + iva21 + iva105 + other + sheet.write( + row + index, 18, total_net * credit, money_format + ) # Total Gravado + + sheet.write(row + index, 19, obj.amount_total, money_format) # Total + row = row + 1 diff --git a/l10n_ar_ledger/views/account_vat_ledger_pdf.xml b/l10n_ar_ledger/views/account_vat_ledger_pdf.xml new file mode 100644 index 00000000..c8eca948 --- /dev/null +++ b/l10n_ar_ledger/views/account_vat_ledger_pdf.xml @@ -0,0 +1,313 @@ + + + + + + + Apaisado - Libro IVA + + A4 + 0 + 0 + Landscape + 10 + 10 + 2 + 2 + + 40 + 95 + + + + + + diff --git a/l10n_ar_ledger/views/account_vat_ledger_xlsx.xml b/l10n_ar_ledger/views/account_vat_ledger_xlsx.xml new file mode 100644 index 00000000..2870a7fd --- /dev/null +++ b/l10n_ar_ledger/views/account_vat_ledger_xlsx.xml @@ -0,0 +1,16 @@ + + + + + + + + From 01aa4e544563f62c8fb4ffa2574127df45d134e0 Mon Sep 17 00:00:00 2001 From: Ignacio Buioli Date: Wed, 19 Jul 2023 21:06:05 -0300 Subject: [PATCH 2/3] [14.0] [IMP] l10n_ar_ledger: VAT reports --- .../views/account_vat_ledger_pdf.xml | 443 +++++++++--------- 1 file changed, 218 insertions(+), 225 deletions(-) diff --git a/l10n_ar_ledger/views/account_vat_ledger_pdf.xml b/l10n_ar_ledger/views/account_vat_ledger_pdf.xml index c8eca948..9d923e82 100644 --- a/l10n_ar_ledger/views/account_vat_ledger_pdf.xml +++ b/l10n_ar_ledger/views/account_vat_ledger_pdf.xml @@ -1,313 +1,306 @@ - + + + + Apaisado - Libro IVA + + A4 + 0 + 0 + Landscape + 10 + 10 + 2 + 2 + + 40 + 95 + + - - + From 1c0e2e14dea82fdd2ebc69361ae11604ab163adc Mon Sep 17 00:00:00 2001 From: Ignacio Buioli Date: Wed, 19 Jul 2023 21:34:35 -0300 Subject: [PATCH 3/3] [14.0] [IMP] l10n_ar_ledger: VAT reports --- l10n_ar_ledger/views/account_vat_ledger_xlsx.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/l10n_ar_ledger/views/account_vat_ledger_xlsx.xml b/l10n_ar_ledger/views/account_vat_ledger_xlsx.xml index 2870a7fd..17af5dd1 100644 --- a/l10n_ar_ledger/views/account_vat_ledger_xlsx.xml +++ b/l10n_ar_ledger/views/account_vat_ledger_xlsx.xml @@ -1,8 +1,8 @@ - + - - +