[Reports][Sales and Purchase Trends][Completed]
diff --git a/accounts/page/accounts_home/accounts_home.js b/accounts/page/accounts_home/accounts_home.js
index 7f623d7..63fe969 100644
--- a/accounts/page/accounts_home/accounts_home.js
+++ b/accounts/page/accounts_home/accounts_home.js
@@ -257,6 +257,16 @@
 				route: "query-report/Item-wise Purchase Register",
 				doctype: "Purchase Invoice"
 			},
+			{
+				"label":wn._("Purchase Invoice Trends"),
+				route: "query-report/Purchase Invoice Trends",
+				doctype: "Purchase Invoice"
+			},
+			{
+				"label":wn._("Sales Invoice Trends"),
+				route: "query-report/Sales Invoice Trends",
+				doctype: "Sales Invoice"
+			},
 		]
 	}
 ]
diff --git a/accounts/report/purchase_invoice_trends/purchase_invoice_trends.py b/accounts/report/purchase_invoice_trends/purchase_invoice_trends.py
index e74ad21..a38c37c 100644
--- a/accounts/report/purchase_invoice_trends/purchase_invoice_trends.py
+++ b/accounts/report/purchase_invoice_trends/purchase_invoice_trends.py
@@ -16,7 +16,6 @@
 
 from __future__ import unicode_literals
 import webnotes
-from webnotes.utils import cint, add_days, add_months, cstr
 from controllers.trends	import get_columns,get_data
 
 def execute(filters=None):
@@ -25,13 +24,11 @@
 
 	trans = "Purchase Invoice"
 	tab = ["tabPurchase Invoice","tabPurchase Invoice Item"]
-	ysd = webnotes.conn.sql("select year_start_date from `tabFiscal Year` where name = '%s'"%filters.get("fiscal_year"))[0][0]
-	year_start_date = ysd.strftime('%Y-%m-%d')
-	start_month = cint(year_start_date.split('-')[1])
 
-	columns, query_bon, query_pwc, basedon, grbc, sup_tab = get_columns(filters, year_start_date, start_month, trans)
-	data = get_data(columns,filters, tab, query_bon, query_pwc, basedon, grbc ,sup_tab)
-
+	details = get_columns(filters, trans)
+	data = get_data(filters, tab, details)
+	
 	if data == '':
 		webnotes.msgprint("Data Not Available")
-	return columns, data 
\ No newline at end of file
+
+	return details["columns"], data 
\ No newline at end of file
diff --git a/accounts/report/sales_invoice_trends/sales_invoice_trends.py b/accounts/report/sales_invoice_trends/sales_invoice_trends.py
index 48606f0..3839900 100644
--- a/accounts/report/sales_invoice_trends/sales_invoice_trends.py
+++ b/accounts/report/sales_invoice_trends/sales_invoice_trends.py
@@ -16,7 +16,6 @@
 
 from __future__ import unicode_literals
 import webnotes
-from webnotes.utils import cint, add_days, add_months, cstr
 from controllers.trends	import get_columns,get_data
 
 def execute(filters=None):
@@ -25,13 +24,11 @@
 
 	trans = "Sales Invoice"
 	tab = ["tabSales Invoice","tabSales Invoice Item"]
-	ysd = webnotes.conn.sql("select year_start_date from `tabFiscal Year` where name = '%s'"%filters.get("fiscal_year"))[0][0]
-	year_start_date = ysd.strftime('%Y-%m-%d')
-	start_month = cint(year_start_date.split('-')[1])
 
-	columns, query_bon, query_pwc, basedon, grbc, sup_tab = get_columns(filters, year_start_date, start_month, trans)
-	data = get_data(columns,filters, tab, query_bon, query_pwc, basedon, grbc ,sup_tab)
-
+	details = get_columns(filters, trans)
+	data = get_data(filters, tab, details)
+	
 	if data == '':
 		webnotes.msgprint("Data Not Available")
-	return columns, data 
\ No newline at end of file
+
+	return details["columns"], data 
\ No newline at end of file
diff --git a/buying/page/buying_home/buying_home.js b/buying/page/buying_home/buying_home.js
index 2070fd4..dfcd71e 100644
--- a/buying/page/buying_home/buying_home.js
+++ b/buying/page/buying_home/buying_home.js
@@ -115,6 +115,11 @@
 				"label":wn._("Requested Items To Be Ordered"),
 				route: "query-report/Requested Items To Be Ordered",
 			},
+			{
+				"label":wn._("Purchase Order Trends"),
+				route: "query-report/Purchase Order Trends",
+				doctype: "Purchase Order"
+			},
 		]
 	}
 ]
diff --git a/buying/report/purchase_order_trends/purchase_order_trends.py b/buying/report/purchase_order_trends/purchase_order_trends.py
index cdf79b2..063bef4 100644
--- a/buying/report/purchase_order_trends/purchase_order_trends.py
+++ b/buying/report/purchase_order_trends/purchase_order_trends.py
@@ -16,7 +16,6 @@
 
 from __future__ import unicode_literals
 import webnotes
-from webnotes.utils import cint, add_days, add_months, cstr
 from controllers.trends	import get_columns,get_data
 
 def execute(filters=None):
@@ -25,13 +24,11 @@
 
 	trans = "Purchase Order"
 	tab = ["tabPurchase Order","tabPurchase Order Item"]
-	ysd = webnotes.conn.sql("select year_start_date from `tabFiscal Year` where name = '%s'"%filters.get("fiscal_year"))[0][0]
-	year_start_date = ysd.strftime('%Y-%m-%d')
-	start_month = cint(year_start_date.split('-')[1])
 
-	columns, query_bon, query_pwc, basedon, grbc, sup_tab = get_columns(filters, year_start_date, start_month, trans)
-	data = get_data(columns,filters, tab, query_bon, query_pwc, basedon, grbc ,sup_tab)
-
+	details = get_columns(filters, trans)
+	data = get_data(filters, tab, details)
+	
 	if data == '':
 		webnotes.msgprint("Data Not Available")
-	return columns, data 
\ No newline at end of file
+
+	return details["columns"], data 
\ No newline at end of file
diff --git a/controllers/trends.py b/controllers/trends.py
index 6c33235..dee9ec8 100644
--- a/controllers/trends.py
+++ b/controllers/trends.py
@@ -18,51 +18,45 @@
 import webnotes
 from webnotes.utils import cint, add_days, add_months, cstr
 
-def get_columns(filters, year_start_date, start_month, trans):
-	columns, pwc, bon, grbc = [], [], [], []
-	query_bon, query_pwc = '', ''
+def get_columns(filters, trans):
 
-	period = filters.get("period")
-	based_on = filters.get("based_on")
-	grby = filters.get("group_by")
-
-	if not (period and based_on):
+	if not (filters.get("period") and filters.get("based_on")):
 		webnotes.msgprint("Value missing in 'Period' or 'Based On'", raise_exception=1)
 
-	elif based_on == grby:
+	elif filters.get("based_on") == filters.get("group_by"):
 		webnotes.msgprint("Plese select different values in 'Based On' and 'Group By'", raise_exception=1)
 
 	else: 
-		bon, query_bon, basedon, sup_tab = bon_columns_qdata(based_on, bon, trans)
-		pwc, query_pwc = pw_column_qdata(filters, period, pwc, year_start_date,start_month, trans)
-		grbc = grp_column(grby)
-	
-	if grbc:	
-		columns = bon + grbc + pwc +["TOTAL(Qty):Float:120", "TOTAL(Amt):Currency:120"] 
-	else:
+		bon, query_bon, basedon, sup_tab = basedon_wise_colums_query(filters.get("based_on"), trans)
+		pwc, query_pwc = period_wise_colums_query(filters, trans)
+		grbc = group_wise_column(filters.get("group_by"))
+
 		columns = bon + pwc + ["TOTAL(Qty):Float:120", "TOTAL(Amt):Currency:120"]
+		if grbc:	
+			columns = bon + grbc + pwc +["TOTAL(Qty):Float:120", "TOTAL(Amt):Currency:120"] 
 
-	return columns, query_bon, query_pwc, basedon, grbc, sup_tab
+		details = {"query_bon": query_bon, "query_pwc": query_pwc, "columns": columns, "basedon": basedon, 
+			"grbc": grbc, "sup_tab": sup_tab}
 
-def get_data(columns, filters, tab,  query_bon, query_pwc, basedon, grbc, sup_tab):
+	return details
+
+def get_data(filters, tab, details):
 	
-	query_details =  query_bon + query_pwc + 'SUM(t2.qty), SUM(t1.grand_total) '
-	query_pwc = query_pwc + 'SUM(t2.qty), SUM(t1.grand_total)'
 	data = []
 	inc, cond= '',''
+	query_details =  details["query_bon"] + details["query_pwc"]
 	
-	if query_bon in ["t1.project_name,", "t2.project_name,"]:
-		cond = 'and '+ query_bon[:-1] +' IS Not NULL'
+	if details["query_bon"] in ["t1.project_name,", "t2.project_name,"]:
+		cond = 'and '+ details["query_bon"][:-1] +' IS Not NULL'
 
 	if filters.get("group_by"):
 		sel_col = ''
+		ind = details["columns"].index(details["grbc"][0])
 
 		if filters.get("group_by") == 'Item':
 			sel_col = 't2.item_code'
-
 		elif filters.get("group_by") == 'Customer':
 			sel_col = 't1.customer'
-
 		elif filters.get("group_by") == 'Supplier':
 			sel_col = 't1.supplier'
 
@@ -71,13 +65,14 @@
 		else :
 			inc = 1
 
-		ind = columns.index(grbc[0])
-
-		data1 = webnotes.conn.sql(""" select %s %s from `%s` t1, `%s` t2 %s
-			where t2.parent = t1.name and t1.company = '%s' and t1.fiscal_year = '%s' 
-			and t1.docstatus = 1 %s group by %s 
-		"""%(query_bon, query_pwc, tab[0], tab[1], sup_tab,filters.get("company"), filters.get("fiscal_year"), 
-		cond, basedon), as_list=1)
+		data1 = webnotes.conn.sql(""" select %s from `%s` t1, `%s` t2 %s
+						where t2.parent = t1.name and t1.company = %s 
+						and t1.fiscal_year = %s and t1.docstatus = 1 %s 
+						group by %s 
+					""" % (query_details, tab[0], tab[1], details["sup_tab"], "%s", 
+						"%s", cond, details["basedon"]), (filters.get("company"), 
+						filters["fiscal_year"]),
+					as_list=1)
 
 		for d in range(len(data1)):
 			#to add blanck column
@@ -86,44 +81,64 @@
 			data.append(dt)
 
 			#to get distinct value of col specified by group_by in filter
-			row = webnotes.conn.sql("""select DISTINCT(%s) from `%s` t1, `%s` t2
-				where t2.parent = t1.name and t1.company = '%s'	and t1.fiscal_year = '%s' 
-				and t1.docstatus = 1 and %s = '%s' 
-			"""%(sel_col, tab[0], tab[1], filters.get("company"), filters.get("fiscal_year"), 
-			basedon, data1[d][0]),as_list=1)
-			
+			row = webnotes.conn.sql("""select DISTINCT(%s) from `%s` t1, `%s` t2 %s
+							where t2.parent = t1.name and t1.company = %s	
+							and t1.fiscal_year = %s 	and t1.docstatus = 1 
+							and %s = %s 
+						"""%(sel_col, tab[0], tab[1], details["sup_tab"], "%s", 
+							"%s", details["basedon"], "%s"),
+							(filters.get("company"), filters.get("fiscal_year"), 
+							data1[d][0]),
+						as_list=1)
+
 			for i in range(len(row)):
-				des = ['' for q in range(len(columns))]
+				des = ['' for q in range(len(details["columns"]))]
 				
 				#get data for each group_by filter 
-				row1 = webnotes.conn.sql(""" select %s , %s from `%s` t1, `%s` t2 
-					where t2.parent = t1.name and t1.company = '%s' and t1.fiscal_year = '%s' 
-					and t1.docstatus = 1 and %s = '%s' and %s ='%s' 
-				"""%(sel_col, query_pwc, tab[0], tab[1], filters.get("company"), filters.get("fiscal_year"), 
-				sel_col, row[i][0], basedon, data1[d][0]),as_list=1)
+				row1 = webnotes.conn.sql(""" select %s , %s from `%s` t1, `%s` t2 %s
+								where t2.parent = t1.name and t1.company = %s 
+								and t1.fiscal_year = %s and t1.docstatus = 1 
+								and %s = %s and %s = %s 
+							"""%(sel_col, details["query_pwc"], tab[0], tab[1], details["sup_tab"], 
+								"%s", "%s", sel_col, "%s", details["basedon"], "%s"), 
+								(filters.get("company"), filters.get("fiscal_year"), row[i][0], 
+								data1[d][0]),
+							as_list=1)
 
 				des[ind] = row[i]
-				for j in range(1,len(columns)-inc):	
+				for j in range(1,len(details["columns"])-inc):	
 					des[j+inc] = row1[0][j]
 				data.append(des)
 	else:
 
 		data = webnotes.conn.sql(""" select %s from `%s` t1, `%s` t2 %s
-			where t2.parent = t1.name and t1.company = '%s' and t1.fiscal_year = '%s' 
-			and t1.docstatus = 1 %s group by %s	
-		"""%(query_details, tab[0], tab[1], sup_tab, filters.get("company"), 
-		filters.get("fiscal_year"), cond,basedon), as_list=1)
+						where t2.parent = t1.name and t1.company = %s 
+						and t1.fiscal_year = %s and t1.docstatus = 1 
+						%s group by %s	
+					"""%(query_details, tab[0], tab[1], details["sup_tab"], "%s", 
+						"%s", cond,details["basedon"]), (filters.get("company"), 
+						filters.get("fiscal_year")), 
+					as_list=1)
 
 	return data
 
-def pw_column_qdata(filters, period, pwc, year_start_date, start_month, trans):
+def period_wise_colums_query(filters, trans):
+
 	query_details = ''
+	pwc = []
+	ysd = webnotes.conn.sql("""select year_start_date from `tabFiscal Year` 
+					where name = '%s' 
+				"""%filters.get("fiscal_year"))[0][0]
+
+	year_start_date = ysd.strftime('%Y-%m-%d')
+	start_month = cint(year_start_date.split('-')[1])
+
 	if trans in ['Purchase Receipt', 'Delivery Note', 'Purchase Invoice', 'Sales Invoice']:
 		trans_date = 'posting_date'
 	else:
 		trans_date = 'transaction_date'
 
-	if period == "Monthly":
+	if filters.get("period") == "Monthly":
 		month_name = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
 
 		for month in range(start_month-1,len(month_name)):
@@ -144,23 +159,23 @@
 				SUM(CASE WHEN MONTH(t1.%(trans)s)= %(mon_num)s THEN t1.grand_total ELSE NULL END),
 			"""%{"trans": trans_date, "mon_num": cstr(month+1)}
 	
-	elif period == "Quarterly":
-		pwc = ["Q1(qty):Float:120", "Q1(amt):Currency:120", "Q2(qty):Float:120", "Q2(amt):Currency:120", 
-		"Q3(qty):Float:120", "Q3(amt):Currency:120", "Q4(qty):Float:120", "Q4(amt):Currency:120"]
+	elif filters.get("period") == "Quarterly":
+		pwc = ["Q1 (Qty):Float:120", "Q1 (Amt):Currency:120", "Q2 (Qty):Float:120", "Q2 (Amt):Currency:120", 
+		"Q3 (Qty):Float:120", "Q3 (Amt):Currency:120", "Q4 (Qty):Float:120", "Q4 (Amt):Currency:120"]
 
 		first_qsd, second_qsd, third_qsd, fourth_qsd = year_start_date, add_months(year_start_date,3), add_months(year_start_date,6), add_months(year_start_date,9)
 		first_qed, second_qed, third_qed, fourth_qed = add_days(add_months(first_qsd,3),-1), add_days(add_months(second_qsd,3),-1), add_days(add_months(third_qsd,3),-1), add_days(add_months(fourth_qsd,3),-1)
-
 		bet_dates = [[first_qsd,first_qed],[second_qsd,second_qed],[third_qsd,third_qed],[fourth_qsd,fourth_qed]] 
+
 		for d in bet_dates:
 			query_details += """
 				SUM(CASE WHEN t1.%(trans)s BETWEEN '%(sd)s' AND '%(ed)s' THEN t2.qty ELSE NULL END), 
 				SUM(CASE WHEN t1.%(trans)s BETWEEN '%(sd)s' AND '%(ed)s' THEN t1.grand_total ELSE NULL END),
 			"""%{"trans": trans_date, "sd": d[0],"ed": d[1]}
 
-	elif period == "Half-yearly":
-		pwc = ["Fisrt Half(qty):Float:120", "Fisrt Half(amt):Currency:120", "Second Half(qty):Float:120",
-		 	"Second Half(amt):Currency:120"]
+	elif filters.get("period") == "Half-yearly":
+		pwc = ["Fisrt Half (Qty):Float:120", "Fisrt Half (Amt):Currency:120", "Second Half (Qty):Float:120",
+		 	"Second Half (Amt):Currency:120"]
 
 		first_half_start = year_start_date
 		first_half_end = add_days(add_months(first_half_start,6),-1)
@@ -176,12 +191,13 @@
 		"she": second_half_end}	 
 	
 	else:
-		pwc = [filters.get("fiscal_year")+"(qty):Float:120", filters.get("fiscal_year")+"(amt):Currency:120"]
+		pwc = [filters.get("fiscal_year")+" (Qty):Float:120", filters.get("fiscal_year")+" (Amt):Currency:120"]
 		query_details = " SUM(t2.qty), SUM(t1.grand_total),"
 
+	query_details += 'SUM(t2.qty), SUM(t1.grand_total)'
 	return pwc, query_details
 
-def bon_columns_qdata(based_on, bon, trans):
+def basedon_wise_colums_query(based_on, trans):
 	sup_tab = ''
 
 	if based_on == "Item":
@@ -234,11 +250,11 @@
 			basedon = 't2.project_name'
 
 		else:
-			webnotes.msgprint("No Information Available", raise_exception=1)
+			webnotes.msgprint("Information Not Available", raise_exception=1)
 
 	return bon, query_details, basedon, sup_tab
 
-def grp_column(group_by):
+def group_wise_column(group_by):
 	if group_by:
 		return [group_by+":Link/"+group_by+":120"]
 	else:
diff --git a/public/js/purchase_trends_filters.js b/public/js/purchase_trends_filters.js
index 05f67c9..e994a47 100644
--- a/public/js/purchase_trends_filters.js
+++ b/public/js/purchase_trends_filters.js
@@ -1,4 +1,4 @@
-var get_filter = function(){
+var get_filters = function(){
 	return [
 		{
 			"fieldname":"period",
diff --git a/selling/page/selling_home/selling_home.js b/selling/page/selling_home/selling_home.js
index 15f9b86..ff8cff8 100644
--- a/selling/page/selling_home/selling_home.js
+++ b/selling/page/selling_home/selling_home.js
@@ -173,6 +173,11 @@
 			{
 				"label":wn._("Quotation Trend"),
 				route: "query-report/Quotation Trends",
+				doctype: "Quotation"
+			},
+			{
+				"label":wn._("Sales Order Trend"),
+				route: "query-report/Sales Order Trends",
 				doctype: "Sales Order"
 			},
 
diff --git a/selling/report/quotation_trends/quotation_trends.py b/selling/report/quotation_trends/quotation_trends.py
index 527e0ad..548a4a8 100644
--- a/selling/report/quotation_trends/quotation_trends.py
+++ b/selling/report/quotation_trends/quotation_trends.py
@@ -16,7 +16,6 @@
 
 from __future__ import unicode_literals
 import webnotes
-from webnotes.utils import cint, add_days, add_months, cstr
 from controllers.trends	import get_columns,get_data
 
 def execute(filters=None):
@@ -25,13 +24,11 @@
 
 	trans = "Quotation"
 	tab = ["tabQuotation","tabQuotation Item"]
-	ysd = webnotes.conn.sql("select year_start_date from `tabFiscal Year` where name = '%s'"%filters.get("fiscal_year"))[0][0]
-	year_start_date = ysd.strftime('%Y-%m-%d')
-	start_month = cint(year_start_date.split('-')[1])
 
-	columns, query_bon, query_pwc, basedon, grbc, sup_tab = get_columns(filters, year_start_date, start_month, trans)
-	data = get_data(columns,filters, tab, query_bon, query_pwc, basedon, grbc ,sup_tab)
-
+	details = get_columns(filters, trans)
+	data = get_data(filters, tab, details)
+	
 	if data == '':
 		webnotes.msgprint("Data Not Available")
-	return columns, data 
\ No newline at end of file
+
+	return details["columns"], data 
\ No newline at end of file
diff --git a/selling/report/sales_order_trends/sales_order_trends.js b/selling/report/sales_order_trends/sales_order_trends.js
index 29c1244..458fee6 100644
--- a/selling/report/sales_order_trends/sales_order_trends.js
+++ b/selling/report/sales_order_trends/sales_order_trends.js
@@ -1,5 +1,5 @@
 wn.require("app/js/sales_trends_filters.js");
 
-wn.query_reports["Sales Order"] = {
+wn.query_reports["Sales Order Trends"] = {
 	filters: get_filters()
  }
\ No newline at end of file
diff --git a/selling/report/sales_order_trends/sales_order_trends.py b/selling/report/sales_order_trends/sales_order_trends.py
index 047a8a9..e3d9d9f 100644
--- a/selling/report/sales_order_trends/sales_order_trends.py
+++ b/selling/report/sales_order_trends/sales_order_trends.py
@@ -16,7 +16,6 @@
 
 from __future__ import unicode_literals
 import webnotes
-from webnotes.utils import cint, add_days, add_months, cstr
 from controllers.trends	import get_columns,get_data
 
 def execute(filters=None):
@@ -25,13 +24,11 @@
 
 	trans = "Sales Order"
 	tab = ["tabSales Order","tabSales Order Item"]
-	ysd = webnotes.conn.sql("select year_start_date from `tabFiscal Year` where name = '%s'"%filters.get("fiscal_year"))[0][0]
-	year_start_date = ysd.strftime('%Y-%m-%d')
-	start_month = cint(year_start_date.split('-')[1])
-
-	columns, query_bon, query_pwc, basedon, grbc, sup_tab = get_columns(filters, year_start_date, start_month, trans)
-	data = get_data(columns,filters, tab, query_bon, query_pwc, basedon, grbc ,sup_tab)
-
+	
+	details = get_columns(filters, trans)
+	data = get_data(filters, tab, details)
+	
 	if data == '':
 		webnotes.msgprint("Data Not Available")
-	return columns, data 
\ No newline at end of file
+
+	return details["columns"], data 
\ No newline at end of file
diff --git a/stock/page/stock_home/stock_home.js b/stock/page/stock_home/stock_home.js
index d8c63aa..532eb66 100644
--- a/stock/page/stock_home/stock_home.js
+++ b/stock/page/stock_home/stock_home.js
@@ -223,6 +223,16 @@
 				route: "query-report/Itemwise Recommended Reorder Level",
 				doctype: "Item"
 			},
+			{
+				"label":wn._("Delivery Note Trends"),
+				route: "query-report/Delivery Note Trends",
+				doctype: "Delivery Note"
+			},
+			{
+				"label":wn._("Purchase Receipt Trends"),
+				route: "query-report/Purchase Receipt Trends",
+				doctype: "Purchase Receipt"
+			},
 		]
 	}
 ]
diff --git a/stock/report/delivery_note_trends/delivery_note_trends.py b/stock/report/delivery_note_trends/delivery_note_trends.py
index 685cede..a161c65 100644
--- a/stock/report/delivery_note_trends/delivery_note_trends.py
+++ b/stock/report/delivery_note_trends/delivery_note_trends.py
@@ -16,7 +16,6 @@
 
 from __future__ import unicode_literals
 import webnotes
-from webnotes.utils import cint, add_days, add_months, cstr
 from controllers.trends	import get_columns,get_data
 
 def execute(filters=None):
@@ -25,13 +24,11 @@
 
 	trans = "Delivery Note"
 	tab = ["tabDelivery Note","tabDelivery Note Item"]
-	ysd = webnotes.conn.sql("select year_start_date from `tabFiscal Year` where name = '%s'"%filters.get("fiscal_year"))[0][0]
-	year_start_date = ysd.strftime('%Y-%m-%d')
-	start_month = cint(year_start_date.split('-')[1])
-
-	columns, query_bon, query_pwc, basedon, grbc, sup_tab = get_columns(filters, year_start_date, start_month, trans)
-	data = get_data(columns,filters, tab, query_bon, query_pwc, basedon, grbc ,sup_tab)
-
+	
+	details = get_columns(filters, trans)
+	data = get_data(filters, tab, details)
+	
 	if data == '':
 		webnotes.msgprint("Data Not Available")
-	return columns, data 
\ No newline at end of file
+
+	return details["columns"], data 
\ No newline at end of file
diff --git a/stock/report/purchase_receipt_trends/purchase_receipt_trends.py b/stock/report/purchase_receipt_trends/purchase_receipt_trends.py
index aaa18a0..abce01e 100644
--- a/stock/report/purchase_receipt_trends/purchase_receipt_trends.py
+++ b/stock/report/purchase_receipt_trends/purchase_receipt_trends.py
@@ -16,7 +16,6 @@
 
 from __future__ import unicode_literals
 import webnotes
-from webnotes.utils import cint, add_days, add_months, cstr
 from controllers.trends	import get_columns,get_data
 
 def execute(filters=None):
@@ -25,13 +24,11 @@
 
 	trans = "Purchase Receipt"
 	tab = ["tabPurchase Receipt","tabPurchase Receipt Item"]
-	ysd = webnotes.conn.sql("select year_start_date from `tabFiscal Year` where name = '%s'"%filters.get("fiscal_year"))[0][0]
-	year_start_date = ysd.strftime('%Y-%m-%d')
-	start_month = cint(year_start_date.split('-')[1])
 
-	columns, query_bon, query_pwc, basedon, grbc, sup_tab = get_columns(filters, year_start_date, start_month, trans)
-	data = get_data(columns,filters, tab, query_bon, query_pwc, basedon, grbc ,sup_tab)
-
+	details = get_columns(filters, trans)
+	data = get_data(filters, tab, details)
+	
 	if data == '':
 		webnotes.msgprint("Data Not Available")
-	return columns, data 
\ No newline at end of file
+
+	return details["columns"], data  
\ No newline at end of file