mirror of
https://github.com/frappe/books.git
synced 2025-01-11 02:36:14 +00:00
Merge pull request #19 from piyushsinghania/fix/error-message-not-displayed-while-paying-excess-amount
Added validation to give error message when trying to pay excess amount for an invoice
This commit is contained in:
commit
49fc8d5586
@ -1,3 +1,4 @@
|
|||||||
|
const frappe = require('frappejs');
|
||||||
const utils = require('../../../accounting/utils');
|
const utils = require('../../../accounting/utils');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@ -102,7 +103,17 @@ module.exports = {
|
|||||||
label: 'Amount',
|
label: 'Amount',
|
||||||
fieldtype: 'Currency',
|
fieldtype: 'Currency',
|
||||||
required: 1,
|
required: 1,
|
||||||
formula: doc => doc.getSum('for', 'amount')
|
formula: doc => doc.getSum('for', 'amount'),
|
||||||
|
validate(value, doc) {
|
||||||
|
const amount = doc.getSum('for', 'amount');
|
||||||
|
const isValid = amount >= value && value > 0;
|
||||||
|
|
||||||
|
if (!isValid) {
|
||||||
|
throw new frappe.errors.ValidationError(
|
||||||
|
`Payment amount ${value} cannot be accepted. Please enter a value between 0 and ${amount}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'writeoff',
|
fieldname: 'writeoff',
|
||||||
|
Loading…
Reference in New Issue
Block a user