mirror of
https://github.com/frappe/books.git
synced 2024-12-31 22:11:48 +00:00
fix: update SalesInvoice
This commit is contained in:
parent
c9349b0570
commit
5f4a9ceeb1
@ -53,13 +53,16 @@ export default {
|
||||
label: 'Customer Currency',
|
||||
fieldtype: 'Link',
|
||||
target: 'Currency',
|
||||
formula: (doc) => doc.getFrom('Party', doc.customer, 'currency'),
|
||||
formula: (doc) =>
|
||||
doc.getFrom('Party', doc.customer, 'currency') ||
|
||||
frappe.AccountingSettings.currency,
|
||||
formulaDependsOn: ['customer'],
|
||||
},
|
||||
{
|
||||
fieldname: 'exchangeRate',
|
||||
label: 'Exchange Rate',
|
||||
fieldtype: 'Float',
|
||||
default: 1,
|
||||
formula: (doc) => doc.getExchangeRate(),
|
||||
readOnly: true,
|
||||
},
|
||||
@ -74,7 +77,7 @@ export default {
|
||||
fieldname: 'netTotal',
|
||||
label: 'Net Total',
|
||||
fieldtype: 'Currency',
|
||||
formula: (doc) => doc.getSum('items', 'amount'),
|
||||
formula: (doc) => doc.getSum('items', 'amount', false),
|
||||
readOnly: 1,
|
||||
getCurrency: (doc) => doc.currency,
|
||||
},
|
||||
@ -82,7 +85,7 @@ export default {
|
||||
fieldname: 'baseNetTotal',
|
||||
label: 'Net Total (Company Currency)',
|
||||
fieldtype: 'Currency',
|
||||
formula: (doc) => doc.netTotal * doc.exchangeRate,
|
||||
formula: (doc) => doc.netTotal.mul(doc.exchangeRate),
|
||||
readOnly: 1,
|
||||
},
|
||||
{
|
||||
@ -105,7 +108,7 @@ export default {
|
||||
fieldname: 'baseGrandTotal',
|
||||
label: 'Grand Total (Company Currency)',
|
||||
fieldtype: 'Currency',
|
||||
formula: (doc) => doc.grandTotal * doc.exchangeRate,
|
||||
formula: (doc) => doc.grandTotal.mul(doc.exchangeRate),
|
||||
readOnly: 1,
|
||||
},
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ export default {
|
||||
label: 'Quantity',
|
||||
fieldtype: 'Float',
|
||||
required: 1,
|
||||
formula: (row) => row.quantity || 1,
|
||||
default: 1,
|
||||
},
|
||||
{
|
||||
fieldname: 'rate',
|
||||
@ -42,9 +42,9 @@ export default {
|
||||
fieldtype: 'Currency',
|
||||
required: 1,
|
||||
formula: async (row, doc) => {
|
||||
const baseRate = (await doc.getFrom('Item', row.item, 'rate')) || 0;
|
||||
const exchangeRate = doc.exchangeRate ?? 1;
|
||||
return baseRate / exchangeRate;
|
||||
const baseRate =
|
||||
(await doc.getFrom('Item', row.item, 'rate')) || frappe.pesa(0);
|
||||
return baseRate.div(doc.exchangeRate);
|
||||
},
|
||||
getCurrency: (row, doc) => doc.currency,
|
||||
formulaDependsOn: ['item'],
|
||||
@ -53,7 +53,7 @@ export default {
|
||||
fieldname: 'baseRate',
|
||||
label: 'Rate (Company Currency)',
|
||||
fieldtype: 'Currency',
|
||||
formula: (row, doc) => row.rate * doc.exchangeRate,
|
||||
formula: (row, doc) => row.rate.mul(doc.exchangeRate),
|
||||
readOnly: 1,
|
||||
},
|
||||
{
|
||||
@ -78,7 +78,7 @@ export default {
|
||||
label: 'Amount',
|
||||
fieldtype: 'Currency',
|
||||
readOnly: 1,
|
||||
formula: (row) => row.quantity * row.rate,
|
||||
formula: (row) => row.rate.mul(row.quantity),
|
||||
getCurrency: (row, doc) => doc.currency,
|
||||
},
|
||||
{
|
||||
@ -86,7 +86,7 @@ export default {
|
||||
label: 'Amount (Company Currency)',
|
||||
fieldtype: 'Currency',
|
||||
readOnly: 1,
|
||||
formula: (row, doc) => row.amount * doc.exchangeRate,
|
||||
formula: (row, doc) => row.amount.mul(doc.exchangeRate),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user