Skip to content

Commit

Permalink
Merge PR #3542 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by HaraldPanten
  • Loading branch information
OCA-git-bot committed Jan 23, 2025
2 parents 8f777fc + bbdb7ed commit 88e67a4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sale_advance_payment/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def _compute_advance_payment(self):
# Consider payments in related invoices.
invoice_paid_amount = 0.0
for inv in order.invoice_ids:
invoice_paid_amount += inv.amount_total - inv.amount_residual
invoice_paid_amount += (
inv.amount_total_signed - inv.amount_residual_signed
)
amount_residual = order.amount_total - advance_amount - invoice_paid_amount
payment_state = "not_paid"
inv_currency = order.currency_id or self.env.company.currency_id
Expand Down
30 changes: 30 additions & 0 deletions sale_advance_payment/tests/test_sale_advance_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,33 @@ def test_03_residual_amount_big_pre_payment(self):
self.assertEqual(invoice.amount_residual, 0.0)
self.assertEqual(self.sale_order_1.amount_residual, 1600)
self.assertEqual(invoice.amount_residual, 0)

def test_04_residual_amount_credit_note(self):
self.sale_order_1.action_confirm()
self.sale_order_1._create_invoices()
invoice = self.sale_order_1.invoice_ids[0]
invoice.invoice_date = fields.Date.today()
invoice.action_post()
self.env["account.payment.register"].with_context(
active_model="account.move", active_ids=invoice.ids
).create(
{
"amount": 3600.0,
"group_payment": True,
"payment_difference_handling": "open",
}
)._create_payments()
self.assertEqual(self.sale_order_1.amount_residual, 0)
credit_note = invoice._reverse_moves()
credit_note.invoice_date = fields.Date.today()
credit_note.action_post()
self.env["account.payment.register"].with_context(
active_model="account.move", active_ids=credit_note.ids
).create(
{
"amount": 3600.0,
"group_payment": True,
"payment_difference_handling": "open",
}
)._create_payments()
self.assertEqual(self.sale_order_1.amount_residual, 3600)

0 comments on commit 88e67a4

Please sign in to comment.