Skip to content

Commit

Permalink
[fix]l10n_it_fatturapa_out fix invoice with downpayment
Browse files Browse the repository at this point in the history
before the fix  the dictionary it was always rewritten, now it update if the key of the tax is the same

Co-authored-by: Marcoapu <[email protected]>
  • Loading branch information
matteoopenf and Marcoapu committed Sep 24, 2024
1 parent 232beba commit 3972d17
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from odoo import api, fields, models
from odoo.exceptions import UserError
from odoo.tools import float_is_zero
from odoo.tools.translate import _

from odoo.addons.l10n_it_account.tools.account_tools import encode_for_export
Expand Down Expand Up @@ -146,14 +147,28 @@ def _key(tax_id):
tax_line_id = tax_id.tax_line_id
aliquota = format_numbers(tax_line_id.amount)
key = _key(tax_line_id)
out_computed[key] = {
"AliquotaIVA": aliquota,
"Natura": tax_line_id.kind_id.code,
# 'Arrotondamento':'',
"ImponibileImporto": tax_id.tax_base_amount,
"Imposta": abs(tax_id.balance),
"EsigibilitaIVA": tax_line_id.payability,
}
tax_amount = 0
dp = self.env["decimal.precision"].precision_get("Account")
if invoice.move_type == "out_invoice":
if float_is_zero(tax_id.credit, dp) and tax_id.debit:
tax_amount = -tax_id.balance

Check warning on line 154 in l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py#L154

Added line #L154 was not covered by tests
if tax_id.credit and float_is_zero(tax_id.debit, dp):
tax_amount = abs(tax_id.balance)
else:
tax_amount = abs(tax_id.balance)
if key not in out_computed:
out_computed[key] = {
"AliquotaIVA": aliquota,
"Natura": tax_line_id.kind_id.code,
# 'Arrotondamento':'',
"ImponibileImporto": tax_id.tax_base_amount,
"Imposta": tax_amount,
"EsigibilitaIVA": tax_line_id.payability,
}
else:
out_computed[key]["ImponibileImporto"] += tax_id.tax_base_amount
out_computed[key]["Imposta"] += tax_amount

Check warning on line 170 in l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py#L169-L170

Added lines #L169 - L170 were not covered by tests

if tax_line_id.law_reference:
out_computed[key]["RiferimentoNormativo"] = encode_for_export(
tax_line_id.law_reference, 100
Expand Down

0 comments on commit 3972d17

Please sign in to comment.