2
0
mirror of https://github.com/frappe/books.git synced 2024-12-23 03:19: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) { validate(value, doc) {
if (value.isNegative()) { if (value.isNegative()) {
throw new frappe.errors.ValidationError( throw new frappe.errors.ValidationError(
frappe._( frappe._(`Payment amount cannot be less than zero.`)
`Payment amount cannot be less than zero. Amount has been reset.`
)
); );
} }
@ -128,16 +126,13 @@ export default {
`Payment amount cannot exceed ${frappe.format( `Payment amount cannot exceed ${frappe.format(
amount, amount,
'Currency' 'Currency'
)}. Amount has been reset.` )}.`
) )
); );
} else if (value.isZero()) { } else if (value.isZero()) {
throw new frappe.errors.ValidationError( throw new frappe.errors.ValidationError(
frappe._( frappe._(
`Payment amount cannot be ${frappe.format( `Payment amount cannot be ${frappe.format(value, 'Currency')}.`
value,
'Currency'
)}. Amount has been reset.`
) )
); );
} }

View File

@ -35,6 +35,15 @@ export default {
fieldtype: 'Float', fieldtype: 'Float',
required: 1, required: 1,
default: 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', fieldname: 'rate',
@ -48,6 +57,17 @@ export default {
}, },
getCurrency: (row, doc) => doc.currency, getCurrency: (row, doc) => doc.currency,
formulaDependsOn: ['item'], 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', fieldname: 'baseRate',

View File

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