Skip to content

Commit

Permalink
chore: Validation for return allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
deepeshgarg007 committed Jun 16, 2023
1 parent 8b4a49c commit 9620104
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions erpnext/accounts/doctype/payment_entry/payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 9620104

Please sign in to comment.