From 8c84fca1824d6c6ef529ea985c3be4b2e2374081 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 2 Mar 2015 16:29:56 +0530 Subject: [PATCH] [fix] #2875 --- erpnext/public/js/controllers/accounts.js | 46 +++++++++++++---------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/erpnext/public/js/controllers/accounts.js b/erpnext/public/js/controllers/accounts.js index 283ec74b53..3074fe3332 100644 --- a/erpnext/public/js/controllers/accounts.js +++ b/erpnext/public/js/controllers/accounts.js @@ -139,31 +139,37 @@ frappe.ui.form.on(cur_frm.doctype, "taxes_on_form_rendered", function(frm) { erpnext.taxes.set_conditional_mandatory_rate_or_amount(frm); }); +// setup queries for taxes +frappe.ui.form.on(cur_frm.doctype, "onload", function(frm) { + if(frm.get_field("taxes")) { + frm.set_query("account_head", "taxes", function(doc) { + if(frm.cscript.tax_table == "Sales Taxes and Charges") { + var account_type = ["Tax", "Chargeable", "Expense Account"]; + } else { + var account_type = ["Tax", "Chargeable", "Income Account"]; + } -cur_frm.set_query("account_head", "taxes", function(doc) { - if(cur_frm.cscript.tax_table == "Sales Taxes and Charges") { - var account_type = ["Tax", "Chargeable", "Expense Account"]; - } else { - var account_type = ["Tax", "Chargeable", "Income Account"]; - } + return { + query: "erpnext.controllers.queries.tax_account_query", + filters: { + "account_type": account_type, + "company": doc.company + } + } + }); - return { - query: "erpnext.controllers.queries.tax_account_query", - filters: { - "account_type": account_type, - "company": doc.company - } + frm.set_query("cost_center", "taxes", function(doc) { + return { + filters: { + 'company': doc.company, + 'group_or_ledger': "Ledger" + } + } + }); } }); -cur_frm.set_query("cost_center", "taxes", function(doc) { - return { - filters: { - 'company': doc.company, - 'group_or_ledger': "Ledger" - } - } -}); + // For customizing print cur_frm.pformat.total = function(doc) { return ''; }