Skip to content

Commit

Permalink
[FIX] l10n_it_reverse_charge: Negative lines management
Browse files Browse the repository at this point in the history
Otherwise bills having negative lines raise an error when confirmed
  • Loading branch information
SirTakobi authored and SirAionTech committed Sep 5, 2024
1 parent e55741f commit 5b2fcf0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion l10n_it_reverse_charge/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,11 @@ def _rc_get_move_line_to_reconcile(self):
else:
raise UserError(_("Only inbound and outbound moves are supported"))

to_reconcile_move_lines = self.line_ids.filtered(
lambda ml: ml.account_id.reconcile
)
is_zero = self.currency_id.is_zero
for move_line in self.line_ids:
for move_line in to_reconcile_move_lines:
field_value = getattr(move_line, line_field)
if not is_zero(field_value) and move_line.account_id.account_type in (
"asset_receivable",
Expand Down
13 changes: 13 additions & 0 deletions l10n_it_reverse_charge/tests/test_rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,16 @@ def test_description_lines(self):

# Assert
self.assertEqual(bill.state, "posted")

def test_negative_lines(self):
"""A Reverse Charge Bill can be confirmed
when contains negative lines."""
# Arrange: Create a Reverse Charge Bill with negative lines
bill = self.create_invoice(
self.supplier_extraEU,
amounts=[100, -10],
taxes=self.tax_0_pur,
)

# Assert
self.assertEqual(bill.state, "posted")

0 comments on commit 5b2fcf0

Please sign in to comment.