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

fix: allow zero rate on items

This commit is contained in:
18alantom 2022-02-28 12:46:33 +05:30 committed by Alan
parent a5adf7cca3
commit 900639734a
2 changed files with 14 additions and 4 deletions

View File

@ -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.`);
}
},
},

View File

@ -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',