Merge branch 'master' into edge

This commit is contained in:
Nabin Hait 2013-05-03 15:42:03 +05:30
commit dc992824d0
12 changed files with 224 additions and 2 deletions

View File

@ -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) {

View File

View File

@ -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"
}
]

View File

@ -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):
"""

View File

@ -157,6 +157,14 @@ 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",
},
{
"label":wn._("Item-wise Sales History"),
route: "query-report/Item-wise Sales History",
},
]
}
]

View File

@ -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"
}
]

View File

@ -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",
},
]
}

View File

@ -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

View File

@ -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"
}
]