Skip to content

Commit

Permalink
[FIX] l10n_ar_account_tax_settlement: afip file for lines with foregi…
Browse files Browse the repository at this point in the history
…n currency

closes #232

Ticket: 60774
X-original-commit: f1b5c52
Signed-off-by: Katherine Zaoral <kz@adhoc.com.ar>
Signed-off-by: pablohmontenegro <pam@adhoc.com.ar>
  • Loading branch information
pablohmontenegro committed Oct 5, 2023
1 parent 153b144 commit 57eec2b
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions l10n_ar_account_tax_settlement/models/account_journal.py
Expand Up @@ -470,10 +470,12 @@ def iibb_aplicado_agip_files_values(self, move_lines):
'No hay alicuota configurada en el partner '
'"%s" (id: %s)') % (partner.name, partner.id))


ret_perc_applied = False
es_percepcion = False
# 1 - Tipo de Operación
if tax.type_tax_use in ['sale', 'purchase']:
# tax.amount_type == 'partner_tax':
es_percepcion = True
content = '2'
alicuot = alicuot_line.alicuota_percepcion
elif tax.type_tax_use in ['customer', 'supplier']:
Expand Down Expand Up @@ -545,7 +547,12 @@ def iibb_aplicado_agip_files_values(self, move_lines):
or_inv.invoice_date).strftime('%d/%m/%Y')

# 12 - Ret/percep a deducir
content += format_amount(line.balance, 16, 2, ',')

# si la línea tiene moneda diferente de la moneda de la compañía queremos que la ret/perc
# se calcule aplicando la alícuota sobre la base imponible en la moneda de la compañía
if line.currency_id and line.currency_id != line.company_id.currency_id:
ret_perc_applied = float_round((taxable_amount*alicuot/100), precision_digits=2)
content += format_amount((line.balance if not ret_perc_applied else ret_perc_applied), 16, 2, ',')

# 13 - Alícuota
content += format_amount(alicuot, 5, 2, ',')
Expand All @@ -566,7 +573,10 @@ def iibb_aplicado_agip_files_values(self, move_lines):
if internal_type == 'invoice':
content += '01'
elif internal_type == 'debit_note':
content += '02'
if es_percepcion:
content += '09'
else:
content += '02'
else:
# orden de pago
content += '03'
Expand Down Expand Up @@ -693,10 +703,15 @@ def iibb_aplicado_agip_files_values(self, move_lines):
content += format_amount(alicuot, 5, 2, ',')

# 20 - Retención/Percepción Practicada
content += format_amount(-line.balance, 16, 2, ',')

# si la línea tiene moneda diferente de la moneda de la compañía queremos que la ret/perc
# se calcule aplicando la alícuota sobre la base imponible en la moneda de la compañía
if line.currency_id and line.currency_id != line.company_id.currency_id:
ret_perc_applied = float_round((taxable_amount*alicuot/100), precision_digits=2)
content += format_amount((-line.balance if not ret_perc_applied else ret_perc_applied), 16, 2, ',')

# 21 - Monto Total Retenido/Percibido
content += format_amount(-line.balance, 16, 2, ',')
content += format_amount((-line.balance if not ret_perc_applied else ret_perc_applied), 16, 2, ',')

content += '\r\n'

Expand Down

0 comments on commit 57eec2b

Please sign in to comment.