diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js index d23ae8778278..f6280307e9c6 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.js +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js @@ -829,7 +829,6 @@ frappe.ui.form.on('Payment Entry', { else total_negative_outstanding += Math.abs(flt(row.outstanding_amount)); }) - var allocated_negative_outstanding = 0; if ( (frm.doc.payment_type=="Receive" && frm.doc.party_type=="Customer") || @@ -844,6 +843,7 @@ frappe.ui.form.on('Payment Entry', { var allocated_positive_outstanding = paid_amount + allocated_negative_outstanding; } else if (in_list(["Customer", "Supplier"], frm.doc.party_type)) { + total_negative_outstanding = flt(total_negative_outstanding, precision("outstanding_amount")) if(paid_amount > total_negative_outstanding) { if(total_negative_outstanding == 0) { frappe.msgprint( diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 35207eae0e50..03c939cf079c 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -913,8 +913,11 @@ def validate_payment_against_negative_invoice(self): ): return - total_negative_outstanding = sum( - abs(flt(d.outstanding_amount)) for d in self.get("references") if flt(d.outstanding_amount) < 0 + total_negative_outstanding = flt( + sum( + abs(flt(d.outstanding_amount)) for d in self.get("references") if flt(d.outstanding_amount) < 0 + ), + self.references[0].precision("outstanding_amount") if self.references else None, ) paid_amount = self.paid_amount if self.payment_type == "Receive" else self.received_amount