Merge branch 'master' into edge
diff --git a/buying/page/buying_home/buying_home.js b/buying/page/buying_home/buying_home.js
index 2df5f6f..56328cc 100644
--- a/buying/page/buying_home/buying_home.js
+++ b/buying/page/buying_home/buying_home.js
@@ -98,6 +98,17 @@
},
]
},
+ {
+ 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 0000000..e69de29
--- /dev/null
+++ b/buying/report/__init__.py
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 0000000..e69de29
--- /dev/null
+++ b/buying/report/item_wise_purchase_history/__init__.py
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 0000000..3f9e702
--- /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:13:34",
+ "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\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"
+ },
+ {
+ "doctype": "Report",
+ "name": "Item-wise Purchase History"
+ }
+]
\ No newline at end of file
diff --git a/hr/doctype/salary_slip/salary_slip.py b/hr/doctype/salary_slip/salary_slip.py
index 3edf410..d1ce3cc 100644
--- a/hr/doctype/salary_slip/salary_slip.py
+++ b/hr/doctype/salary_slip/salary_slip.py
@@ -152,7 +152,7 @@
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 @@
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/page/selling_home/selling_home.js b/selling/page/selling_home/selling_home.js
index 994bb4a..682978b 100644
--- a/selling/page/selling_home/selling_home.js
+++ b/selling/page/selling_home/selling_home.js
@@ -157,6 +157,14 @@
"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",
+ },
+ {
+ "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 0000000..e69de29
--- /dev/null
+++ b/selling/report/item_wise_sales_history/__init__.py
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 0000000..cf13bdc
--- /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 15:15:11",
+ "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: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"
+ },
+ {
+ "doctype": "Report",
+ "name": "Item-wise Sales History"
+ }
+]
\ No newline at end of file
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 0000000..e69de29
--- /dev/null
+++ b/selling/report/sales_person_wise_transaction_summary/__init__.py
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 0000000..4a8e678
--- /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 0000000..612cb74
--- /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 <http://www.gnu.org/licenses/>.
+
+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 0000000..abd69f3
--- /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