[fix] [minor] get_query of tax account

This commit is contained in:
Nabin Hait 2013-07-16 17:24:17 +05:30
parent 17aa1337bc
commit 9a380ef40a
3 changed files with 33 additions and 17 deletions

View File

@ -129,14 +129,12 @@ cur_frm.cscript.row_id = function(doc, cdt, cdn) {
cur_frm.set_query("account_head", "purchase_tax_details", function(doc) { cur_frm.set_query("account_head", "purchase_tax_details", function(doc) {
return { return {
filters: [ query: "controllers.queries.tax_account_query",
["Account", "group_or_ledger", "=", "Ledger"], filters: {
["Account", "docstatus", "!=", 2], "account_type": ["Tax", "Chargeable", "Expense Account"],
["Account", "account_type", "in", "Tax, Chargeable, Expense Account"], "debit_or_credit": "Debit",
["Account", "is_pl_account", "=", "Yes"], "company": doc.company
["Account", "debit_or_credit", "=", "Debit"], }
["Account", "company", "=", doc.company]
]
} }
}); });

View File

@ -139,11 +139,12 @@ cur_frm.cscript.row_id = function(doc, cdt, cdn) {
cur_frm.fields_dict['other_charges'].grid.get_field("account_head").get_query = function(doc,cdt,cdn) { cur_frm.fields_dict['other_charges'].grid.get_field("account_head").get_query = function(doc,cdt,cdn) {
return{ return{
filters:[ query: "controllers.queries.tax_account_query",
['Account', 'group_or_ledger', '=', 'Ledger'], filters: {
['Account', 'account_type', 'in', 'Tax, Chargeable, Income Account'], "account_type": ["Tax", "Chargeable", "Income Account"],
['Account', 'company', '=', doc.company] "debit_or_credit": "Credit",
] "company": doc.company
}
} }
} }

View File

@ -166,15 +166,32 @@ def account_query(doctype, txt, searchfield, start, page_len, filters):
if not filters.group_or_ledger: if not filters.group_or_ledger:
filters.group_or_ledger = "Ledger" filters.group_or_ledger = "Ledger"
return webnotes.conn.sql("""select tabAccount.name, tabAccount.parent_account, return webnotes.conn.sql("""
tabAccount.debit_or_credit from tabAccount select tabAccount.name, tabAccount.parent_account, tabAccount.debit_or_credit
from tabAccount
where tabAccount.docstatus!=2 where tabAccount.docstatus!=2
and
and tabAccount.%(key)s LIKE "%(txt)s" and tabAccount.%(key)s LIKE "%(txt)s"
%(fcond)s %(mcond)s %(fcond)s %(mcond)s
limit %(start)s, %(page_len)s""" % {'key': searchfield, limit %(start)s, %(page_len)s""" % {'key': searchfield,
'txt': "%%%s%%" % txt, 'fcond': get_filters_cond(doctype, filters, conditions), 'txt': "%%%s%%" % txt, 'fcond': get_filters_cond(doctype, filters, conditions),
'mcond':get_match_cond(doctype, searchfield), 'start': start, 'page_len': page_len}) 'mcond':get_match_cond(doctype, searchfield), 'start': start, 'page_len': page_len})
def tax_account_query(doctype, txt, searchfield, start, page_len, filters):
return webnotes.conn.sql("""select name, parent_account, debit_or_credit
from tabAccount
where tabAccount.docstatus!=2
and (account_type in (%s) or
(ifnull(is_pl_account, 'No') = 'Yes' and debit_or_credit = %s) )
and group_or_ledger = 'Ledger'
and company = %s
and `%s` LIKE %s
limit %s, %s""" %
(", ".join(['%s']*len(filters.get("account_type"))),
"%s", "%s", searchfield, "%s", "%s", "%s"),
tuple(filters.get("account_type") + [filters.get("debit_or_credit"),
filters.get("company"), "%%%s%%" % txt, start, page_len]))
def item_query(doctype, txt, searchfield, start, page_len, filters): def item_query(doctype, txt, searchfield, start, page_len, filters):
conditions = [] conditions = []