Skip to content

Commit

Permalink
[IMP]l10n_ar_account_tax_settlement: retenciones y percepciones IVA txt
Browse files Browse the repository at this point in the history
closes #153

Ticket: 54274
Signed-off-by: Nacho Cainelli <[email protected]>
  • Loading branch information
pablohmontenegro committed Dec 16, 2022
1 parent d23e069 commit c06fc8b
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions l10n_ar_account_tax_settlement/models/account_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class AccountJournal(models.Model):
('iibb_aplicado_api', 'TXT Perc/Ret IIBB aplicadas API'),
('iibb_aplicado_sircar', 'TXT Perc/Ret IIBB aplicadas SIRCAR'),
('iibb_aplicado_dgr_mendoza', 'TXT Perc/Ret IIBB aplicado DGR Mendonza'),
('retenciones_iva', 'TXT Retenciones/Percepciones Sufridas IVA'),
# ('other', 'Other')
])

Expand Down Expand Up @@ -1343,3 +1344,59 @@ def misiones_files_values(self, move_lines):
'txt_filename': ('Retenciones ' if payment else 'Percepciones ') + 'Misiones.txt',
'txt_content': content,
}]

def retenciones_iva_files_values(self, move_lines):
""" Implementado segun especificación indicada en ticket 54274."""
self.ensure_one()
content = ''
for line in move_lines.sorted(key=lambda r: (r.date, r.id)):
payment = line.payment_id
if payment:
# regimen (long 3)
codigo_regimen = payment.tax_withholding_id.codigo_regimen
if not codigo_regimen:
raise ValidationError(_('No hay código de régimen en la configuración del impuesto "%s"') % (
payment.tax_withholding_id.name))
if len(codigo_regimen) < 3:
raise ValidationError(_('El código de régimen tiene que tener 3 dígitos en la configuración del impuesto "%s"') % (payment.tax_withholding_id.name))
content += codigo_regimen[:3]

# cuit agente (long 11)
content += payment.partner_id.ensure_vat()

# fecha retención (long 10)
content += fields.Date.from_string(payment.payment_date).strftime('%d/%m/%Y')

# número comprobante (long 16)
content += re.sub('[^0-9\.-]', '', payment.move_name)[1:].ljust(16)

# importe retención (long 16)
content += '%16.2f' % payment.amount
content += '\r\n'
elif line.move_id.is_invoice():
# regimen (long 3)
codigo_regimen = line.tax_line_id.codigo_regimen
if not codigo_regimen:
raise ValidationError(_('No hay código de régimen en la configuración del impuesto "%s"') % (
line.tax_withholding_id.name))
if len(codigo_regimen) < 3:
raise ValidationError(_('El código de régimen tiene que tener 3 dígitos en la configuración del impuesto "%s"') % (line.tax_withholding_id.name))
content += codigo_regimen[:3]

# cuit agente (long 11)
content += line.move_id.partner_id.ensure_vat()

# fecha retención (long 10)
content += fields.Date.from_string(line.move_id.invoice_date).strftime('%d/%m/%Y')

# número comprobante (long 16)
content += line.move_id.l10n_latam_document_number.ljust(16)

# importe retención (long 16)
content += '%16.2f' % line.balance
content += '\r\n'

return [{
'txt_filename': ('Retenciones' if payment else 'Percepciones') + '_iva.txt',
'txt_content': content,
}]

0 comments on commit c06fc8b

Please sign in to comment.