Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 1 | # ERPNext - web based ERP (http://erpnext.com) |
| 2 | # Copyright (C) 2012 Web Notes Technologies Pvt Ltd |
| 3 | # |
| 4 | # This program is free software: you can redistribute it and/or modify |
| 5 | # it under the terms of the GNU General Public License as published by |
| 6 | # the Free Software Foundation, either version 3 of the License, or |
| 7 | # (at your option) any later version. |
| 8 | # |
| 9 | # This program is distributed in the hope that it will be useful, |
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | # GNU General Public License for more details. |
| 13 | # |
| 14 | # You should have received a copy of the GNU General Public License |
| 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | |
| 17 | from __future__ import unicode_literals |
| 18 | import webnotes |
Nabin Hait | b8ebbca | 2013-06-20 13:03:10 +0530 | [diff] [blame] | 19 | from webnotes.utils import add_days, add_months, cstr, getdate |
| 20 | from webnotes import _ |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 21 | |
Saurabh | 1848b71 | 2013-06-14 15:03:45 +0530 | [diff] [blame] | 22 | def get_columns(filters, trans): |
Nabin Hait | b8ebbca | 2013-06-20 13:03:10 +0530 | [diff] [blame] | 23 | validate_filters(filters) |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 24 | |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 25 | # get conditions for based_on filter cond |
Saurabh | 2b02f14 | 2013-06-21 10:46:26 +0530 | [diff] [blame] | 26 | based_on_details = based_wise_colums_query(filters.get("based_on"), trans) |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 27 | # get conditions for periodic filter cond |
| 28 | period_cols, period_select = period_wise_colums_query(filters, trans) |
| 29 | # get conditions for grouping filter cond |
| 30 | group_by_cols = group_wise_column(filters.get("group_by")) |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 31 | |
Saurabh | 2b02f14 | 2013-06-21 10:46:26 +0530 | [diff] [blame] | 32 | columns = based_on_details["based_on_cols"] + period_cols + ["Total(Qty):Float:120", "Total(Amt):Currency:120"] |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 33 | if group_by_cols: |
Saurabh | 2b02f14 | 2013-06-21 10:46:26 +0530 | [diff] [blame] | 34 | columns = based_on_details["based_on_cols"] + group_by_cols + period_cols + \ |
| 35 | ["Total(Qty):Float:120", "Total(Amt):Currency:120"] |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 36 | |
Saurabh | 2b02f14 | 2013-06-21 10:46:26 +0530 | [diff] [blame] | 37 | conditions = {"based_on_select": based_on_details["based_on_select"], "period_wise_select": period_select, |
Saurabh | 36cb3ca | 2013-06-21 16:25:28 +0530 | [diff] [blame] | 38 | "columns": columns, "group_by": based_on_details["based_on_group_by"], "grbc": group_by_cols, "trans": trans, |
Saurabh | 2b02f14 | 2013-06-21 10:46:26 +0530 | [diff] [blame] | 39 | "addl_tables": based_on_details["addl_tables"]} |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 40 | |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 41 | return conditions |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 42 | |
Nabin Hait | b8ebbca | 2013-06-20 13:03:10 +0530 | [diff] [blame] | 43 | def validate_filters(filters): |
| 44 | for f in ["Fiscal Year", "Based On", "Period", "Company"]: |
| 45 | if not filters.get(f.lower().replace(" ", "_")): |
| 46 | webnotes.msgprint(f + _(" is mandatory"), raise_exception=1) |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 47 | |
Nabin Hait | b8ebbca | 2013-06-20 13:03:10 +0530 | [diff] [blame] | 48 | if filters.get("based_on") == filters.get("group_by"): |
| 49 | webnotes.msgprint("'Based On' and 'Group By' can not be same", raise_exception=1) |
| 50 | |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 51 | def get_data(filters, conditions): |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 52 | data = [] |
| 53 | inc, cond= '','' |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 54 | query_details = conditions["based_on_select"] + conditions["period_wise_select"] |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 55 | |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 56 | if conditions["based_on_select"] in ["t1.project_name,", "t2.project_name,"]: |
| 57 | cond = 'and '+ conditions["based_on_select"][:-1] +' IS Not NULL' |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 58 | |
| 59 | if filters.get("group_by"): |
| 60 | sel_col = '' |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 61 | ind = conditions["columns"].index(conditions["grbc"][0]) |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 62 | |
| 63 | if filters.get("group_by") == 'Item': |
| 64 | sel_col = 't2.item_code' |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 65 | elif filters.get("group_by") == 'Customer': |
| 66 | sel_col = 't1.customer' |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 67 | elif filters.get("group_by") == 'Supplier': |
| 68 | sel_col = 't1.supplier' |
| 69 | |
| 70 | if filters.get('based_on') in ['Item','Customer','Supplier']: |
| 71 | inc = 2 |
| 72 | else : |
| 73 | inc = 1 |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 74 | data1 = webnotes.conn.sql(""" select %s from `tab%s` t1, `tab%s Item` t2 %s |
Saurabh | 36cb3ca | 2013-06-21 16:25:28 +0530 | [diff] [blame] | 75 | where t2.parent = t1.name and t1.company = %s and t1.fiscal_year = %s and |
| 76 | t1.docstatus = 1 %s |
Saurabh | 5b6d03e | 2013-06-19 12:34:22 +0530 | [diff] [blame] | 77 | group by %s |
Saurabh | 2b02f14 | 2013-06-21 10:46:26 +0530 | [diff] [blame] | 78 | """ % (query_details, conditions["trans"], conditions["trans"], conditions["addl_tables"], "%s", |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 79 | "%s", cond, conditions["group_by"]), (filters.get("company"), |
| 80 | filters["fiscal_year"]),as_list=1) |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 81 | |
| 82 | for d in range(len(data1)): |
| 83 | #to add blanck column |
| 84 | dt = data1[d] |
| 85 | dt.insert(ind,'') |
| 86 | data.append(dt) |
| 87 | |
| 88 | #to get distinct value of col specified by group_by in filter |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 89 | row = webnotes.conn.sql("""select DISTINCT(%s) from `tab%s` t1, `tab%s Item` t2 %s |
Saurabh | 5b6d03e | 2013-06-19 12:34:22 +0530 | [diff] [blame] | 90 | where t2.parent = t1.name and t1.company = %s and t1.fiscal_year = %s |
| 91 | and t1.docstatus = 1 and %s = %s |
Nabin Hait | 4555d3b | 2013-06-21 16:27:34 +0530 | [diff] [blame] | 92 | """ % |
| 93 | (sel_col, conditions["trans"], conditions["trans"], conditions["addl_tables"], |
| 94 | "%s", "%s", conditions["group_by"], "%s"), |
| 95 | (filters.get("company"), filters.get("fiscal_year"), data1[d][0]), as_list=1) |
Saurabh | 1848b71 | 2013-06-14 15:03:45 +0530 | [diff] [blame] | 96 | |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 97 | for i in range(len(row)): |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 98 | des = ['' for q in range(len(conditions["columns"]))] |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 99 | |
Saurabh | af5df66 | 2013-06-20 15:00:53 +0530 | [diff] [blame] | 100 | #get data for group_by filter |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 101 | row1 = webnotes.conn.sql(""" select %s , %s from `tab%s` t1, `tab%s Item` t2 %s |
Saurabh | 5b6d03e | 2013-06-19 12:34:22 +0530 | [diff] [blame] | 102 | where t2.parent = t1.name and t1.company = %s and t1.fiscal_year = %s |
| 103 | and t1.docstatus = 1 and %s = %s and %s = %s |
Nabin Hait | 4555d3b | 2013-06-21 16:27:34 +0530 | [diff] [blame] | 104 | """ % |
| 105 | (sel_col, conditions["period_wise_select"], conditions["trans"], |
| 106 | conditions["trans"], conditions["addl_tables"], "%s", "%s", sel_col, |
| 107 | "%s", conditions["group_by"], "%s"), |
| 108 | (filters.get("company"), filters.get("fiscal_year"), row[i][0], |
| 109 | data1[d][0]), as_list=1) |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 110 | |
| 111 | des[ind] = row[i] |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 112 | for j in range(1,len(conditions["columns"])-inc): |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 113 | des[j+inc] = row1[0][j] |
Nabin Hait | b8ebbca | 2013-06-20 13:03:10 +0530 | [diff] [blame] | 114 | |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 115 | data.append(des) |
| 116 | else: |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 117 | data = webnotes.conn.sql(""" select %s from `tab%s` t1, `tab%s Item` t2 %s |
Saurabh | 36cb3ca | 2013-06-21 16:25:28 +0530 | [diff] [blame] | 118 | where t2.parent = t1.name and t1.company = %s and t1.fiscal_year = %s and |
| 119 | t1.docstatus = 1 %s |
Saurabh | 5b6d03e | 2013-06-19 12:34:22 +0530 | [diff] [blame] | 120 | group by %s |
Nabin Hait | 4555d3b | 2013-06-21 16:27:34 +0530 | [diff] [blame] | 121 | """ % |
| 122 | (query_details, conditions["trans"], conditions["trans"], conditions["addl_tables"], |
| 123 | "%s", "%s", cond,conditions["group_by"]), |
| 124 | (filters.get("company"), filters.get("fiscal_year")), as_list=1) |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 125 | |
| 126 | return data |
| 127 | |
Nabin Hait | b8ebbca | 2013-06-20 13:03:10 +0530 | [diff] [blame] | 128 | def get_mon(dt): |
| 129 | return getdate(dt).strftime("%b") |
Saurabh | d4f2199 | 2013-06-19 14:44:44 +0530 | [diff] [blame] | 130 | |
Saurabh | 1848b71 | 2013-06-14 15:03:45 +0530 | [diff] [blame] | 131 | def period_wise_colums_query(filters, trans): |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 132 | query_details = '' |
Saurabh | 1848b71 | 2013-06-14 15:03:45 +0530 | [diff] [blame] | 133 | pwc = [] |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 134 | bet_dates = get_period_date_ranges(filters.get("period"), filters.get("fiscal_year")) |
Saurabh | 1848b71 | 2013-06-14 15:03:45 +0530 | [diff] [blame] | 135 | |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 136 | if trans in ['Purchase Receipt', 'Delivery Note', 'Purchase Invoice', 'Sales Invoice']: |
| 137 | trans_date = 'posting_date' |
| 138 | else: |
| 139 | trans_date = 'transaction_date' |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 140 | |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 141 | if filters.get("period") != 'Yearly': |
| 142 | for dt in bet_dates: |
| 143 | get_period_wise_columns(dt, filters.get("period"), pwc) |
| 144 | query_details = get_period_wise_query(dt, trans_date, query_details) |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 145 | else: |
Nabin Hait | 4555d3b | 2013-06-21 16:27:34 +0530 | [diff] [blame] | 146 | pwc = [filters.get("fiscal_year") + " (Qty):Float:120", |
| 147 | filters.get("fiscal_year") + " (Amt):Currency:120"] |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 148 | query_details = " SUM(t2.qty), SUM(t1.grand_total)," |
| 149 | |
Saurabh | 1848b71 | 2013-06-14 15:03:45 +0530 | [diff] [blame] | 150 | query_details += 'SUM(t2.qty), SUM(t1.grand_total)' |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 151 | return pwc, query_details |
| 152 | |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 153 | def get_period_wise_columns(bet_dates, period, pwc): |
| 154 | if period == 'Monthly': |
| 155 | pwc += [get_mon(bet_dates[0]) + " (Qty):Float:120", |
| 156 | get_mon(bet_dates[0]) + " (Amt):Currency:120"] |
| 157 | else: |
| 158 | pwc += [get_mon(bet_dates[0]) + "-" + get_mon(bet_dates[1]) + " (Qty):Float:120", |
| 159 | get_mon(bet_dates[0]) + "-" + get_mon(bet_dates[1]) + " (Amt):Currency:120"] |
| 160 | |
| 161 | def get_period_wise_query(bet_dates, trans_date, query_details): |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 162 | query_details += """SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.qty, NULL)), |
| 163 | SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t1.grand_total, NULL)), |
Nabin Hait | 4555d3b | 2013-06-21 16:27:34 +0530 | [diff] [blame] | 164 | """ % {"trans_date": trans_date, "sd": bet_dates[0],"ed": bet_dates[1]} |
Nabin Hait | b8ebbca | 2013-06-20 13:03:10 +0530 | [diff] [blame] | 165 | return query_details |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 166 | |
Saurabh | f8f68c5 | 2013-06-20 18:52:31 +0530 | [diff] [blame] | 167 | def get_period_date_ranges(period, fiscal_year): |
| 168 | from dateutil.relativedelta import relativedelta |
| 169 | |
| 170 | year_start_date = webnotes.conn.get_value("Fiscal Year", fiscal_year, "year_start_date") |
| 171 | increment = { |
| 172 | "Monthly": 1, |
| 173 | "Quarterly": 3, |
| 174 | "Half-Yearly": 6, |
| 175 | "Yearly": 12 |
| 176 | }.get(period) |
| 177 | |
| 178 | period_date_ranges = [] |
| 179 | for i in xrange(1, 13, increment): |
| 180 | period_end_date = year_start_date + relativedelta(months=increment, days=-1) |
| 181 | period_date_ranges.append([year_start_date, period_end_date]) |
| 182 | year_start_date = period_end_date + relativedelta(days=1) |
| 183 | |
| 184 | return period_date_ranges |
| 185 | |
| 186 | def get_period_month_ranges(period, fiscal_year): |
| 187 | from dateutil.relativedelta import relativedelta |
| 188 | period_month_ranges = [] |
| 189 | |
| 190 | for start_date, end_date in get_period_date_ranges(period, fiscal_year): |
| 191 | months_in_this_period = [] |
| 192 | while start_date <= end_date: |
| 193 | months_in_this_period.append(start_date.strftime("%B")) |
| 194 | start_date += relativedelta(months=1) |
| 195 | period_month_ranges.append(months_in_this_period) |
| 196 | |
| 197 | return period_month_ranges |
| 198 | |
| 199 | def based_wise_colums_query(based_on, trans): |
Saurabh | 2b02f14 | 2013-06-21 10:46:26 +0530 | [diff] [blame] | 200 | based_on_details = {} |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 201 | |
Saurabh | 2b02f14 | 2013-06-21 10:46:26 +0530 | [diff] [blame] | 202 | # based_on_cols, based_on_select, based_on_group_by, addl_tables |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 203 | if based_on == "Item": |
Saurabh | 2b02f14 | 2013-06-21 10:46:26 +0530 | [diff] [blame] | 204 | based_on_details["based_on_cols"] = ["Item:Link/Item:120", "Item Name:Data:120"] |
| 205 | based_on_details["based_on_select"] = "t2.item_code, t2.item_name," |
| 206 | based_on_details["based_on_group_by"] = 't2.item_code' |
| 207 | based_on_details["addl_tables"] = '' |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 208 | |
| 209 | elif based_on == "Item Group": |
Saurabh | 2b02f14 | 2013-06-21 10:46:26 +0530 | [diff] [blame] | 210 | based_on_details["based_on_cols"] = ["Item Group:Link/Item Group:120"] |
| 211 | based_on_details["based_on_select"] = "t2.item_group," |
| 212 | based_on_details["based_on_group_by"] = 't2.item_group' |
| 213 | based_on_details["addl_tables"] = '' |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 214 | |
| 215 | elif based_on == "Customer": |
Saurabh | 2b02f14 | 2013-06-21 10:46:26 +0530 | [diff] [blame] | 216 | based_on_details["based_on_cols"] = ["Customer:Link/Customer:120", "Territory:Link/Territory:120"] |
| 217 | based_on_details["based_on_select"] = "t1.customer_name, t1.territory, " |
| 218 | based_on_details["based_on_group_by"] = 't1.customer_name' |
| 219 | based_on_details["addl_tables"] = '' |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 220 | |
| 221 | elif based_on == "Customer Group": |
Saurabh | 2b02f14 | 2013-06-21 10:46:26 +0530 | [diff] [blame] | 222 | based_on_details["based_on_cols"] = ["Customer Group:Link/Customer Group"] |
| 223 | based_on_details["based_on_select"] = "t1.customer_group," |
| 224 | based_on_details["based_on_group_by"] = 't1.customer_group' |
| 225 | based_on_details["addl_tables"] = '' |
| 226 | |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 227 | elif based_on == 'Supplier': |
Saurabh | 2b02f14 | 2013-06-21 10:46:26 +0530 | [diff] [blame] | 228 | based_on_details["based_on_cols"] = ["Supplier:Link/Supplier:120", "Supplier Type:Link/Supplier Type:140"] |
| 229 | based_on_details["based_on_select"] = "t1.supplier, t3.supplier_type," |
| 230 | based_on_details["based_on_group_by"] = 't1.supplier' |
| 231 | based_on_details["addl_tables"] = ',`tabSupplier` t3' |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 232 | |
| 233 | elif based_on == 'Supplier Type': |
Saurabh | 2b02f14 | 2013-06-21 10:46:26 +0530 | [diff] [blame] | 234 | based_on_details["based_on_cols"] = ["Supplier Type:Link/Supplier Type:140"] |
| 235 | based_on_details["based_on_select"] = "t3.supplier_type," |
| 236 | based_on_details["based_on_group_by"] = 't3.supplier_type' |
| 237 | based_on_details["addl_tables"] =',`tabSupplier` t3' |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 238 | |
| 239 | elif based_on == "Territory": |
Saurabh | 2b02f14 | 2013-06-21 10:46:26 +0530 | [diff] [blame] | 240 | based_on_details["based_on_cols"] = ["Territory:Link/Territory:120"] |
| 241 | based_on_details["based_on_select"] = "t1.territory," |
| 242 | based_on_details["based_on_group_by"] = 't1.territory' |
| 243 | based_on_details["addl_tables"] = '' |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 244 | |
| 245 | elif based_on == "Project": |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 246 | if trans in ['Sales Invoice', 'Delivery Note', 'Sales Order']: |
Saurabh | 2b02f14 | 2013-06-21 10:46:26 +0530 | [diff] [blame] | 247 | based_on_details["based_on_cols"] = ["Project:Link/Project:120"] |
| 248 | based_on_details["based_on_select"] = "t1.project_name," |
| 249 | based_on_details["based_on_group_by"] = 't1.project_name' |
| 250 | based_on_details["addl_tables"] = '' |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 251 | elif trans in ['Purchase Order', 'Purchase Invoice', 'Purchase Receipt']: |
Saurabh | 2b02f14 | 2013-06-21 10:46:26 +0530 | [diff] [blame] | 252 | based_on_details["based_on_cols"] = ["Project:Link/Project:120"] |
| 253 | based_on_details["based_on_select"] = "t2.project_name," |
| 254 | based_on_details["based_on_group_by"] = 't2.project_name' |
| 255 | based_on_details["addl_tables"] = '' |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 256 | else: |
Nabin Hait | b8ebbca | 2013-06-20 13:03:10 +0530 | [diff] [blame] | 257 | webnotes.msgprint("Project-wise data is not available for Quotation", raise_exception=1) |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 258 | |
Saurabh | 2b02f14 | 2013-06-21 10:46:26 +0530 | [diff] [blame] | 259 | return based_on_details |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 260 | |
Saurabh | 1848b71 | 2013-06-14 15:03:45 +0530 | [diff] [blame] | 261 | def group_wise_column(group_by): |
Saurabh | 0326f54 | 2013-06-13 19:17:56 +0530 | [diff] [blame] | 262 | if group_by: |
| 263 | return [group_by+":Link/"+group_by+":120"] |
| 264 | else: |
| 265 | return [] |