mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
Added validation to give error message when trying to pay excess amount for an invoice
This commit is contained in:
parent
ca0c2968e0
commit
102ef29d6b
@ -1,3 +1,4 @@
|
||||
const frappe = require('frappejs');
|
||||
const utils = require('../../../accounting/utils');
|
||||
|
||||
module.exports = {
|
||||
@ -102,7 +103,15 @@ module.exports = {
|
||||
label: 'Amount',
|
||||
fieldtype: 'Currency',
|
||||
required: 1,
|
||||
formula: doc => doc.getSum('for', 'amount')
|
||||
formula: doc => doc.getSum('for', 'amount'),
|
||||
validate(value, doc) {
|
||||
let amount = doc.getSum('for', 'amount');
|
||||
let isValid = amount >= value && value > 0 ? true : false;
|
||||
|
||||
if (!isValid) {
|
||||
throw new frappe.errors.ValidationError(`Invalid amount ${value}`);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
fieldname: 'writeoff',
|
||||
|
Loading…
Reference in New Issue
Block a user