Skip to content

Commit

Permalink
[IMP] l10n_ar_account_tax_settlement: sicore aplicado iva percepciones
Browse files Browse the repository at this point in the history
Generates the txt file for sicore IVA applied insights
  • Loading branch information
pablohmontenegro committed Jan 26, 2022
1 parent b172a55 commit e900a8e
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 33 deletions.
1 change: 1 addition & 0 deletions l10n_ar_account_tax_settlement/__manifest__.py
Expand Up @@ -34,6 +34,7 @@
'data/account_financial_report_data.xml',
'data/inflation_adjustment_index.xml',
'views/inflation_adjustmen_index_view.xml',
'views/account_tax_view.xml',
'wizards/inflation_adjustment_view.xml',
'security/ir.model.access.csv',
],
Expand Down
1 change: 1 addition & 0 deletions l10n_ar_account_tax_settlement/models/__init__.py
Expand Up @@ -2,3 +2,4 @@
from . import account_chart_template
from . import account_journal
from . import inflation_adjustment_index
from . import account_tax
78 changes: 45 additions & 33 deletions l10n_ar_account_tax_settlement/models/account_journal.py
Expand Up @@ -4,8 +4,6 @@
# from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
import re

# from odoo.exceptions import ValidationError

#########
# helpers
#########
Expand Down Expand Up @@ -1121,71 +1119,85 @@ def sicore_aplicado_files_values(self, move_lines):
payment = line.payment_id
pay_group = payment.payment_group_id
move = line.move_id
if not payment:
raise ValidationError(_(
'La liquidación de percepciones todavía no está '
'implementada. Apunte contable: %s' % line.id))

# Codigo del Comprobante [ 2]
content += (payment.payment_type == 'inbound' and '02') or (
payment.payment_type == 'outbound' and '06') or '00'

# Fecha Emision Comprobante [10] (dd/mm/yyyy)
content += fields.Date.from_string(
pay_group.payment_date).strftime('%d/%m/%Y')
#si tengo payment es una retención, sino es una percepción y tengo que sacar la información de la factura (del move)
if payment:
# Codigo del Comprobante [ 2]
content += (payment.payment_type == 'inbound' and '02') or (
payment.payment_type == 'outbound' and '06') or '00'

# Numbero Comprobante [16]
content += '%016d' % int(
re.sub('[^0-9]', '', move.l10n_latam_document_number))
# Fecha Emision Comprobante [10] (dd/mm/yyyy)
content += fields.Date.from_string(
pay_group.payment_date).strftime('%d/%m/%Y')
# Numero Comprobante [16]
content += '%016d' % int(re.sub('[^0-9]', '', move.l10n_latam_document_number))
#Importe del comprobante
codop = '1'
issue_date = payment.payment_date
amount_tot = abs(payment.payment_group_id.payments_amount)
base_amount = payment.withholding_base_amount
elif move.is_invoice():
# Codigo del Comprobante [ 2]
# content += TODO escribir...ej, factura, nc, etc
content += '%02d' % int(move.l10n_latam_document_type_id.code)
# Fecha Emision Comprobante [10] (dd/mm/yyyy)
content += fields.Date.from_string(
move.invoice_date).strftime('%d/%m/%Y')
# Numero Comprobante [16]
# content += '%016d' % int(re.sub('[^0-9]', '', move.l10n_latam_document_number))
content += '%05d' % int(re.sub('[^0-9]', '', move.l10n_latam_document_number)[:5])
content += '%011d' % int(re.sub('[^0-9]', '', move.l10n_latam_document_number)[11:])
issue_date = move.invoice_date
base_amount = line.tax_base_amount
codop = '2'
#Importe del comprobante
amount_tot = abs(move.amount_total_signed)

# Importe Comprobante [16]
content += '%016.2f' % payment.payment_group_id.payments_amount

content += '%016.2f' % amount_tot
# Codigo de Impuesto [ 4]
# Codigo de Regimen [ 3]
if line.tax_line_id.tax_group_id in (
self.env.ref('l10n_ar_ux.tax_group_retencion_ganancias'),
self.env.ref('l10n_ar.tax_group_percepcion_ganancias')):
if line.tax_line_id.tax_group_id == self.env.ref('l10n_ar_ux.tax_group_retencion_ganancias'):
content += '0217'
regimen = pay_group.regimen_ganancias_id
# necesitamos lo de filter porque hay dos regimenes que le
# agregamos caracteres
content += regimen and '%03d' % int(''.join(filter(
str.isdigit, str(regimen.codigo_de_regimen)))) or '000'
elif line.tax_line_id.tax_group_id in (
self.env.ref('l10n_ar_ux.tax_group_retencion_iva'),
self.env.ref('l10n_ar.tax_group_percepcion_iva')):
elif line.tax_line_id.tax_group_id == self.env.ref('l10n_ar_ux.tax_group_retencion_iva'):
content += '0767'
# por ahora el unico implementado es para factura M
content += '499'
elif line.tax_line_id.tax_group_id == self.env.ref('l10n_ar.tax_group_percepcion_iva'):
content += '0767'
content += '%03d' % int(line.tax_line_id.codigo_regimen) # (ver account tax) DUDA cómo le aplico el código de régimen a las facturas viejas
else:
raise ValidationError(_('Para sicore solo IVA y Ganancias están implementados'))
raise ValidationError(_('Grupos de impuestos %s no implementados para SICORE') % line.tax_line_id.tax_group_id.name)

# Codigo de Operacion [ 1]
content += '1' # TODO: ????
content += codop # TODO: ???? DUDA: SERÍA PARA VER SI ES RETENCION O PERCEPCION

# Base de Calculo [14]
content += '%014.2f' % payment.withholdable_base_amount
content += '%014.2f' % base_amount

# Fecha Emision Retencion [10] (dd/mm/yyyy)
content += fields.Date.from_string(
payment.payment_date).strftime('%d/%m/%Y')
content += fields.Date.from_string(issue_date).strftime('%d/%m/%Y')

# Codigo de Condicion [ 2]
content += '01' # TODO: ????
content += '01' # TODO: ???? ver tabla de condición sicore

# Retención Pract. a Suj. .. [ 1]
content += '0' # TODO: ????

# Importe de Retencion [14]
content += '%014.2f' % -line.balance
content += '%014.2f' % abs(line.balance)

# Porcentaje de Exclusion [ 6]
content += '000.00' # TODO: ????
content += '%06.2f' % line.tax_line_id.porcentaje_exclusion or '000.00'

# Fecha Emision Boletin [10] (dd/mm/yyyy)
content += fields.Date.from_string(
payment.payment_date).strftime('%d/%m/%Y')
issue_date).strftime('%d/%m/%Y')

# Tipo Documento Retenido [ 2]
content += '%02d' % int(partner.l10n_latam_identification_type_id.l10n_ar_afip_code)
Expand Down
13 changes: 13 additions & 0 deletions l10n_ar_account_tax_settlement/models/account_tax.py
@@ -0,0 +1,13 @@
from odoo import api, models, fields, _
from odoo.exceptions import ValidationError

class AccountTax(models.Model):
_inherit = 'account.tax'

codigo_regimen = fields.Char(string='Codigo de regimen IVA', size=3)
porcentaje_exclusion = fields.Float(string='Porcentaje de exclusión')

@api.constrains('codigo_regimen', 'tax_group_id')
def _check_codigo_regimen(self):
if self.filtered(lambda x: x.codigo_regimen and x.tax_group_id.l10n_ar_tribute_afip_code != '06'):
raise ValidationError(_('El código de régimen de iva es solo utilizado para percepciones de iva'))
14 changes: 14 additions & 0 deletions l10n_ar_account_tax_settlement/views/account_tax_view.xml
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_tax_form_inherited" model="ir.ui.view">
<field name="name">account.tax.form.inherited</field>
<field name="model">account.tax</field>
<field name="inherit_id" ref="account.view_tax_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='tax_group_id']" position="after">
<field name="codigo_regimen"/>
<field name="porcentaje_exclusion"/>
</xpath>
</field>
</record>
</odoo>

0 comments on commit e900a8e

Please sign in to comment.