Skip to content

Commit

Permalink
FIX tests based on account_invoice_triple_discount
Browse files Browse the repository at this point in the history
  • Loading branch information
eLBati committed Nov 24, 2023
1 parent d85268d commit 8dd0e03
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 3 additions & 1 deletion l10n_it_fatturapa_in/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)


Expand Down
14 changes: 7 additions & 7 deletions l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion l10n_it_ricevute_bancarie/tests/test_riba.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8dd0e03

Please sign in to comment.