mirror of
https://github.com/frappe/books.git
synced 2024-12-23 11:29:03 +00:00
Merge pull request #22 from piyushsinghania/fix/error-message-not-displayed-while-paying-excess-amount
Added translation support and currency symbol in the error message
This commit is contained in:
commit
95e1510682
@ -106,11 +106,21 @@ module.exports = {
|
||||
formula: doc => doc.getSum('for', 'amount'),
|
||||
validate(value, doc) {
|
||||
const amount = doc.getSum('for', 'amount');
|
||||
const isValid = amount >= value && value > 0;
|
||||
|
||||
if (!isValid) {
|
||||
if (value > amount)) {
|
||||
throw new frappe.errors.ValidationError(
|
||||
`Payment amount ${value} cannot be accepted. Please enter a value between 0 and ${amount}`
|
||||
frappe._(
|
||||
`Payment amount cannot exceed ${frappe.format(
|
||||
amount,
|
||||
'Currency'
|
||||
)}. Amount has been reset to max viable amount.`
|
||||
)
|
||||
);
|
||||
} else if (value === 0) {
|
||||
throw new frappe.errors.ValidationError(
|
||||
frappe._(
|
||||
`Payment amount cannot be ${frappe.format(value, 'Currency')}. Amount has been reset to max viable amount.`
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user