2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 19:09:01 +00:00

fix: minor fixes to validation messages

- add two for SI items
This commit is contained in:
18alantom 2022-01-10 13:38:20 +05:30
parent ab7cffe609
commit 5a457614c3
3 changed files with 24 additions and 9 deletions

View File

@ -113,9 +113,7 @@ export default {
validate(value, doc) {
if (value.isNegative()) {
throw new frappe.errors.ValidationError(
frappe._(
`Payment amount cannot be less than zero. Amount has been reset.`
)
frappe._(`Payment amount cannot be less than zero.`)
);
}
@ -128,16 +126,13 @@ export default {
`Payment amount cannot exceed ${frappe.format(
amount,
'Currency'
)}. Amount has been reset.`
)}.`
)
);
} else if (value.isZero()) {
throw new frappe.errors.ValidationError(
frappe._(
`Payment amount cannot be ${frappe.format(
value,
'Currency'
)}. Amount has been reset.`
`Payment amount cannot be ${frappe.format(value, 'Currency')}.`
)
);
}

View File

@ -35,6 +35,15 @@ export default {
fieldtype: 'Float',
required: 1,
default: 1,
validate(value, doc) {
if (value >= 0) {
return;
}
throw new frappe.errors.ValidationError(
frappe._(`Quantity (${value}) cannot be less than zero.`)
);
},
},
{
fieldname: 'rate',
@ -48,6 +57,17 @@ export default {
},
getCurrency: (row, doc) => doc.currency,
formulaDependsOn: ['item'],
validate(value, doc) {
if (value.gte(0)) {
return;
}
throw new frappe.errors.ValidationError(
frappe._(
`Rate (${frappe.format(value, 'Currency')}) cannot be less zero.`
)
);
},
},
{
fieldname: 'baseRate',

View File

@ -152,7 +152,7 @@ export function openQuickEdit({ doctype, name, hideFields, defaults = {} }) {
}
export function getErrorMessage(e, doc) {
let errorMessage = e.message || _('An error occurred');
let errorMessage = e.message || _('An error occurred.');
const { doctype, name } = doc;
const canElaborate = doctype && name;
if (e.type === frappe.errors.LinkValidationError && canElaborate) {