2
0
mirror of https://github.com/frappe/books.git synced 2024-11-13 00:46:28 +00:00

Fixed auto updation of rate and tax on changing item

This commit is contained in:
Piyush Singhania 2021-10-14 23:58:27 +05:30 committed by 18alantom
parent be97d722b7
commit f0bdc4e669

View File

@ -25,14 +25,15 @@ module.exports = {
label: 'Description', label: 'Description',
fieldtype: 'Text', fieldtype: 'Text',
formula: (row, doc) => doc.getFrom('Item', row.item, 'description'), formula: (row, doc) => doc.getFrom('Item', row.item, 'description'),
hidden: 1 hidden: 1,
formulaDependsOn: ['item']
}, },
{ {
fieldname: 'quantity', fieldname: 'quantity',
label: 'Quantity', label: 'Quantity',
fieldtype: 'Float', fieldtype: 'Float',
required: 1, required: 1,
formula: () => 1 formula: row => row.quantity || 1
}, },
{ {
fieldname: 'rate', fieldname: 'rate',
@ -43,7 +44,8 @@ module.exports = {
let baseRate = await doc.getFrom('Item', row.item, 'rate'); let baseRate = await doc.getFrom('Item', row.item, 'rate');
return baseRate / doc.exchangeRate; return baseRate / doc.exchangeRate;
}, },
getCurrency: (row, doc) => doc.currency getCurrency: (row, doc) => doc.currency,
formulaDependsOn: ['item']
}, },
{ {
fieldname: 'baseRate', fieldname: 'baseRate',
@ -67,9 +69,10 @@ module.exports = {
fieldtype: 'Link', fieldtype: 'Link',
target: 'Tax', target: 'Tax',
formula: (row, doc) => { formula: (row, doc) => {
if (row.tax) return row.tax; // if (row.tax) return row.tax;
return doc.getFrom('Item', row.item, 'tax'); return doc.getFrom('Item', row.item, 'tax');
} },
formulaDependsOn: ['item']
}, },
{ {
fieldname: 'amount', fieldname: 'amount',