[fix] sales person wise transaction summary
diff --git a/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py b/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py
index 0dee7ab..4761117 100644
--- a/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py
+++ b/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py
@@ -34,7 +34,7 @@
 
 def get_entries(filters):
 	date_field = filters["doc_type"] == "Sales Order" and "transaction_date" or "posting_date"
-	conditions, items = get_conditions(filters, date_field)
+	conditions, values = get_conditions(filters, date_field)
 	entries = frappe.db.sql("""select dt.name, dt.customer, dt.territory, dt.%s as posting_date,
 		dt_item.item_code, dt_item.qty, dt_item.base_net_amount, st.sales_person,
 		st.allocated_percentage, dt_item.base_net_amount*st.allocated_percentage/100 as contribution_amt
@@ -42,31 +42,33 @@
 		where st.parent = dt.name and dt.name = dt_item.parent and st.parenttype = %s
 		and dt.docstatus = 1 %s order by st.sales_person, dt.name desc""" %
 		(date_field, filters["doc_type"], filters["doc_type"], '%s', conditions),
-		tuple([filters["doc_type"]] + items), as_dict=1)
+		tuple([filters["doc_type"]] + values), as_dict=1, debug=1)
 
 	return entries
 
 def get_conditions(filters, date_field):
-	conditions = ""
-	if filters.get("company"): conditions += " and dt.company = '%s'" % \
-		filters["company"].replace("'", "\'")
-	if filters.get("customer"): conditions += " and dt.customer = '%s'" % \
-		filters["customer"].replace("'", "\'")
-	if filters.get("territory"): conditions += " and dt.territory = '%s'" % \
-		filters["territory"].replace("'", "\'")
-
-	if filters.get("from_date"): conditions += " and dt.%s >= '%s'" % \
-		(date_field, filters["from_date"])
-	if filters.get("to_date"): conditions += " and dt.%s <= '%s'" % (date_field, filters["to_date"])
-
-	if filters.get("sales_person"): conditions += " and st.sales_person = '%s'" % \
-	 	filters["sales_person"].replace("'", "\'")
+	conditions = [""]
+	values = []
+	
+	for field in ["company", "customer", "territory", "sales_person"]:
+		if filters.get(field):
+			conditions.append("dt.{0}=%s".format(field))
+			values.append(filters[field])
+		
+	if filters.get("from_date"):
+		conditions.append("dt.{0}>=%s".format(date_field))
+		values.append(filters["from_date"])
+		
+	if filters.get("to_date"):
+		conditions.append("dt.{0}<=%s".format(date_field))
+		values.append(filters["to_date"])
 
 	items = get_items(filters)
 	if items:
-		conditions += " and dt_item.item_code in (%s)" % ', '.join(['%s']*len(items))
+		conditions.append("dt_item.item_code in (%s)" % ', '.join(['%s']*len(items)))
+		values += items
 
-	return conditions, items
+	return " and ".join(conditions), values
 
 def get_items(filters):
 	if filters.get("item_group"): key = "item_group"