Skip to content

Commit

Permalink
Merge PR #79 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by nimarosa
  • Loading branch information
OCA-git-bot committed Aug 17, 2023
2 parents 1d73016 + 1c0e2e1 commit 3d25a99
Show file tree
Hide file tree
Showing 6 changed files with 473 additions and 5 deletions.
2 changes: 2 additions & 0 deletions l10n_ar_ledger/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions l10n_ar_ledger/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
##############################################################################

from . import account_vat_ledger
from . import account_vat_ledger_xlsx
from . import l10n_latam_document_type
17 changes: 12 additions & 5 deletions l10n_ar_ledger/models/account_vat_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 += [
Expand Down
136 changes: 136 additions & 0 deletions l10n_ar_ledger/models/account_vat_ledger_xlsx.py
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 3d25a99

Please sign in to comment.