File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,7 +82,9 @@ def _compute_advance_payment(self):
8282 # Consider payments in related invoices.
8383 invoice_paid_amount = 0.0
8484 for inv in order .invoice_ids :
85- invoice_paid_amount += inv .amount_total - inv .amount_residual
85+ invoice_paid_amount += (
86+ inv .amount_total_signed - inv .amount_residual_signed
87+ )
8688 amount_residual = order .amount_total - advance_amount - invoice_paid_amount
8789 payment_state = "not_paid"
8890 if mls :
Original file line number Diff line number Diff line change @@ -482,3 +482,33 @@ def test_04_sale_advance_payment_multi_inv_validate_wiz(self):
482482 payments = invoice .invoice_outstanding_credits_debits_widget
483483 result = [d ["amount" ] for d in payments ["content" ]]
484484 self .assertEqual (set (payment_list ), set (result ))
485+
486+ def test_05_residual_amount_credit_note (self ):
487+ self .sale_order_1 .action_confirm ()
488+ self .sale_order_1 ._create_invoices ()
489+ invoice = self .sale_order_1 .invoice_ids [0 ]
490+ invoice .invoice_date = fields .Date .today ()
491+ invoice .action_post ()
492+ self .env ["account.payment.register" ].with_context (
493+ active_model = "account.move" , active_ids = invoice .ids
494+ ).create (
495+ {
496+ "amount" : 3600.0 ,
497+ "group_payment" : True ,
498+ "payment_difference_handling" : "open" ,
499+ }
500+ )._create_payments ()
501+ self .assertEqual (self .sale_order_1 .amount_residual , 0 )
502+ credit_note = invoice ._reverse_moves ()
503+ credit_note .invoice_date = fields .Date .today ()
504+ credit_note .action_post ()
505+ self .env ["account.payment.register" ].with_context (
506+ active_model = "account.move" , active_ids = credit_note .ids
507+ ).create (
508+ {
509+ "amount" : 3600.0 ,
510+ "group_payment" : True ,
511+ "payment_difference_handling" : "open" ,
512+ }
513+ )._create_payments ()
514+ self .assertEqual (self .sale_order_1 .amount_residual , 3600 )
You can’t perform that action at this time.
0 commit comments