Merge branch 'master' of github.com:webnotes/erpnext into edge
This commit is contained in:
commit
4cea651a36
@ -20,9 +20,10 @@ from webnotes.utils import flt
|
||||
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
columns, expense_accounts, tax_accounts = get_columns()
|
||||
|
||||
|
||||
invoice_list = get_invoices(filters)
|
||||
columns, expense_accounts, tax_accounts = get_columns(invoice_list)
|
||||
|
||||
invoice_expense_map = get_invoice_expense_map(invoice_list)
|
||||
invoice_tax_map = get_invoice_tax_map(invoice_list)
|
||||
invoice_po_pr_map = get_invoice_po_pr_map(invoice_list)
|
||||
@ -55,7 +56,7 @@ def execute(filters=None):
|
||||
return columns, data
|
||||
|
||||
|
||||
def get_columns():
|
||||
def get_columns(invoice_list):
|
||||
"""return columns based on filters"""
|
||||
columns = [
|
||||
"Invoice:Link/Purchase Invoice:120", "Posting Date:Date:80", "Supplier:Link/Supplier:120",
|
||||
@ -66,10 +67,14 @@ def get_columns():
|
||||
|
||||
expense_accounts = webnotes.conn.sql_list("""select distinct expense_head
|
||||
from `tabPurchase Invoice Item` where docstatus = 1 and ifnull(expense_head, '') != ''
|
||||
order by expense_head""")
|
||||
and parent in (%s) order by expense_head""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
|
||||
|
||||
tax_accounts = webnotes.conn.sql_list("""select distinct account_head
|
||||
from `tabPurchase Taxes and Charges` where parenttype = 'Purchase Invoice'
|
||||
and docstatus = 1 and ifnull(account_head, '') != '' order by account_head""")
|
||||
and docstatus = 1 and ifnull(account_head, '') != '' and parent in (%s)
|
||||
order by account_head""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
|
||||
|
||||
columns = columns + [(account + ":Currency:120") for account in expense_accounts] + \
|
||||
["Net Total:Currency:120"] + [(account + ":Currency:120") for account in tax_accounts] + \
|
||||
|
@ -20,9 +20,10 @@ from webnotes.utils import flt
|
||||
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
columns, income_accounts, tax_accounts = get_columns()
|
||||
|
||||
invoice_list = get_invoices(filters)
|
||||
columns, income_accounts, tax_accounts = get_columns(invoice_list)
|
||||
|
||||
invoice_income_map = get_invoice_income_map(invoice_list)
|
||||
invoice_tax_map = get_invoice_tax_map(invoice_list)
|
||||
|
||||
@ -59,7 +60,7 @@ def execute(filters=None):
|
||||
return columns, data
|
||||
|
||||
|
||||
def get_columns():
|
||||
def get_columns(invoice_list):
|
||||
"""return columns based on filters"""
|
||||
columns = [
|
||||
"Invoice:Link/Sales Invoice:120", "Posting Date:Date:80", "Customer:Link/Customer:120",
|
||||
@ -69,11 +70,14 @@ def get_columns():
|
||||
]
|
||||
|
||||
income_accounts = webnotes.conn.sql_list("""select distinct income_account
|
||||
from `tabSales Invoice Item` where docstatus = 1 order by income_account""")
|
||||
from `tabSales Invoice Item` where docstatus = 1 and parent in (%s)
|
||||
order by income_account""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
|
||||
|
||||
tax_accounts = webnotes.conn.sql_list("""select distinct account_head
|
||||
from `tabSales Taxes and Charges` where parenttype = 'Sales Invoice'
|
||||
and docstatus = 1 order by account_head""")
|
||||
and docstatus = 1 and parent in (%s) order by account_head""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
|
||||
|
||||
columns = columns + [(account + ":Currency:120") for account in income_accounts] + \
|
||||
["Net Total:Currency:120"] + [(account + ":Currency:120") for account in tax_accounts] + \
|
||||
|
@ -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) {
|
||||
|
0
buying/report/__init__.py
Normal file
0
buying/report/__init__.py
Normal 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"
|
||||
}
|
||||
]
|
@ -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):
|
||||
"""
|
||||
|
@ -58,6 +58,17 @@ wn.module_page["Manufacturing"] = [
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: wn._("Reports"),
|
||||
right: true,
|
||||
icon: "icon-list",
|
||||
items: [
|
||||
{
|
||||
"label":wn._("Issued Items Against Production Order"),
|
||||
route: "query-report/Issued Items Against Production Order",
|
||||
},
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
pscript['onload_manufacturing-home'] = function(wrapper) {
|
||||
|
0
manufacturing/report/__init__.py
Normal file
0
manufacturing/report/__init__.py
Normal file
@ -0,0 +1,23 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-05-03 17:48:46",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-05-03 18:24:05",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"add_total_row": 0,
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"name": "__common__",
|
||||
"query": "select\n ste.production_order as \"Production Order:Link/Production Order:120\",\n ste.posting_date as \"Issue Date:Date:140\",\n ste_item.item_code as \"Item Code:Link/Item:120\",\n\tste_item.description as \"Description::150\",\n\tste_item.transfer_qty as \"Qty:Currency:100\",\n\tste_item.stock_uom as \"UOM:Link/UOM:80\",\n\tste_item.amount as \"Amount:Currency:120\",\n\tste_item.serial_no as \"Serial No:Link/Serial No:80\",\n\tste_item.s_warehouse as \"Source Warehouse:Link/Warehouse:120\",\n\tste_item.t_warehouse as \"Target Warehouse:Link/Warehouse:120\",\n\tpro.production_item as \"Finished Goods:Link/Item:120\", \n\tste.name as \"Stock Entry:Link/Stock Entry:120\"\nfrom\n\t`tabStock Entry` ste, `tabStock Entry Detail` ste_item, `tabProduction Order` pro\nwhere\n\tifnull(ste.production_order, '') != '' and ste.name = ste_item.parent \n\tand ste.production_order = pro.name and ste.docstatus = 1 \n\tand ste.purpose = 'Manufacture/Repack'\norder by ste.posting_date, ste.production_order, ste_item.item_code",
|
||||
"ref_doctype": "Production Order",
|
||||
"report_name": "Issued Items Against Production Order",
|
||||
"report_type": "Query Report"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"name": "Issued Items Against Production Order"
|
||||
}
|
||||
]
|
@ -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",
|
||||
},
|
||||
]
|
||||
}
|
||||
]
|
||||
|
0
selling/report/item_wise_sales_history/__init__.py
Normal file
0
selling/report/item_wise_sales_history/__init__.py
Normal 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"
|
||||
}
|
||||
]
|
@ -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",
|
||||
},
|
||||
]
|
||||
}
|
@ -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
|
@ -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"
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue
Block a user