Skip to content

Commit

Permalink
[FIX] l10n_it_fatturapa_in: Rounding applied twice
Browse files Browse the repository at this point in the history
  • Loading branch information
SirAionTech committed Mar 1, 2024
1 parent 8152137 commit e78d481
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 27 deletions.
25 changes: 1 addition & 24 deletions l10n_it_fatturapa_in/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,6 @@ class AccountMove(models.Model):

e_invoice_received_date = fields.Date(string="E-Bill Received Date")

@api.depends(
"line_ids.matched_debit_ids.debit_move_id.move_id.line_ids.amount_residual",
"line_ids.matched_debit_ids.debit_move_id.move_id.line_ids.amount_residual_currency", # noqa: B950
"line_ids.matched_credit_ids.credit_move_id.move_id.line_ids.amount_residual",
"line_ids.matched_credit_ids.credit_move_id.move_id.line_ids.amount_residual_currency", # noqa: B950
"line_ids.debit",
"line_ids.credit",
"line_ids.currency_id",
"line_ids.amount_currency",
"line_ids.amount_residual",
"line_ids.amount_residual_currency",
"line_ids.payment_id.state",
"line_ids.full_reconcile_id",
)
def _compute_amount(self):
super()._compute_amount()
for inv in self:
if inv.efatt_rounding != 0:
inv.amount_total += inv.efatt_rounding
sign = inv.move_type in ["in_refund", "out_refund"] and -1 or 1
inv.amount_total_signed = inv.amount_total * sign
return # fix W8110

def action_post(self):
for invoice in self:
if (
Expand Down Expand Up @@ -125,7 +102,7 @@ def e_inv_check_amount_tax(self):

def e_inv_check_amount_total(self):
error_message = ""
bill_total = self.amount_total - self.efatt_rounding
bill_total = self.amount_total
e_bill_total = self.e_invoice_amount_total or 0
if (
e_bill_total
Expand Down
16 changes: 13 additions & 3 deletions l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2024 Simone Rubino - Aion Tech
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from datetime import date

from psycopg2 import IntegrityError
Expand Down Expand Up @@ -580,10 +583,17 @@ def test_25_xml_import(self):
res = self.run_wizard("test25", "IT05979361218_013.xml")
invoice_id = res.get("domain")[0][2][0]
invoice = self.invoice_model.browse(invoice_id)
self.assertAlmostEqual(invoice.e_invoice_amount_untaxed, 34.67)
e_bill_total = 34.32
e_bill_rounding = -0.35
self.assertAlmostEqual(
invoice.e_invoice_amount_untaxed, e_bill_total - e_bill_rounding
)
self.assertEqual(invoice.e_invoice_amount_tax, 0.0)
self.assertEqual(invoice.e_invoice_amount_total, 34.32)
self.assertEqual(invoice.efatt_rounding, -0.35)
self.assertEqual(invoice.e_invoice_amount_total, e_bill_total)
self.assertEqual(invoice.efatt_rounding, e_bill_rounding)
self.assertEqual(invoice.amount_total, e_bill_total)
self.assertEqual(invoice.amount_total_signed, -e_bill_total)
self.assertEqual(invoice.amount_net_pay, e_bill_total)
invoice.action_post()
move_line = False
for line in invoice.line_ids:
Expand Down

0 comments on commit e78d481

Please sign in to comment.