From fdd919a1d3024fa264e7fbf60832da1ddb944bf3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 3 May 2013 14:24:24 +0530 Subject: [PATCH 1/4] [report] sales personwise transaction summary --- selling/page/selling_home/selling_home.js | 4 + .../__init__.py | 0 .../sales_person_wise_transaction_summary.js | 54 +++++++++++++ .../sales_person_wise_transaction_summary.py | 81 +++++++++++++++++++ .../sales_person_wise_transaction_summary.txt | 22 +++++ 5 files changed, 161 insertions(+) create mode 100644 selling/report/sales_person_wise_transaction_summary/__init__.py create mode 100644 selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.js create mode 100644 selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py create mode 100644 selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.txt diff --git a/selling/page/selling_home/selling_home.js b/selling/page/selling_home/selling_home.js index 994bb4a555..1ffa600fd5 100644 --- a/selling/page/selling_home/selling_home.js +++ b/selling/page/selling_home/selling_home.js @@ -157,6 +157,10 @@ wn.module_page["Selling"] = [ "label":wn._("Sales Orders Pending to be Delivered"), route: "query-report/Sales Orders Pending To Be Delivered" }, + { + "label":wn._("Sales Person-wise Transaction Summary"), + route: "query-report/Sales Person-wise Transaction Summary", + }, ] } ] diff --git a/selling/report/sales_person_wise_transaction_summary/__init__.py b/selling/report/sales_person_wise_transaction_summary/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.js b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.js new file mode 100644 index 0000000000..4a8e6787ff --- /dev/null +++ b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.js @@ -0,0 +1,54 @@ +wn.query_reports["Sales Person-wise Transaction Summary"] = { + "filters": [ + { + fieldname: "sales_person", + label: "Sales Person", + fieldtype: "Link", + options: "Sales Person" + }, + { + fieldname: "doc_type", + label: "Document Type", + fieldtype: "Select", + options: "Sales Order\nDelivery Note\nSales Invoice", + default: "Sales Order" + }, + { + fieldname: "from_date", + label: "From Date", + fieldtype: "Date", + default: wn.defaults.get_user_default("year_start_date"), + }, + { + fieldname:"to_date", + label: "To Date", + fieldtype: "Date", + default: get_today() + }, + { + fieldname:"company", + label: "Company", + fieldtype: "Link", + options: "Company", + default: sys_defaults.company + }, + { + fieldname:"item_group", + label: "Item Group", + fieldtype: "Link", + options: "Item Group", + }, + { + fieldname:"brand", + label: "Brand", + fieldtype: "Link", + options: "Brand", + }, + { + fieldname:"customer", + label: "Customer", + fieldtype: "Link", + options: "Customer", + }, + ] +} \ No newline at end of file diff --git a/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py new file mode 100644 index 0000000000..612cb7425d --- /dev/null +++ b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py @@ -0,0 +1,81 @@ +# 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 import msgprint, _ + +def execute(filters=None): + if not filters: filters = {} + + columns = get_columns(filters) + data = get_entries(filters) + + return columns, data + +def get_columns(filters): + if not filters.get("doc_type"): + msgprint(_("Please select the document type first"), raise_exception=1) + + return [filters["doc_type"] + ":Link/" + filters["doc_type"] + ":140", + "Customer:Link/Customer:140", "Territory:Link/Territory:100", "Posting Date:Date:100", + "Item Code:Link/Item:120", "Qty:Currency:100", "Amount:Currency:120", + "Sales Person:Link/Sales Person:140", "Contribution %:Currency:110", + "Contribution Amount:Currency:140"] + +def get_entries(filters): + date_field = filters["doc_type"] == "Sales Order" and "transaction_date" or "posting_date" + conditions, items = get_conditions(filters, date_field) + entries = webnotes.conn.sql("""select dt.name, dt.customer, dt.territory, dt.%s, + dt_item.item_code, dt_item.qty, dt_item.amount, st.sales_person, + st.allocated_percentage, dt_item.amount*st.allocated_percentage/100 + from `tab%s` dt, `tab%s Item` dt_item, `tabSales Team` st + where st.parent = dt.name and dt.name = dt_item.parent and st.parenttype = '%s' + and dt.docstatus = 1 %s order by st.sales_person, dt.name desc""" % + (date_field, filters["doc_type"], filters["doc_type"], filters["doc_type"], conditions), + tuple(items), as_list=1) + + return entries + +def get_conditions(filters, date_field): + conditions = "" + if filters.get("company"): conditions += " and dt.company = '%s'" % filters["company"] + if filters.get("customer"): conditions += " and dt.customer = '%s'" % filters["customer"] + + if filters.get("from_date"): conditions += " and dt.%s >= '%s'" % \ + (date_field, filters["from_date"]) + if filters.get("to_date"): conditions += " and dt.%s <= '%s'" % (date_field, filters["to_date"]) + + if filters.get("sales_person"): conditions += " and st.sales_person = '%s'" % \ + filters["sales_person"] + + items = get_items(filters) + if items: + conditions += " and dt_item.item_code in (%s)" % ', '.join(['%s']*len(items)) + + return conditions, items + +def get_items(filters): + if filters.get("item_group"): key = "item_group" + elif filters.get("brand"): key = "brand" + else: key = "" + + items = [] + if key: + items = webnotes.conn.sql_list("""select name from tabItem where %s = %s""" % + (key, '%s'), (filters[key])) + + return items \ No newline at end of file diff --git a/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.txt b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.txt new file mode 100644 index 0000000000..abd69f3f2f --- /dev/null +++ b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.txt @@ -0,0 +1,22 @@ +[ + { + "creation": "2013-05-03 11:31:05", + "docstatus": 0, + "modified": "2013-05-03 11:31:05", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "add_total_row": 1, + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "ref_doctype": "Sales Order", + "report_name": "Sales Person-wise Transaction Summary", + "report_type": "Script Report" + }, + { + "doctype": "Report", + "name": "Sales Person-wise Transaction Summary" + } +] \ No newline at end of file From 9c7eb486edcb49845dfc893420f360d78c5dc8f8 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 3 May 2013 14:50:12 +0530 Subject: [PATCH 2/4] [Query Report] Item-wise Sales History --- selling/page/selling_home/selling_home.js | 4 ++++ .../item_wise_sales_history/__init__.py | 0 .../item_wise_sales_history.txt | 23 +++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 selling/report/item_wise_sales_history/__init__.py create mode 100644 selling/report/item_wise_sales_history/item_wise_sales_history.txt diff --git a/selling/page/selling_home/selling_home.js b/selling/page/selling_home/selling_home.js index 1ffa600fd5..682978bd17 100644 --- a/selling/page/selling_home/selling_home.js +++ b/selling/page/selling_home/selling_home.js @@ -161,6 +161,10 @@ wn.module_page["Selling"] = [ "label":wn._("Sales Person-wise Transaction Summary"), route: "query-report/Sales Person-wise Transaction Summary", }, + { + "label":wn._("Item-wise Sales History"), + route: "query-report/Item-wise Sales History", + }, ] } ] diff --git a/selling/report/item_wise_sales_history/__init__.py b/selling/report/item_wise_sales_history/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/selling/report/item_wise_sales_history/item_wise_sales_history.txt b/selling/report/item_wise_sales_history/item_wise_sales_history.txt new file mode 100644 index 0000000000..2558b35228 --- /dev/null +++ b/selling/report/item_wise_sales_history/item_wise_sales_history.txt @@ -0,0 +1,23 @@ +[ + { + "creation": "2013-05-03 14:38:34", + "docstatus": 0, + "modified": "2013-05-03 14:49:05", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "add_total_row": 1, + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "query": "select\n so_item.item_code as \"Item Code:Link/Item:120\",\n\tso_item.item_name as \"Item Name::120\",\n\tso_item.description as \"Description::150\",\n\tso_item.qty as \"Qty:Currency:100\",\n\tso_item.stock_uom as \"UOM::80\",\n\tso_item.basic_rate as \"Rate:Currency:120\",\n\tso_item.amount as \"Amount:Currency:120\",\n\tso.name as \"Sales Order:Link/Sales Order:120\",\n\tso.transaction_date as \"Transaction Date:Date:140\",\n\tso.customer as \"Customer:Link/Customer:130\",\n\tso.territory as \"Territory:Link/Territory:130\",\n\tifnull(so_item.delivered_qty, 0) as \"Delivered Qty:Currency:120\",\n\tifnull(so_item.billed_amt, 0) as \"Billed Amount:Currency:120\"\nfrom\n\t`tabSales Order` so, `tabSales Order Item` so_item\nwhere\n\tso.name = so_item.parent\n\tand so.docstatus = 1\norder by so.name desc", + "ref_doctype": "Sales Order", + "report_name": "Item-wise Sales History", + "report_type": "Query Report" + }, + { + "doctype": "Report", + "name": "Item-wise Sales History" + } +] \ No newline at end of file From 317f0273e74d1e3c28fd720b0328bded48de6af0 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 3 May 2013 15:08:12 +0530 Subject: [PATCH 3/4] [query report] item-wise purchase history --- buying/page/buying_home/buying_home.js | 11 +++++++++ buying/report/__init__.py | 0 .../item_wise_purchase_history/__init__.py | 0 .../item_wise_purchase_history.txt | 23 +++++++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 buying/report/__init__.py create mode 100644 buying/report/item_wise_purchase_history/__init__.py create mode 100644 buying/report/item_wise_purchase_history/item_wise_purchase_history.txt diff --git a/buying/page/buying_home/buying_home.js b/buying/page/buying_home/buying_home.js index 2df5f6fb07..56328cc574 100644 --- a/buying/page/buying_home/buying_home.js +++ b/buying/page/buying_home/buying_home.js @@ -98,6 +98,17 @@ wn.module_page["Buying"] = [ }, ] }, + { + title: wn._("Reports"), + right: true, + icon: "icon-list", + items: [ + { + "label":wn._("Item-wise Purchase History"), + route: "query-report/Item-wise Purchase History", + }, + ] + } ] pscript['onload_buying-home'] = function(wrapper) { diff --git a/buying/report/__init__.py b/buying/report/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/buying/report/item_wise_purchase_history/__init__.py b/buying/report/item_wise_purchase_history/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt b/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt new file mode 100644 index 0000000000..b499707062 --- /dev/null +++ b/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt @@ -0,0 +1,23 @@ +[ + { + "creation": "2013-05-03 14:55:53", + "docstatus": 0, + "modified": "2013-05-03 15:07:13", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "add_total_row": 1, + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "query": "select\n po_item.item_code as \"Item Code:Link/Item:120\",\n\tpo_item.item_name as \"Item Name::120\",\n\tpo_item.description as \"Description::150\",\n\tpo_item.qty as \"Qty:Currency:100\",\n\tpo_item.stock_uom as \"UOM:Link/UOM:80\",\n\tpo_item.purchase_rate as \"Rate:Currency:120\",\n\tpo_item.amount as \"Amount:Currency:120\",\n\tpo.name as \"Purchase Order:Link/Purchase Order:120\",\n\tpo.transaction_date as \"Transaction Date:Date:140\",\n\tpo.supplier as \"Supplier:Link/Supplier:130\",\n\tifnull(po_item.received_qty, 0) as \"Received Qty:Currency:120\",\n\tifnull(po_item.billed_qty, 0) as \"Billed Qty:Currency:120\"\nfrom\n\t`tabPurchase Order` po, `tabPurchase Order Item` po_item\nwhere\n\tpo.name = po_item.parent and po.docstatus = 1\norder by po.name desc", + "ref_doctype": "Purchase Order", + "report_name": "Item-wise Purchase History", + "report_type": "Query Report" + }, + { + "doctype": "Report", + "name": "Item-wise Purchase History" + } +] \ No newline at end of file From c51c0ce3e99c996ed22d585eef20bc8f5cdef284 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 3 May 2013 15:40:26 +0530 Subject: [PATCH 4/4] [fixes] salary slip --- .../item_wise_purchase_history/item_wise_purchase_history.txt | 4 ++-- hr/doctype/salary_slip/salary_slip.py | 4 ++-- .../item_wise_sales_history/item_wise_sales_history.txt | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt b/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt index b499707062..3f9e702f5f 100644 --- a/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt +++ b/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-03 14:55:53", "docstatus": 0, - "modified": "2013-05-03 15:07:13", + "modified": "2013-05-03 15:13:34", "modified_by": "Administrator", "owner": "Administrator" }, @@ -11,7 +11,7 @@ "doctype": "Report", "is_standard": "Yes", "name": "__common__", - "query": "select\n po_item.item_code as \"Item Code:Link/Item:120\",\n\tpo_item.item_name as \"Item Name::120\",\n\tpo_item.description as \"Description::150\",\n\tpo_item.qty as \"Qty:Currency:100\",\n\tpo_item.stock_uom as \"UOM:Link/UOM:80\",\n\tpo_item.purchase_rate as \"Rate:Currency:120\",\n\tpo_item.amount as \"Amount:Currency:120\",\n\tpo.name as \"Purchase Order:Link/Purchase Order:120\",\n\tpo.transaction_date as \"Transaction Date:Date:140\",\n\tpo.supplier as \"Supplier:Link/Supplier:130\",\n\tifnull(po_item.received_qty, 0) as \"Received Qty:Currency:120\",\n\tifnull(po_item.billed_qty, 0) as \"Billed Qty:Currency:120\"\nfrom\n\t`tabPurchase Order` po, `tabPurchase Order Item` po_item\nwhere\n\tpo.name = po_item.parent and po.docstatus = 1\norder by po.name desc", + "query": "select\n po_item.item_code as \"Item Code:Link/Item:120\",\n\tpo_item.item_name as \"Item Name::120\",\n\tpo_item.description as \"Description::150\",\n\tpo_item.qty as \"Qty:Currency:100\",\n\tpo_item.stock_uom as \"UOM:Link/UOM:80\",\n\tpo_item.purchase_rate as \"Rate:Currency:120\",\n\tpo_item.amount as \"Amount:Currency:120\",\n\tpo.name as \"Purchase Order:Link/Purchase Order:120\",\n\tpo.transaction_date as \"Transaction Date:Date:140\",\n\tpo.supplier as \"Supplier:Link/Supplier:130\",\n\tpo_item.project_name as \"Project:Link/Project:130\",\n\tifnull(po_item.received_qty, 0) as \"Received Qty:Currency:120\",\n\tifnull(po_item.billed_qty, 0) as \"Billed Qty:Currency:120\"\nfrom\n\t`tabPurchase Order` po, `tabPurchase Order Item` po_item\nwhere\n\tpo.name = po_item.parent and po.docstatus = 1\norder by po.name desc", "ref_doctype": "Purchase Order", "report_name": "Item-wise Purchase History", "report_type": "Query Report" diff --git a/hr/doctype/salary_slip/salary_slip.py b/hr/doctype/salary_slip/salary_slip.py index 3edf410954..d1ce3ccf1d 100644 --- a/hr/doctype/salary_slip/salary_slip.py +++ b/hr/doctype/salary_slip/salary_slip.py @@ -152,7 +152,7 @@ class DocType(TransactionBase): d.e_modified_amount = round(flt(d.e_amount)*flt(self.doc.payment_days)/cint(self.doc.total_days_in_month), 2) elif not self.doc.payment_days: d.e_modified_amount = 0 - self.doc.gross_pay += d.e_modified_amount + self.doc.gross_pay += flt(d.e_modified_amount) def calculate_ded_total(self): """ @@ -165,7 +165,7 @@ class DocType(TransactionBase): elif not self.doc.payment_days: d.d_modified_amount = 0 - self.doc.total_deduction += d.d_modified_amount + self.doc.total_deduction += flt(d.d_modified_amount) def calculate_net_pay(self): """ diff --git a/selling/report/item_wise_sales_history/item_wise_sales_history.txt b/selling/report/item_wise_sales_history/item_wise_sales_history.txt index 2558b35228..cf13bdc3ea 100644 --- a/selling/report/item_wise_sales_history/item_wise_sales_history.txt +++ b/selling/report/item_wise_sales_history/item_wise_sales_history.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-03 14:38:34", "docstatus": 0, - "modified": "2013-05-03 14:49:05", + "modified": "2013-05-03 15:15:11", "modified_by": "Administrator", "owner": "Administrator" }, @@ -11,7 +11,7 @@ "doctype": "Report", "is_standard": "Yes", "name": "__common__", - "query": "select\n so_item.item_code as \"Item Code:Link/Item:120\",\n\tso_item.item_name as \"Item Name::120\",\n\tso_item.description as \"Description::150\",\n\tso_item.qty as \"Qty:Currency:100\",\n\tso_item.stock_uom as \"UOM::80\",\n\tso_item.basic_rate as \"Rate:Currency:120\",\n\tso_item.amount as \"Amount:Currency:120\",\n\tso.name as \"Sales Order:Link/Sales Order:120\",\n\tso.transaction_date as \"Transaction Date:Date:140\",\n\tso.customer as \"Customer:Link/Customer:130\",\n\tso.territory as \"Territory:Link/Territory:130\",\n\tifnull(so_item.delivered_qty, 0) as \"Delivered Qty:Currency:120\",\n\tifnull(so_item.billed_amt, 0) as \"Billed Amount:Currency:120\"\nfrom\n\t`tabSales Order` so, `tabSales Order Item` so_item\nwhere\n\tso.name = so_item.parent\n\tand so.docstatus = 1\norder by so.name desc", + "query": "select\n so_item.item_code as \"Item Code:Link/Item:120\",\n\tso_item.item_name as \"Item Name::120\",\n\tso_item.description as \"Description::150\",\n\tso_item.qty as \"Qty:Currency:100\",\n\tso_item.stock_uom as \"UOM:Link/UOM:80\",\n\tso_item.basic_rate as \"Rate:Currency:120\",\n\tso_item.amount as \"Amount:Currency:120\",\n\tso.name as \"Sales Order:Link/Sales Order:120\",\n\tso.transaction_date as \"Transaction Date:Date:140\",\n\tso.customer as \"Customer:Link/Customer:130\",\n\tso.territory as \"Territory:Link/Territory:130\",\n so.project_name as \"Project:Link/Project:130\",\n\tifnull(so_item.delivered_qty, 0) as \"Delivered Qty:Currency:120\",\n\tifnull(so_item.billed_amt, 0) as \"Billed Amount:Currency:120\"\nfrom\n\t`tabSales Order` so, `tabSales Order Item` so_item\nwhere\n\tso.name = so_item.parent\n\tand so.docstatus = 1\norder by so.name desc", "ref_doctype": "Sales Order", "report_name": "Item-wise Sales History", "report_type": "Query Report"