From 66f10cd14fce583b608c0d2b9e9ace9f7d680a67 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 7 Jun 2013 18:05:16 +0530 Subject: [PATCH] Quotation Trend --- selling/page/selling_home/selling_home.js | 5 + selling/report/quotation_trends/__init__.py | 0 .../quotation_trends/quotation_trends.js | 40 ++++++++ .../quotation_trends/quotation_trends.py | 96 +++++++++++++++++++ .../quotation_trends/quotation_trends.txt | 22 +++++ 5 files changed, 163 insertions(+) create mode 100644 selling/report/quotation_trends/__init__.py create mode 100644 selling/report/quotation_trends/quotation_trends.js create mode 100644 selling/report/quotation_trends/quotation_trends.py create mode 100644 selling/report/quotation_trends/quotation_trends.txt diff --git a/selling/page/selling_home/selling_home.js b/selling/page/selling_home/selling_home.js index 9c18fda681..15f9b86162 100644 --- a/selling/page/selling_home/selling_home.js +++ b/selling/page/selling_home/selling_home.js @@ -170,6 +170,11 @@ wn.module_page["Selling"] = [ route: "query-report/Customers Not Buying Since Long Time", doctype: "Sales Order" }, + { + "label":wn._("Quotation Trend"), + route: "query-report/Quotation Trends", + doctype: "Sales Order" + }, ] } diff --git a/selling/report/quotation_trends/__init__.py b/selling/report/quotation_trends/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/selling/report/quotation_trends/quotation_trends.js b/selling/report/quotation_trends/quotation_trends.js new file mode 100644 index 0000000000..e55e252c0b --- /dev/null +++ b/selling/report/quotation_trends/quotation_trends.js @@ -0,0 +1,40 @@ +wn.query_reports["Quotation Trends"] = { + "filters": [ + { + "fieldname":"period", + "label": "Period", + "fieldtype": "Select", + "options": "Monthly"+NEWLINE+"Quarterly"+NEWLINE+"Half-yearly"+NEWLINE+"Yearly", + "default": "Monthly" + }, + { + "fieldname":"based_on", + "label": "Based On", + "fieldtype": "Select", + "options": "Item"+NEWLINE+"Item Group"+NEWLINE+"Customer"+NEWLINE+"Customer Group"+NEWLINE+"Territory"+NEWLINE+"Project", + "default": "Item" + }, + { + "fieldname":"group_by", + "label": "Group By", + "fieldtype": "Select", + "options": "Item"+NEWLINE+"Customer", + "default": "Customer" + }, + { + "fieldname":"fiscal_year", + "label": "Fiscal Year", + "fieldtype": "Link", + "options":'Fiscal Year', + "default": "Fiscal Year" + }, + { + "fieldname":"company", + "label": "Company", + "fieldtype": "Link", + "options": "Company", + "default": "Company" + }, + + ] +} \ No newline at end of file diff --git a/selling/report/quotation_trends/quotation_trends.py b/selling/report/quotation_trends/quotation_trends.py new file mode 100644 index 0000000000..5b9fc04fb3 --- /dev/null +++ b/selling/report/quotation_trends/quotation_trends.py @@ -0,0 +1,96 @@ +# ERPNext - web based ERP (http://erpnext.com) +# Copyright (C) 2012 Web Notes Technologies Pvt Ltd +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from __future__ import unicode_literals +import webnotes +from webnotes.utils import getdate, cint + +def execute(filters=None): + if not filters: filters ={} + + period = filters.get("period") + based_on = filters.get("based_on") + group_by = filters.get("group_by") + + columns = get_columns(filters, period, based_on, group_by) + data = [] + + return columns, data + +def get_columns(filters, period, based_on, group_by): + columns = [] + pwc = [] + bon = [] + gby = [] + + if not (period and based_on): + webnotes.msgprint("Value missing in 'Period' or 'Based On'",raise_exception=1) + elif based_on == group_by: + webnotes.msgprint("Plese select different values in 'Based On' and 'Group By'") + else: + pwc = period_wise_column(filters, period, pwc) + bon = base_wise_column(based_on, bon) + gby = gruoup_wise_column(group_by) + + if gby: + columns = bon + gby + pwc + else: + columns = bon + pwc + return columns + + +def period_wise_column(filters, period, pwc): + + if period == "Monthly": + month_name = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'] + for month in range(0,len(month_name)): + pwc.append(month_name[month]+' (Qty):Float:120') + pwc.append(month_name[month]+' (Amt):Currency:120') + + 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 period == "Half-yearly": + pwc = ["Fisrt Half(qty):Float:120", "Fisrt Half(amt):Currency:120", "Second Half(qty):Float:120", + "Second Half(amt):Currency:120" + ] + else: + pwc = [filters.get("fiscal_year")+"(qty):Float:120", filters.get("fiscal_year")+"(amt):Currency:120"] + + return pwc + +def base_wise_column(based_on, bon): + if based_on == "Item": + bon = ["Item:Link/Item:120", "Item Name:Data:120"] + elif based_on == "Item Group": + bon = ["Item Group:Link/Item Group:120"] + elif based_on == "Customer": + bon = ["Customer:Link/Customer:120", "Territory:Link/Territory:120"] + elif based_on == "Customer Group": + bon = ["Customer Group:Link/Customer Group"] + elif based_on == "Territory": + bon = ["Territory:Link/Territory:120"] + else: + bon = ["Project:Link/Project:120"] + return bon + +def gruoup_wise_column(group_by): + if group_by: + return [group_by+":Link/"+group_by+":120"] + else: + return [] \ No newline at end of file diff --git a/selling/report/quotation_trends/quotation_trends.txt b/selling/report/quotation_trends/quotation_trends.txt new file mode 100644 index 0000000000..a135c34560 --- /dev/null +++ b/selling/report/quotation_trends/quotation_trends.txt @@ -0,0 +1,22 @@ +[ + { + "creation": "2013-06-07 16:01:16", + "docstatus": 0, + "modified": "2013-06-07 16:01:16", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "add_total_row": 1, + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "ref_doctype": "Quotation", + "report_name": "Quotation Trends", + "report_type": "Script Report" + }, + { + "doctype": "Report", + "name": "Quotation Trends" + } +] \ No newline at end of file