From 6178cf55c0d3a6819f4c43f519de8b5bcdaeb571 Mon Sep 17 00:00:00 2001 From: Piyush Singhania Date: Fri, 29 Oct 2021 23:12:10 +0530 Subject: [PATCH] Updated suggested changes --- models/doctype/Payment/Payment.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/models/doctype/Payment/Payment.js b/models/doctype/Payment/Payment.js index 76240afa..a92ea9bd 100644 --- a/models/doctype/Payment/Payment.js +++ b/models/doctype/Payment/Payment.js @@ -105,11 +105,13 @@ module.exports = { required: 1, formula: doc => doc.getSum('for', 'amount'), validate(value, doc) { - let amount = doc.getSum('for', 'amount'); - let isValid = amount >= value && value > 0 ? true : false; + const amount = doc.getSum('for', 'amount'); + const isValid = amount >= value && value > 0; if (!isValid) { - throw new frappe.errors.ValidationError(`Invalid amount ${value}`); + throw new frappe.errors.ValidationError( + `Payment amount ${value} cannot be accepted. Please enter a value between 0 and ${amount}` + ); } } },