diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js index 17ac1f70567..52d8a2d5ceb 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.js +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js @@ -648,13 +648,13 @@ frappe.ui.form.on('Payment Entry', { 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);