Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][FIX]sale_advance_payment: Amount residual with signed invoice amount #3542

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading