2
0
mirror of https://github.com/frappe/books.git synced 2024-11-09 23:30:56 +00:00

fix(ux): disallow negative amount in Payments

This commit is contained in:
18alantom 2021-11-22 12:04:29 +05:30
parent 4a53e0c344
commit 4340113ac9

View File

@ -104,6 +104,14 @@ export default {
required: 1,
formula: (doc) => doc.getSum('for', 'amount'),
validate(value, doc) {
if (value < 0) {
throw new frappe.errors.ValidationError(
frappe._(
`Payment amount cannot be less than zero. Amount has been reset to max viable amount.`
)
);
}
if (doc.for.length === 0) return;
const amount = doc.getSum('for', 'amount');