Merge pull request #11406 from rohitwaghchaure/payment_entry_differnece_amount_issue
[Fix] Wrong difference amount in the payment entry for the internal transfer type
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js
index 17ac1f7..52d8a2d 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.js
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js
@@ -648,13 +648,13 @@
set_difference_amount: function(frm) {
var unallocated_amount = 0;
+ var total_deductions = frappe.utils.sum($.map(frm.doc.deductions || [],
+ function(d) { return flt(d.amount) }));
+
if(frm.doc.party) {
var party_amount = frm.doc.payment_type=="Receive" ?
frm.doc.paid_amount : frm.doc.received_amount;
- var total_deductions = frappe.utils.sum($.map(frm.doc.deductions || [],
- function(d) { return flt(d.amount) }));
-
if(frm.doc.total_allocated_amount < party_amount) {
if(frm.doc.payment_type == "Receive") {
unallocated_amount = party_amount - (frm.doc.total_allocated_amount - total_deductions);