From f75ebb5a1bc940db2d5d47e4da060a8841d26cc1 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Tue, 11 Jun 2013 10:23:10 +0530 Subject: [PATCH] Report partially completed - Territory Target Variance(Item-Group Wise) --- selling/page/selling_home/selling_home.js | 4 + .../__init__.py | 0 ...itory_target_variance_(item_group_wise).js | 25 ++++++ ...itory_target_variance_(item_group_wise).py | 89 +++++++++++++++++++ ...tory_target_variance_(item_group_wise).txt | 21 +++++ 5 files changed, 139 insertions(+) create mode 100644 selling/report/territory_target_variance_(item_group_wise)/__init__.py create mode 100644 selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).js create mode 100644 selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).py create mode 100644 selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).txt diff --git a/selling/page/selling_home/selling_home.js b/selling/page/selling_home/selling_home.js index 682978bd17..7d0162d2ab 100644 --- a/selling/page/selling_home/selling_home.js +++ b/selling/page/selling_home/selling_home.js @@ -165,6 +165,10 @@ wn.module_page["Selling"] = [ "label":wn._("Item-wise Sales History"), route: "query-report/Item-wise Sales History", }, + { + "label":wn._("Territory Target Variance (Item Group-Wise)"), + route: "query-report/Territory Target Variance (Item Group-Wise)", + }, ] } ] diff --git a/selling/report/territory_target_variance_(item_group_wise)/__init__.py b/selling/report/territory_target_variance_(item_group_wise)/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).js b/selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).js new file mode 100644 index 0000000000..58718a4e0b --- /dev/null +++ b/selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).js @@ -0,0 +1,25 @@ +wn.query_reports["Territory Target Variance (Item Group-Wise)"] = { + "filters": [ + { + fieldname: "fiscal_year", + label: "Fiscal Year", + fieldtype: "Link", + options: "Fiscal Year", + default: sys_defaults.fiscal_year + }, + { + fieldname: "period", + label: "Period", + fieldtype: "Select", + options: "Monthly\nQuarterly\nHalf-Yearly\nYearly", + default: "Monthly" + }, + { + fieldname: "target_on", + label: "Target On", + fieldtype: "Select", + options: "Quantity\nAmount", + default: "Quantity" + }, + ] +} \ No newline at end of file diff --git a/selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).py b/selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).py new file mode 100644 index 0000000000..790c6f02ad --- /dev/null +++ b/selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).py @@ -0,0 +1,89 @@ +# 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 +import calendar +from webnotes import msgprint +from webnotes.utils import cint, cstr, add_months + +def execute(filters=None): + if not filters: filters = {} + + columns = get_columns(filters) + + data = [] + + return columns, data + +def get_columns(filters): + """return columns based on filters""" + + if not filters.get("period"): + msgprint("Please select the Period", raise_exception=1) + + mo = cint(cstr(webnotes.conn.get_value("Fiscal Year", filters["fiscal_year"], "year_start_date")).split("-")[1]) + period_months = [] + if (filters["period"] == "Monthly" or "Yearly"): + for x in range(0,12): + period_months.append(mo) + if (mo!=12): + mo += 1 + else: + mo = 1 + + columns = ["Territory:Link/Territory:80"] + ["Item Group:Link/Item Group:80"] + + period = [] + + if (filters["period"] == "Monthly" or "Yearly"): + for i in (0,12): + period.append("Target (" + "i" + ")::80") + period.append("Achieved (" + "i" + ")::80") + period.append("Variance (" + "i" + ")::80") + + columns = columns + [(p) for p in period] + \ + ["Total Target::80"] + ["Total Achieved::80"] + ["Total Variance::80"] + + return columns + +def get_conditions(filters): + conditions = "" + + if filters.get("fiscal_year"): + conditions += " and posting_date <= '%s'" % filters["fiscal_year"] + else: + webnotes.msgprint("Please enter Fiscal Year", raise_exception=1) + + if filters.get("target_on"): + conditions += " and posting_date <= '%s'" % filters["target_on"] + else: + webnotes.msgprint("Please select Target On", raise_exception=1) + + return conditions + + +#get territory details +def get_territory_details(filters): + conditions = get_conditions(filters) + return webnotes.conn.sql("""select item_code, batch_no, warehouse, + posting_date, actual_qty + from `tabStock Ledger Entry` + where ifnull(is_cancelled, 'No') = 'No' %s order by item_code, warehouse""" % + conditions, as_dict=1) + +def get_month_abbr(month_number): + return 0 \ No newline at end of file diff --git a/selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).txt b/selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).txt new file mode 100644 index 0000000000..7fff64a861 --- /dev/null +++ b/selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).txt @@ -0,0 +1,21 @@ +[ + { + "creation": "2013-06-07 15:13:13", + "docstatus": 0, + "modified": "2013-06-07 15:13:13", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "ref_doctype": "Sales Order", + "report_name": "Territory Target Variance (Item Group-Wise)", + "report_type": "Script Report" + }, + { + "doctype": "Report", + "name": "Territory Target Variance (Item Group-Wise)" + } +] \ No newline at end of file