diff --git a/models/doctype/Item/Item.js b/models/doctype/Item/Item.js index aabf92fc..35634d43 100644 --- a/models/doctype/Item/Item.js +++ b/models/doctype/Item/Item.js @@ -105,10 +105,8 @@ export default { label: t`Rate`, fieldtype: 'Currency', validate(value) { - if (value.lte(0)) { - throw new frappe.errors.ValidationError( - 'Rate must be greater than 0' - ); + if (value.isNegative()) { + throw new frappe.errors.ValidationError(t`Rate can't be negative.`); } }, }, diff --git a/models/doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js b/models/doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js index caef417c..e57026e8 100644 --- a/models/doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js +++ b/models/doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js @@ -46,6 +46,18 @@ export default { return baseRate.div(doc.exchangeRate); }, getCurrency: (row, doc) => doc.currency, + validate(value) { + if (value.gte(0)) { + return; + } + + throw new frappe.errors.ValidationError( + frappe.t`Rate (${frappe.format( + value, + 'Currency' + )}) cannot be less zero.` + ); + }, }, { fieldname: 'baseRate',