blob: 1cb101f214a94246a8dd00df064b1ac1213ec05a [file] [log] [blame]
Anand Doshi885e0742015-03-03 14:55:30 +05301# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
Rushabh Mehtae67d1fb2013-08-05 14:59:54 +05302# License: GNU General Public License v3. See license.txt
Saurabh0326f542013-06-13 19:17:56 +05303
Chillar Anand915b3432021-09-02 16:44:59 +05304
Rushabh Mehta793ba6b2014-02-14 15:47:51 +05305import frappe
Rushabh Mehta793ba6b2014-02-14 15:47:51 +05306from frappe import _
Chillar Anand915b3432021-09-02 16:44:59 +05307from frappe.utils import getdate
8
Saurabh0326f542013-06-13 19:17:56 +05309
Saurabh1848b712013-06-14 15:03:45 +053010def get_columns(filters, trans):
Nabin Haitb8ebbca2013-06-20 13:03:10 +053011 validate_filters(filters)
Rushabh Mehta9f0d6252014-04-14 19:20:45 +053012
Saurabhf8f68c52013-06-20 18:52:31 +053013 # get conditions for based_on filter cond
Nabin Haitb7438892014-06-05 16:14:28 +053014 based_on_details = based_wise_columns_query(filters.get("based_on"), trans)
Saurabhf8f68c52013-06-20 18:52:31 +053015 # get conditions for periodic filter cond
Nabin Haitb7438892014-06-05 16:14:28 +053016 period_cols, period_select = period_wise_columns_query(filters, trans)
Saurabhf8f68c52013-06-20 18:52:31 +053017 # get conditions for grouping filter cond
18 group_by_cols = group_wise_column(filters.get("group_by"))
Saurabh0326f542013-06-13 19:17:56 +053019
81552433qqcom951da0c2014-09-11 16:15:27 +080020 columns = based_on_details["based_on_cols"] + period_cols + [_("Total(Qty)") + ":Float:120", _("Total(Amt)") + ":Currency:120"]
Rushabh Mehta9f0d6252014-04-14 19:20:45 +053021 if group_by_cols:
Saurabh2b02f142013-06-21 10:46:26 +053022 columns = based_on_details["based_on_cols"] + group_by_cols + period_cols + \
81552433qqcom951da0c2014-09-11 16:15:27 +080023 [_("Total(Qty)") + ":Float:120", _("Total(Amt)") + ":Currency:120"]
Saurabh0326f542013-06-13 19:17:56 +053024
Rushabh Mehta9f0d6252014-04-14 19:20:45 +053025 conditions = {"based_on_select": based_on_details["based_on_select"], "period_wise_select": period_select,
Saurabh36cb3ca2013-06-21 16:25:28 +053026 "columns": columns, "group_by": based_on_details["based_on_group_by"], "grbc": group_by_cols, "trans": trans,
Nabin Haita6b597a2014-08-11 11:54:21 +053027 "addl_tables": based_on_details["addl_tables"], "addl_tables_relational_cond": based_on_details.get("addl_tables_relational_cond", "")}
Saurabh0326f542013-06-13 19:17:56 +053028
Saurabhf8f68c52013-06-20 18:52:31 +053029 return conditions
Saurabh1848b712013-06-14 15:03:45 +053030
Nabin Haitb8ebbca2013-06-20 13:03:10 +053031def validate_filters(filters):
32 for f in ["Fiscal Year", "Based On", "Period", "Company"]:
33 if not filters.get(f.lower().replace(" ", "_")):
Rushabh Mehta9f0d6252014-04-14 19:20:45 +053034 frappe.throw(_("{0} is mandatory").format(f))
shreyase970ddc2016-01-28 16:38:59 +053035
Nabin Haitc5b8f7e2015-04-30 16:10:58 +053036 if not frappe.db.exists("Fiscal Year", filters.get("fiscal_year")):
Michelle Alva97872262020-06-25 22:35:33 +053037 frappe.throw(_("Fiscal Year {0} Does Not Exist").format(filters.get("fiscal_year")))
shreyase970ddc2016-01-28 16:38:59 +053038
Nabin Haitb8ebbca2013-06-20 13:03:10 +053039 if filters.get("based_on") == filters.get("group_by"):
Rushabh Mehta9f0d6252014-04-14 19:20:45 +053040 frappe.throw(_("'Based On' and 'Group By' can not be same"))
Nabin Haitb8ebbca2013-06-20 13:03:10 +053041
Saurabhf8f68c52013-06-20 18:52:31 +053042def get_data(filters, conditions):
Saurabh0326f542013-06-13 19:17:56 +053043 data = []
44 inc, cond= '',''
Saurabhf8f68c52013-06-20 18:52:31 +053045 query_details = conditions["based_on_select"] + conditions["period_wise_select"]
Rushabh Mehta9f0d6252014-04-14 19:20:45 +053046
rohitwaghchaure49ccac52016-03-20 19:55:17 +053047 posting_date = 't1.transaction_date'
48 if conditions.get('trans') in ['Sales Invoice', 'Purchase Invoice', 'Purchase Receipt', 'Delivery Note']:
49 posting_date = 't1.posting_date'
Anurag Mishrabbc1b5c2019-09-06 12:10:37 +053050 if filters.period_based_on:
51 posting_date = 't1.'+filters.period_based_on
rohitwaghchaure49ccac52016-03-20 19:55:17 +053052
Neil Trini Lasrado6e343e22016-03-09 17:02:59 +053053 if conditions["based_on_select"] in ["t1.project,", "t2.project,"]:
Saurabh4f62c4c2016-10-03 12:48:25 +053054 cond = ' and '+ conditions["based_on_select"][:-1] +' IS Not NULL'
Nabin Hait5c69fed2016-09-02 12:53:18 +053055 if conditions.get('trans') in ['Sales Order', 'Purchase Order']:
Saurabh4f62c4c2016-10-03 12:48:25 +053056 cond += " and t1.status != 'Closed'"
Saurabh0326f542013-06-13 19:17:56 +053057
rohitwaghchaure358a01a2019-09-10 19:18:30 +053058 if conditions.get('trans') == 'Quotation' and filters.get("group_by") == 'Customer':
59 cond += " and t1.quotation_to = 'Customer'"
60
rohitwaghchaure5b9d5172016-03-17 22:46:09 +053061 year_start_date, year_end_date = frappe.db.get_value("Fiscal Year",
62 filters.get('fiscal_year'), ["year_start_date", "year_end_date"])
63
Saurabh0326f542013-06-13 19:17:56 +053064 if filters.get("group_by"):
65 sel_col = ''
Saurabhf8f68c52013-06-20 18:52:31 +053066 ind = conditions["columns"].index(conditions["grbc"][0])
Saurabh0326f542013-06-13 19:17:56 +053067
68 if filters.get("group_by") == 'Item':
69 sel_col = 't2.item_code'
Saurabh0326f542013-06-13 19:17:56 +053070 elif filters.get("group_by") == 'Customer':
rohitwaghchaure358a01a2019-09-10 19:18:30 +053071 sel_col = 't1.party_name' if conditions.get('trans') == 'Quotation' else 't1.customer'
Saurabh0326f542013-06-13 19:17:56 +053072 elif filters.get("group_by") == 'Supplier':
73 sel_col = 't1.supplier'
74
75 if filters.get('based_on') in ['Item','Customer','Supplier']:
76 inc = 2
77 else :
78 inc = 1
Anand Doshie9baaa62014-02-26 12:35:33 +053079 data1 = frappe.db.sql(""" select %s from `tab%s` t1, `tab%s Item` t2 %s
rohitwaghchaure49ccac52016-03-20 19:55:17 +053080 where t2.parent = t1.name and t1.company = %s and %s between %s and %s and
Nabin Haita6b597a2014-08-11 11:54:21 +053081 t1.docstatus = 1 %s %s
Rushabh Mehta9f0d6252014-04-14 19:20:45 +053082 group by %s
83 """ % (query_details, conditions["trans"], conditions["trans"], conditions["addl_tables"], "%s",
rohitwaghchaure49ccac52016-03-20 19:55:17 +053084 posting_date, "%s", "%s", conditions.get("addl_tables_relational_cond"), cond, conditions["group_by"]), (filters.get("company"),
rohitwaghchaure5b9d5172016-03-17 22:46:09 +053085 year_start_date, year_end_date),as_list=1)
Saurabh0326f542013-06-13 19:17:56 +053086
87 for d in range(len(data1)):
88 #to add blanck column
89 dt = data1[d]
Rushabh Mehta9f0d6252014-04-14 19:20:45 +053090 dt.insert(ind,'')
Saurabh0326f542013-06-13 19:17:56 +053091 data.append(dt)
92
93 #to get distinct value of col specified by group_by in filter
Anand Doshie9baaa62014-02-26 12:35:33 +053094 row = frappe.db.sql("""select DISTINCT(%s) from `tab%s` t1, `tab%s Item` t2 %s
rohitwaghchaure49ccac52016-03-20 19:55:17 +053095 where t2.parent = t1.name and t1.company = %s and %s between %s and %s
Nabin Hait5c69fed2016-09-02 12:53:18 +053096 and t1.docstatus = 1 and %s = %s %s %s
Rushabh Mehta9f0d6252014-04-14 19:20:45 +053097 """ %
98 (sel_col, conditions["trans"], conditions["trans"], conditions["addl_tables"],
Nabin Hait5c69fed2016-09-02 12:53:18 +053099 "%s", posting_date, "%s", "%s", conditions["group_by"], "%s", conditions.get("addl_tables_relational_cond"), cond),
rohitwaghchaure5b9d5172016-03-17 22:46:09 +0530100 (filters.get("company"), year_start_date, year_end_date, data1[d][0]), as_list=1)
Saurabh1848b712013-06-14 15:03:45 +0530101
Saurabh0326f542013-06-13 19:17:56 +0530102 for i in range(len(row)):
Saurabhf8f68c52013-06-20 18:52:31 +0530103 des = ['' for q in range(len(conditions["columns"]))]
Rushabh Mehta9f0d6252014-04-14 19:20:45 +0530104
105 #get data for group_by filter
Anand Doshie9baaa62014-02-26 12:35:33 +0530106 row1 = frappe.db.sql(""" select %s , %s from `tab%s` t1, `tab%s Item` t2 %s
rohitwaghchaure49ccac52016-03-20 19:55:17 +0530107 where t2.parent = t1.name and t1.company = %s and %s between %s and %s
Nabin Hait5c69fed2016-09-02 12:53:18 +0530108 and t1.docstatus = 1 and %s = %s and %s = %s %s %s
Rushabh Mehta9f0d6252014-04-14 19:20:45 +0530109 """ %
110 (sel_col, conditions["period_wise_select"], conditions["trans"],
rohitwaghchaure49ccac52016-03-20 19:55:17 +0530111 conditions["trans"], conditions["addl_tables"], "%s", posting_date, "%s","%s", sel_col,
Nabin Hait5c69fed2016-09-02 12:53:18 +0530112 "%s", conditions["group_by"], "%s", conditions.get("addl_tables_relational_cond"), cond),
rohitwaghchaure5b9d5172016-03-17 22:46:09 +0530113 (filters.get("company"), year_start_date, year_end_date, row[i][0],
Nabin Hait4555d3b2013-06-21 16:27:34 +0530114 data1[d][0]), as_list=1)
Saurabh0326f542013-06-13 19:17:56 +0530115
shreyase970ddc2016-01-28 16:38:59 +0530116 des[ind] = row[i][0]
117
Rushabh Mehta9f0d6252014-04-14 19:20:45 +0530118 for j in range(1,len(conditions["columns"])-inc):
Saurabh0326f542013-06-13 19:17:56 +0530119 des[j+inc] = row1[0][j]
Rushabh Mehta9f0d6252014-04-14 19:20:45 +0530120
Saurabh0326f542013-06-13 19:17:56 +0530121 data.append(des)
122 else:
Anand Doshie9baaa62014-02-26 12:35:33 +0530123 data = frappe.db.sql(""" select %s from `tab%s` t1, `tab%s Item` t2 %s
rohitwaghchaure49ccac52016-03-20 19:55:17 +0530124 where t2.parent = t1.name and t1.company = %s and %s between %s and %s and
Nabin Haita6b597a2014-08-11 11:54:21 +0530125 t1.docstatus = 1 %s %s
Rushabh Mehta9f0d6252014-04-14 19:20:45 +0530126 group by %s
127 """ %
128 (query_details, conditions["trans"], conditions["trans"], conditions["addl_tables"],
rohitwaghchaure49ccac52016-03-20 19:55:17 +0530129 "%s", posting_date, "%s", "%s", cond, conditions.get("addl_tables_relational_cond", ""), conditions["group_by"]),
rohitwaghchaure5b9d5172016-03-17 22:46:09 +0530130 (filters.get("company"), year_start_date, year_end_date), as_list=1)
Saurabh0326f542013-06-13 19:17:56 +0530131
132 return data
133
Nabin Haitb8ebbca2013-06-20 13:03:10 +0530134def get_mon(dt):
135 return getdate(dt).strftime("%b")
Saurabhd4f21992013-06-19 14:44:44 +0530136
Nabin Haitb7438892014-06-05 16:14:28 +0530137def period_wise_columns_query(filters, trans):
Saurabh0326f542013-06-13 19:17:56 +0530138 query_details = ''
Saurabh1848b712013-06-14 15:03:45 +0530139 pwc = []
Saurabhf8f68c52013-06-20 18:52:31 +0530140 bet_dates = get_period_date_ranges(filters.get("period"), filters.get("fiscal_year"))
Saurabh1848b712013-06-14 15:03:45 +0530141
Saurabh0326f542013-06-13 19:17:56 +0530142 if trans in ['Purchase Receipt', 'Delivery Note', 'Purchase Invoice', 'Sales Invoice']:
143 trans_date = 'posting_date'
Anurag Mishrafe5890b2019-10-07 14:27:07 +0530144 if filters.period_based_on:
145 trans_date = filters.period_based_on
Saurabh0326f542013-06-13 19:17:56 +0530146 else:
147 trans_date = 'transaction_date'
Rushabh Mehta9f0d6252014-04-14 19:20:45 +0530148
Saurabhf8f68c52013-06-20 18:52:31 +0530149 if filters.get("period") != 'Yearly':
150 for dt in bet_dates:
151 get_period_wise_columns(dt, filters.get("period"), pwc)
Rohit Waghchaure87ad6d02017-04-10 16:42:11 +0530152 query_details = get_period_wise_query(dt, trans_date, query_details)
Saurabh0326f542013-06-13 19:17:56 +0530153 else:
81552433qqcom951da0c2014-09-11 16:15:27 +0800154 pwc = [_(filters.get("fiscal_year")) + " ("+_("Qty") + "):Float:120",
155 _(filters.get("fiscal_year")) + " ("+ _("Amt") + "):Currency:120"]
Rohit Waghchaure87ad6d02017-04-10 16:42:11 +0530156 query_details = " SUM(t2.stock_qty), SUM(t2.base_net_amount),"
Saurabh0326f542013-06-13 19:17:56 +0530157
Rohit Waghchaure87ad6d02017-04-10 16:42:11 +0530158 query_details += 'SUM(t2.stock_qty), SUM(t2.base_net_amount)'
Saurabh0326f542013-06-13 19:17:56 +0530159 return pwc, query_details
160
Saurabhf8f68c52013-06-20 18:52:31 +0530161def get_period_wise_columns(bet_dates, period, pwc):
162 if period == 'Monthly':
81552433qqcom951da0c2014-09-11 16:15:27 +0800163 pwc += [_(get_mon(bet_dates[0])) + " (" + _("Qty") + "):Float:120",
164 _(get_mon(bet_dates[0])) + " (" + _("Amt") + "):Currency:120"]
Saurabhf8f68c52013-06-20 18:52:31 +0530165 else:
81552433qqcom951da0c2014-09-11 16:15:27 +0800166 pwc += [_(get_mon(bet_dates[0])) + "-" + _(get_mon(bet_dates[1])) + " (" + _("Qty") + "):Float:120",
167 _(get_mon(bet_dates[0])) + "-" + _(get_mon(bet_dates[1])) + " (" + _("Amt") + "):Currency:120"]
Saurabhf8f68c52013-06-20 18:52:31 +0530168
Rohit Waghchaure87ad6d02017-04-10 16:42:11 +0530169def get_period_wise_query(bet_dates, trans_date, query_details):
170 query_details += """SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.stock_qty, NULL)),
Nabin Hait82e3e252015-02-23 16:58:30 +0530171 SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.base_net_amount, NULL)),
Rohit Waghchaure87ad6d02017-04-10 16:42:11 +0530172 """ % {"trans_date": trans_date, "sd": bet_dates[0],"ed": bet_dates[1]}
Nabin Haitb8ebbca2013-06-20 13:03:10 +0530173 return query_details
Saurabh0326f542013-06-13 19:17:56 +0530174
Rushabh Mehta793ba6b2014-02-14 15:47:51 +0530175@frappe.whitelist(allow_guest=True)
Akhilesh Darjeeec0da0b2013-11-25 19:51:18 +0530176def get_period_date_ranges(period, fiscal_year=None, year_start_date=None):
177 from dateutil.relativedelta import relativedelta
Saurabhf8f68c52013-06-20 18:52:31 +0530178
Akhilesh Darjeeec0da0b2013-11-25 19:51:18 +0530179 if not year_start_date:
Rushabh Mehta9f0d6252014-04-14 19:20:45 +0530180 year_start_date, year_end_date = frappe.db.get_value("Fiscal Year",
Akhilesh Darjeeec0da0b2013-11-25 19:51:18 +0530181 fiscal_year, ["year_start_date", "year_end_date"])
Saurabhf8f68c52013-06-20 18:52:31 +0530182
Akhilesh Darjeeec0da0b2013-11-25 19:51:18 +0530183 increment = {
184 "Monthly": 1,
185 "Quarterly": 3,
186 "Half-Yearly": 6,
187 "Yearly": 12
188 }.get(period)
Saurabhf8f68c52013-06-20 18:52:31 +0530189
Akhilesh Darjeeec0da0b2013-11-25 19:51:18 +0530190 period_date_ranges = []
Achilles Rasquinha96698c92018-02-28 16:12:51 +0530191 for i in range(1, 13, increment):
Akhilesh Darjeeec0da0b2013-11-25 19:51:18 +0530192 period_end_date = getdate(year_start_date) + relativedelta(months=increment, days=-1)
193 if period_end_date > getdate(year_end_date):
194 period_end_date = year_end_date
195 period_date_ranges.append([year_start_date, period_end_date])
196 year_start_date = period_end_date + relativedelta(days=1)
197 if period_end_date == year_end_date:
198 break
199
200 return period_date_ranges
Saurabhf8f68c52013-06-20 18:52:31 +0530201
202def get_period_month_ranges(period, fiscal_year):
203 from dateutil.relativedelta import relativedelta
204 period_month_ranges = []
205
206 for start_date, end_date in get_period_date_ranges(period, fiscal_year):
207 months_in_this_period = []
208 while start_date <= end_date:
209 months_in_this_period.append(start_date.strftime("%B"))
210 start_date += relativedelta(months=1)
211 period_month_ranges.append(months_in_this_period)
212
213 return period_month_ranges
214
Nabin Haitb7438892014-06-05 16:14:28 +0530215def based_wise_columns_query(based_on, trans):
Saurabh2b02f142013-06-21 10:46:26 +0530216 based_on_details = {}
Saurabh0326f542013-06-13 19:17:56 +0530217
Saurabh2b02f142013-06-21 10:46:26 +0530218 # based_on_cols, based_on_select, based_on_group_by, addl_tables
Saurabh0326f542013-06-13 19:17:56 +0530219 if based_on == "Item":
Saurabh2b02f142013-06-21 10:46:26 +0530220 based_on_details["based_on_cols"] = ["Item:Link/Item:120", "Item Name:Data:120"]
Rushabh Mehta9f0d6252014-04-14 19:20:45 +0530221 based_on_details["based_on_select"] = "t2.item_code, t2.item_name,"
Saurabh2b02f142013-06-21 10:46:26 +0530222 based_on_details["based_on_group_by"] = 't2.item_code'
223 based_on_details["addl_tables"] = ''
Saurabh0326f542013-06-13 19:17:56 +0530224
225 elif based_on == "Item Group":
Saurabh2b02f142013-06-21 10:46:26 +0530226 based_on_details["based_on_cols"] = ["Item Group:Link/Item Group:120"]
Rushabh Mehta9f0d6252014-04-14 19:20:45 +0530227 based_on_details["based_on_select"] = "t2.item_group,"
Saurabh2b02f142013-06-21 10:46:26 +0530228 based_on_details["based_on_group_by"] = 't2.item_group'
229 based_on_details["addl_tables"] = ''
Saurabh0326f542013-06-13 19:17:56 +0530230
231 elif based_on == "Customer":
Saurabh2b02f142013-06-21 10:46:26 +0530232 based_on_details["based_on_cols"] = ["Customer:Link/Customer:120", "Territory:Link/Territory:120"]
233 based_on_details["based_on_select"] = "t1.customer_name, t1.territory, "
rohitwaghchaure358a01a2019-09-10 19:18:30 +0530234 based_on_details["based_on_group_by"] = 't1.party_name' if trans == 'Quotation' else 't1.customer'
Saurabh2b02f142013-06-21 10:46:26 +0530235 based_on_details["addl_tables"] = ''
Saurabh0326f542013-06-13 19:17:56 +0530236
237 elif based_on == "Customer Group":
Saurabh2b02f142013-06-21 10:46:26 +0530238 based_on_details["based_on_cols"] = ["Customer Group:Link/Customer Group"]
239 based_on_details["based_on_select"] = "t1.customer_group,"
240 based_on_details["based_on_group_by"] = 't1.customer_group'
241 based_on_details["addl_tables"] = ''
242
Saurabh0326f542013-06-13 19:17:56 +0530243 elif based_on == 'Supplier':
Zlash652e080982018-04-19 18:37:53 +0530244 based_on_details["based_on_cols"] = ["Supplier:Link/Supplier:120", "Supplier Group:Link/Supplier Group:140"]
245 based_on_details["based_on_select"] = "t1.supplier, t3.supplier_group,"
Saurabh2b02f142013-06-21 10:46:26 +0530246 based_on_details["based_on_group_by"] = 't1.supplier'
247 based_on_details["addl_tables"] = ',`tabSupplier` t3'
Nabin Haita6b597a2014-08-11 11:54:21 +0530248 based_on_details["addl_tables_relational_cond"] = " and t1.supplier = t3.name"
Rushabh Mehta9f0d6252014-04-14 19:20:45 +0530249
Zlash652e080982018-04-19 18:37:53 +0530250 elif based_on == 'Supplier Group':
251 based_on_details["based_on_cols"] = ["Supplier Group:Link/Supplier Group:140"]
252 based_on_details["based_on_select"] = "t3.supplier_group,"
253 based_on_details["based_on_group_by"] = 't3.supplier_group'
Nabin Haita6b597a2014-08-11 11:54:21 +0530254 based_on_details["addl_tables"] = ',`tabSupplier` t3'
255 based_on_details["addl_tables_relational_cond"] = " and t1.supplier = t3.name"
Saurabh0326f542013-06-13 19:17:56 +0530256
257 elif based_on == "Territory":
Saurabh2b02f142013-06-21 10:46:26 +0530258 based_on_details["based_on_cols"] = ["Territory:Link/Territory:120"]
259 based_on_details["based_on_select"] = "t1.territory,"
260 based_on_details["based_on_group_by"] = 't1.territory'
261 based_on_details["addl_tables"] = ''
Saurabh0326f542013-06-13 19:17:56 +0530262
263 elif based_on == "Project":
Saurabh0326f542013-06-13 19:17:56 +0530264 if trans in ['Sales Invoice', 'Delivery Note', 'Sales Order']:
Saurabh2b02f142013-06-21 10:46:26 +0530265 based_on_details["based_on_cols"] = ["Project:Link/Project:120"]
Neil Trini Lasrado6e343e22016-03-09 17:02:59 +0530266 based_on_details["based_on_select"] = "t1.project,"
267 based_on_details["based_on_group_by"] = 't1.project'
Saurabh2b02f142013-06-21 10:46:26 +0530268 based_on_details["addl_tables"] = ''
Saurabh0326f542013-06-13 19:17:56 +0530269 elif trans in ['Purchase Order', 'Purchase Invoice', 'Purchase Receipt']:
Saurabh2b02f142013-06-21 10:46:26 +0530270 based_on_details["based_on_cols"] = ["Project:Link/Project:120"]
Neil Trini Lasrado6e343e22016-03-09 17:02:59 +0530271 based_on_details["based_on_select"] = "t2.project,"
272 based_on_details["based_on_group_by"] = 't2.project'
Saurabh2b02f142013-06-21 10:46:26 +0530273 based_on_details["addl_tables"] = ''
Saurabh0326f542013-06-13 19:17:56 +0530274 else:
Rushabh Mehta9f0d6252014-04-14 19:20:45 +0530275 frappe.throw(_("Project-wise data is not available for Quotation"))
Saurabh0326f542013-06-13 19:17:56 +0530276
Saurabh2b02f142013-06-21 10:46:26 +0530277 return based_on_details
Saurabh0326f542013-06-13 19:17:56 +0530278
Saurabh1848b712013-06-14 15:03:45 +0530279def group_wise_column(group_by):
Saurabh0326f542013-06-13 19:17:56 +0530280 if group_by:
281 return [group_by+":Link/"+group_by+":120"]
282 else:
Rushabh Mehta9f0d6252014-04-14 19:20:45 +0530283 return []