From 75ec0a0a85a010415765518f5a9e36bb13d08b22 Mon Sep 17 00:00:00 2001 From: marination Date: Fri, 3 Mar 2023 14:13:27 +0530 Subject: [PATCH] fix: Recalculate difference amount after setting deductions --- erpnext/accounts/doctype/payment_entry/payment_entry.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 91d31ab0ec..cf1cc0a839 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -1772,6 +1772,7 @@ def get_payment_entry( discount_amount = set_early_payment_discount_loss(pe, doc, valid_discounts, discount_amount) if discount_amount > 0: + # Set pending discount amount in deductions pe.set_gain_or_loss( account_details={ "account": frappe.get_cached_value("Company", pe.company, "default_discount_account"), @@ -1780,7 +1781,8 @@ def get_payment_entry( "amount": discount_amount * (-1 if payment_type == "Pay" else 1), } ) - pe.set_difference_amount() + + pe.set_difference_amount() return pe