Skip to content

Commit

Permalink
Merge PR #4451 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by sergiocorato
  • Loading branch information
OCA-git-bot committed Nov 25, 2024
2 parents aa6627f + 408ef39 commit a1ca49b
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions l10n_it_declaration_of_intent/tests/test_declaration_of_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ def test_invoice_vendor_with_no_effect_on_declaration(self):

def test_all_invoice_types(self):
"""
Check that a declaration with all the invoice types
computes the totals correctly.
Check that declarations with both invoices and refunds compute
the totals correctly.
"""
partner = self.partner1

Expand Down Expand Up @@ -389,20 +389,30 @@ def test_all_invoice_types(self):
in_refund_balance = in_refund.line_ids.filtered("tax_ids").balance
self.assertEqual(in_refund_balance, -100)

invoices = out_invoice | in_invoice | out_refund | in_refund

declaration = self._create_declaration(partner, "out")
declaration.limit_amount = 2000
invoices.declaration_of_intent_ids = declaration

invoices.action_post()
used_amount = (
-out_invoice_balance
+ in_invoice_balance
- out_refund_balance
+ in_refund_balance
)
self.assertEqual(declaration.available_amount, 2000 - used_amount)
declaration_out = self._create_declaration(partner, "out")
declaration_out.limit_amount = 2000
invoices_in = in_invoice | in_refund
invoices_in.declaration_of_intent_ids = declaration_out

declaration_in = self._create_declaration(partner, "in")
declaration_in.limit_amount = 2000
invoices_out = out_invoice | out_refund
invoices_out.declaration_of_intent_ids = declaration_in

invoices_in.action_post()
invoices_out.action_post()

# balance is positive for in invoices
# add "in" invoice and refund and compare with "out" DI available_amount
used_amount_in = in_invoice_balance + in_refund_balance
self.assertEqual(used_amount_in, 800)
self.assertEqual(declaration_out.available_amount, 2000 - used_amount_in)

# balance is positive for out invoices
# add "out" invoice and refund and compare with "in" DI available_amount
used_amount_out = -out_invoice_balance - out_refund_balance
self.assertEqual(used_amount_out, 800)
self.assertEqual(declaration_in.available_amount, 2000 - used_amount_out)

def test_invoice_repost(self):
invoice = self._create_invoice(
Expand Down

0 comments on commit a1ca49b

Please sign in to comment.