2
0
mirror of https://github.com/frappe/books.git synced 2024-12-23 11:29:03 +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`, label: t`Rate`,
fieldtype: 'Currency', fieldtype: 'Currency',
validate(value) { validate(value) {
if (value.lte(0)) { if (value.isNegative()) {
throw new frappe.errors.ValidationError( throw new frappe.errors.ValidationError(t`Rate can't be negative.`);
'Rate must be greater than 0'
);
} }
}, },
}, },

View File

@ -46,6 +46,18 @@ export default {
return baseRate.div(doc.exchangeRate); return baseRate.div(doc.exchangeRate);
}, },
getCurrency: (row, doc) => doc.currency, 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', fieldname: 'baseRate',