2
0
mirror of https://github.com/frappe/books.git synced 2025-01-23 07:08:36 +00:00

fix: prevent NaN in the invoices

This commit is contained in:
18alantom 2021-11-10 19:09:21 +05:30
parent 04d2c4278f
commit 735bf3f830
2 changed files with 6 additions and 4 deletions

View File

@ -40,8 +40,9 @@ export default {
fieldtype: 'Currency',
required: 1,
formula: async (row, doc) => {
let baseRate = await doc.getFrom('Item', row.item, 'rate');
return baseRate / doc.exchangeRate;
const baseRate = (await doc.getFrom('Item', row.item, 'rate')) || 0;
const exchangeRate = doc.exchangeRate ?? 1;
return baseRate / exchangeRate;
},
getCurrency: (row, doc) => doc.currency
},

View File

@ -41,8 +41,9 @@ export default {
fieldtype: 'Currency',
required: 1,
formula: async (row, doc) => {
let baseRate = await doc.getFrom('Item', row.item, 'rate');
return baseRate / doc.exchangeRate;
const baseRate = (await doc.getFrom('Item', row.item, 'rate')) || 0;
const exchangeRate = doc.exchangeRate ?? 1;
return baseRate / exchangeRate;
},
getCurrency: (row, doc) => doc.currency,
formulaDependsOn: ['item']