From 8dd0e032612f3eec3363803f4bcc515e984aab69 Mon Sep 17 00:00:00 2001 From: eLBati Date: Tue, 31 Oct 2023 07:24:49 +0100 Subject: [PATCH] FIX tests based on account_invoice_triple_discount --- l10n_it_fatturapa_in/models/account.py | 4 +++- .../tests/test_import_fatturapa_xml.py | 14 +++++++------- l10n_it_ricevute_bancarie/tests/test_riba.py | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/l10n_it_fatturapa_in/models/account.py b/l10n_it_fatturapa_in/models/account.py index 4c3f2e578628..587d425733ed 100644 --- a/l10n_it_fatturapa_in/models/account.py +++ b/l10n_it_fatturapa_in/models/account.py @@ -320,6 +320,8 @@ def set_einvoice_data(self, fattura): def process_negative_lines(self): self.ensure_one() + if not self.invoice_line_ids: + return for line in self.invoice_line_ids: if line.price_unit >= 0: return @@ -329,7 +331,7 @@ def process_negative_lines(self): {"price_unit": -line.price_unit} ) self.with_context(check_move_validity=False)._recompute_dynamic_lines( - recompute_all_taxes=True + recompute_all_taxes=True, recompute_tax_base_amount=True ) diff --git a/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py b/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py index 2c6da7820602..6dceb15ff024 100644 --- a/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py +++ b/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py @@ -52,7 +52,7 @@ def test_00_xml_import(self): welfare_found = False for line in invoice.invoice_line_ids: if line.product_id.id == self.service.id: - self.assertEqual(line.price_unit, 3) + self.assertAlmostEqual(line.price_unit, 3) welfare_found = True self.assertTrue(welfare_found) self.assertTrue(len(invoice.e_invoice_line_ids) == 1) @@ -135,7 +135,7 @@ def test_04_xml_import(self): self.assertEqual(invoice.invoice_line_ids[1].tax_ids[0].name, "22% e-bill") self.assertEqual(invoice.invoice_line_ids[0].tax_ids[0].amount, 22) self.assertEqual(invoice.invoice_line_ids[1].tax_ids[0].amount, 22) - self.assertEqual(invoice.invoice_line_ids[1].price_unit, 2) + self.assertAlmostEqual(invoice.invoice_line_ids[1].price_unit, 2) self.assertTrue(len(invoice.e_invoice_line_ids) == 2) for e_line in invoice.e_invoice_line_ids: self.assertTrue(e_line.line_number in (1, 2)) @@ -648,10 +648,10 @@ def test_32_xml_import(self): invoice = self.invoice_model.browse(invoice_id) self.assertEqual(invoice.move_type, "in_refund") self.assertEqual(invoice.amount_total, 18.3) - self.assertEqual(invoice.invoice_line_ids[0].price_unit, 2.0) + self.assertAlmostEqual(invoice.invoice_line_ids[0].price_unit, 2.0) self.assertEqual(invoice.invoice_line_ids[0].quantity, 10.0) self.assertEqual(invoice.invoice_line_ids[0].price_subtotal, 20.0) - self.assertEqual(invoice.invoice_line_ids[1].price_unit, -1.0) + self.assertAlmostEqual(invoice.invoice_line_ids[1].price_unit, -1.0) self.assertEqual(invoice.invoice_line_ids[1].quantity, 5.0) self.assertEqual(invoice.invoice_line_ids[1].price_subtotal, -5.0) @@ -662,7 +662,7 @@ def test_33_xml_import(self): invoice = self.invoice_model.browse(invoice_id) self.assertEqual(invoice.move_type, "in_refund") self.assertEqual(round(invoice.amount_total, 2), 24.4) - self.assertEqual(invoice.invoice_line_ids[0].price_unit, 2.0) + self.assertAlmostEqual(invoice.invoice_line_ids[0].price_unit, 2.0) self.assertEqual(invoice.invoice_line_ids[0].quantity, 10.0) self.assertEqual(invoice.invoice_line_ids[0].price_subtotal, 20.0) self.assertEqual(invoice.e_invoice_amount_untaxed, -20.0) @@ -815,7 +815,7 @@ def test_46_xml_many_zeros(self): invoice_id = res.get("domain")[0][2][0] invoice = self.invoice_model.browse(invoice_id) self.assertEqual(invoice.amount_total, 18.07) - self.assertEqual(invoice.invoice_line_ids[0].price_unit, 18.07) + self.assertAlmostEqual(invoice.invoice_line_ids[0].price_unit, 18.07) self.assertEqual(invoice.invoice_line_ids[0].quantity, 1.0) self.assertEqual(invoice.invoice_line_ids[0].price_subtotal, 18.07) self.assertEqual(invoice.invoice_line_ids[1].price_unit, 16.60) @@ -1074,7 +1074,7 @@ def test_xml_import_summary_tax_rate(self): self.assertEqual(invoice.invoice_line_ids[0].price_unit, 164.46) self.assertEqual(invoice.invoice_line_ids[0].quantity, 1.0) - self.assertEqual(invoice.invoice_line_ids[1].price_unit, 3.52) + self.assertAlmostEqual(invoice.invoice_line_ids[1].price_unit, 3.52) self.assertEqual(invoice.invoice_line_ids[1].quantity, 1.0) def test_e_invoice_field_compute(self): diff --git a/l10n_it_ricevute_bancarie/tests/test_riba.py b/l10n_it_ricevute_bancarie/tests/test_riba.py index a69031a471c4..edbef4c769b0 100644 --- a/l10n_it_ricevute_bancarie/tests/test_riba.py +++ b/l10n_it_ricevute_bancarie/tests/test_riba.py @@ -31,7 +31,7 @@ def test_add_due_cost(self): self.invoice.invoice_line_ids[2].product_id.id, self.service_due_cost.id ) # ---- Test Cost line is equal to 10.00 - self.assertEqual( + self.assertAlmostEqual( ( self.invoice.invoice_line_ids[1].price_unit + self.invoice.invoice_line_ids[2].price_unit