refactor: fetch rate directly from the account head

This commit is contained in:
Mangesh-Khairnar 2019-06-19 17:50:33 +05:30
parent 6726dea88b
commit 0ef1df72ad
2 changed files with 3 additions and 9 deletions

View File

@ -361,16 +361,9 @@ frappe.ui.form.on("Expense Claim Advance", {
frappe.ui.form.on("Expense Taxes and Charges", { frappe.ui.form.on("Expense Taxes and Charges", {
account_head: function(frm, cdt, cdn) { account_head: function(frm, cdt, cdn) {
var child = locals[cdt][cdn]; var child = locals[cdt][cdn];
if(child.account_head && !child.description && !child.rate) { if(child.account_head && !child.description) {
// set description from account head // set description from account head
child.description = child.account_head.split(' - ').slice(0, -1).join(' - '); child.description = child.account_head.split(' - ').slice(0, -1).join(' - ');
// set the tax rate from account head
frappe.db.get_value("Account", child.account_head, "tax_rate").then((r) => {
if(r.message) {
frappe.model.set_value(cdt, cdn, 'rate', r.message.tax_rate);
}
});
refresh_field("taxes"); refresh_field("taxes");
} }
}, },

View File

@ -53,6 +53,7 @@
}, },
{ {
"columns": 2, "columns": 2,
"fetch_from": "account_head.tax_rate",
"fieldname": "rate", "fieldname": "rate",
"fieldtype": "Float", "fieldtype": "Float",
"in_list_view": 1, "in_list_view": 1,
@ -91,7 +92,7 @@
} }
], ],
"istable": 1, "istable": 1,
"modified": "2019-06-11 14:19:34.780611", "modified": "2019-06-19 17:47:40.236436",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Expense Taxes and Charges", "name": "Expense Taxes and Charges",