Skip to content

Commit 3e8d0d3

Browse files
manuelregidorTisho99
authored andcommitted
[FIX]sale_advance_payment: Amount residual with signed invoice amount
1 parent 4660e28 commit 3e8d0d3

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

sale_advance_payment/tests/test_sale_advance_payment.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,3 +401,33 @@ def test_04_refunds(self):
401401
self.sale_order_1.amount_residual,
402402
3600,
403403
)
404+
405+
def test_05_residual_amount_credit_note(self):
406+
self.sale_order_1.action_confirm()
407+
self.sale_order_1._create_invoices()
408+
invoice = self.sale_order_1.invoice_ids[0]
409+
invoice.invoice_date = fields.Date.today()
410+
invoice.action_post()
411+
self.env["account.payment.register"].with_context(
412+
active_model="account.move", active_ids=invoice.ids
413+
).create(
414+
{
415+
"amount": 3600.0,
416+
"group_payment": True,
417+
"payment_difference_handling": "open",
418+
}
419+
)._create_payments()
420+
self.assertEqual(self.sale_order_1.amount_residual, 0)
421+
credit_note = invoice._reverse_moves()
422+
credit_note.invoice_date = fields.Date.today()
423+
credit_note.action_post()
424+
self.env["account.payment.register"].with_context(
425+
active_model="account.move", active_ids=credit_note.ids
426+
).create(
427+
{
428+
"amount": 3600.0,
429+
"group_payment": True,
430+
"payment_difference_handling": "open",
431+
}
432+
)._create_payments()
433+
self.assertEqual(self.sale_order_1.amount_residual, 3600)

0 commit comments

Comments
 (0)