From 96201044528828102f377bc51ba8482a29a3be00 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 16 Jun 2023 16:04:56 +0530 Subject: [PATCH] chore: Validation for return allocations --- erpnext/accounts/doctype/payment_entry/payment_entry.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index f1ade7e3813f..d14fff6466ef 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -156,11 +156,11 @@ def validate_allocated_amount(self): else: fail_message = _("Row #{0}: Allocated Amount cannot be greater than outstanding amount.") for d in self.get("references"): - if (flt(d.allocated_amount)) and flt(d.allocated_amount) > flt(d.outstanding_amount): + if (flt(d.allocated_amount)) > 0 and flt(d.allocated_amount) > flt(d.outstanding_amount): frappe.throw(fail_message.format(d.idx)) # Check for negative outstanding invoices as well - if flt(d.allocated_amount) and flt(d.allocated_amount) < flt(d.outstanding_amount): + if flt(d.allocated_amount) < 0 and flt(d.allocated_amount) < flt(d.outstanding_amount): frappe.throw(fail_message.format(d.idx)) def validate_allocated_amount_with_latest_date(self): @@ -202,11 +202,11 @@ def validate_allocated_amount_with_latest_date(self): fail_message = _("Row #{0}: Allocated Amount cannot be greater than outstanding amount.") - if (flt(d.allocated_amount)) and flt(d.allocated_amount) > flt(latest.outstanding_amount): + if (flt(d.allocated_amount)) > 0 and flt(d.allocated_amount) > flt(latest.outstanding_amount): frappe.throw(fail_message.format(d.idx)) # Check for negative outstanding invoices as well - if flt(d.allocated_amount) and flt(d.allocated_amount) < flt(latest.outstanding_amount): + if flt(d.allocated_amount) < 0 and flt(d.allocated_amount) < flt(latest.outstanding_amount): frappe.throw(fail_message.format(d.idx)) def delink_advance_entry_references(self):