[bug] special character % as part of tax category name will cause system failed determine the tax template per tax rule

  1. define tax category with name 13%
  2. define tax template Regular Tax China 13%
  3. define tax rule by tax category
    tax category tax template
    13% Regular Tax China 13%
  4. define supplier abc, assign tax category 13%
  5. create new po for supplier abc, system failed derive the Regular Tax China 13% as default tax template per tax rule.

it turned out that the frappe.escape method converted tax category 13% to 13%%, tax_category =‘13%%’ has been passed as where condition to retrieve records from tax rule table, of course it failed.

so in this case the tax_category should not be escaped.

Extracted from tax_rule.py

def get_tax_template(posting_date, args):
	"""Get matching tax rule"""
	args = frappe._dict(args)
	conditions = ["""(from_date is null or from_date <= '{0}')
		and (to_date is null or to_date >= '{0}')""".format(posting_date)]

	conditions.append("ifnull(tax_category, '') = {0}".format(frappe.db.escape(cstr(args.get("tax_category")))))
2 Likes

Any updates on this?