Skip to content

Commit 4f7f0ba

Browse files
[FIX]l10n_it_riba_oca add test to very the fee is added when the invoice is confirmed from tree
1 parent 5f24b6c commit 4f7f0ba

File tree

1 file changed

+42
-6
lines changed

1 file changed

+42
-6
lines changed

l10n_it_riba_oca/tests/test_riba.py

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,38 @@ def test_add_due_cost(self):
4444
new_inv = self.invoice.copy()
4545
self.assertEqual(len(new_inv.invoice_line_ids), 1)
4646

47+
def test_add_due_cost_via_post(self):
48+
"""Collection fees are added when _post is called directly.
49+
50+
Regression test for https://github.com/OCA/l10n-italy/issues/5063:
51+
when confirming invoices from the list view using 'Confirm Entries',
52+
the collection fees must be added. Before this fix, the fee-adding
53+
logic was only in action_post() and was skipped when _post() was
54+
called directly.
55+
"""
56+
# ---- Set Service in Company Config
57+
self.invoice.company_id.due_cost_service_id = self.service_due_cost.id
58+
# ---- Validate Invoice using _post() directly, simulating the code
59+
# ---- path used by batch confirmation from list view
60+
self.invoice._post(soft=False)
61+
# ---- Test Invoice has 3 lines (1 product + 2 collection fees)
62+
self.assertEqual(len(self.invoice.invoice_line_ids), 3)
63+
# ---- Test Invoice Line for service cost
64+
self.assertEqual(
65+
self.invoice.invoice_line_ids[1].product_id.id, self.service_due_cost.id
66+
)
67+
self.assertEqual(
68+
self.invoice.invoice_line_ids[2].product_id.id, self.service_due_cost.id
69+
)
70+
# ---- Test Cost lines total is equal to 10.00 (5.00 x 2 due dates)
71+
self.assertEqual(
72+
(
73+
self.invoice.invoice_line_ids[1].price_unit
74+
+ self.invoice.invoice_line_ids[2].price_unit
75+
),
76+
10.00,
77+
)
78+
4779
def test_not_add_due_cost(self):
4880
# create 2 invoice for partner in same month on the second one no
4981
# collection fees line expected
@@ -983,9 +1015,11 @@ def test_charge_to_customer_with_partner(self):
9831015

9841016
# Find the bank fee line
9851017
bank_fee_line = past_due_move.line_ids.filtered(
986-
lambda line: line.name == "Bank Fee"
987-
and line.account_id == past_due_wizard.bank_expense_account_id
988-
and line.debit > 0
1018+
lambda line: (
1019+
line.name == "Bank Fee"
1020+
and line.account_id == past_due_wizard.bank_expense_account_id
1021+
and line.debit > 0
1022+
)
9891023
)
9901024

9911025
# Assert that partner_id is set
@@ -1024,9 +1058,11 @@ def test_charge_to_customer_without_partner(self):
10241058

10251059
# Find the bank fee line
10261060
bank_fee_line = past_due_move.line_ids.filtered(
1027-
lambda line: line.name == "Bank Fee"
1028-
and line.account_id == past_due_wizard.bank_expense_account_id
1029-
and line.debit > 0
1061+
lambda line: (
1062+
line.name == "Bank Fee"
1063+
and line.account_id == past_due_wizard.bank_expense_account_id
1064+
and line.debit > 0
1065+
)
10301066
)
10311067

10321068
# Assert that partner_id is not set

0 commit comments

Comments
 (0)