[report] item-wise consumption renamed to supplier-wise sales analytics
This commit is contained in:
parent
4fb848d3c4
commit
b1269b4a07
@ -156,8 +156,8 @@ wn.module_page["Buying"] = [
|
||||
doctype: "Supplier"
|
||||
},
|
||||
{
|
||||
"label":wn._("Item-Wise Consumption"),
|
||||
route: "query-report/Item-wise Consumption",
|
||||
"label":wn._("Supplier-Wise Sales Analytics"),
|
||||
route: "query-report/Supplier-Wise Sales Analytics",
|
||||
doctype: "Stock Ledger Entry"
|
||||
}
|
||||
]
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.query_reports["Item-wise Consumption"] = {
|
||||
wn.query_reports["Supplier-Wise Sales Analytics"] = {
|
||||
"filters": [
|
||||
{
|
||||
"fieldname":"supplier",
|
@ -13,15 +13,22 @@ def execute(filters=None):
|
||||
data = []
|
||||
|
||||
for item_code, suppliers in supplier_details.items():
|
||||
consumed_qty = consumed_amount = 0.0
|
||||
consumed_qty = consumed_amount = delivered_qty = delivered_amount = 0.0
|
||||
if consumed_details.get(item_code):
|
||||
for cd in consumed_details.get(item_code):
|
||||
if cd.voucher_no not in material_transfer_vouchers:
|
||||
consumed_qty += abs(flt(cd.actual_qty))
|
||||
consumed_amount += abs(flt(cd.stock_value_difference))
|
||||
if consumed_qty or consumed_amount:
|
||||
|
||||
if (cd.voucher_no not in material_transfer_vouchers):
|
||||
if cd.voucher_type=="Delivery Note":
|
||||
delivered_qty += abs(flt(cd.actual_qty))
|
||||
delivered_amount += abs(flt(cd.stock_value_difference))
|
||||
elif cd.voucher_type!="Delivery Note":
|
||||
consumed_qty += abs(flt(cd.actual_qty))
|
||||
consumed_amount += abs(flt(cd.stock_value_difference))
|
||||
|
||||
if consumed_qty or consumed_amount or delivered_qty or delivered_amount:
|
||||
row = [cd.item_code, cd.item_name, cd.description, cd.stock_uom, \
|
||||
consumed_qty, consumed_amount, list(set(suppliers))]
|
||||
consumed_qty, consumed_amount, delivered_qty, delivered_amount, \
|
||||
list(set(suppliers))]
|
||||
data.append(row)
|
||||
|
||||
return columns, data
|
||||
@ -29,9 +36,9 @@ def execute(filters=None):
|
||||
def get_columns(filters):
|
||||
"""return columns based on filters"""
|
||||
|
||||
columns = ["Item:Link/Item:100"] + ["Item Name::150"] + ["Description::150"] + \
|
||||
["UOM:Link/UOM:100"] + ["Consumed Qty:Float:130"] + ["Consumed Amount:Currency:130"] + \
|
||||
["Supplier(s)::250"]
|
||||
columns = ["Item:Link/Item:100"] + ["Item Name::100"] + ["Description::150"] + \
|
||||
["UOM:Link/UOM:70"] + ["Consumed Qty:Float:110"] + ["Consumed Amount:Currency:130"] + \
|
||||
["Delivered Qty:Float:100"] + ["Delivered Amount:Currency:130"] + ["Supplier(s)::250"]
|
||||
|
||||
return columns
|
||||
|
||||
@ -52,28 +59,27 @@ def get_consumed_details(filters):
|
||||
for d in webnotes.conn.sql("""select sle.item_code, i.item_name, i.description,
|
||||
i.stock_uom, sle.actual_qty, sle.stock_value_difference, sle.voucher_no
|
||||
from `tabStock Ledger Entry` sle, `tabItem` i
|
||||
where sle.item_code=i.name and sle.actual_qty < 0 %s""" % conditions, values, as_dict=1, debug=1):
|
||||
where sle.item_code=i.name and sle.actual_qty < 0 %s""" % conditions, values, as_dict=1):
|
||||
consumed_details.setdefault(d.item_code, []).append(d)
|
||||
|
||||
return consumed_details
|
||||
|
||||
def get_suppliers_details(filters):
|
||||
item_supplier_map = {}
|
||||
conditions = ""
|
||||
values = []
|
||||
|
||||
if (filters.get('supplier')):
|
||||
conditions = "and pr.supplier=%s"
|
||||
values = [filters.get('supplier')]
|
||||
supplier = filters.get('supplier')
|
||||
|
||||
for d in webnotes.conn.sql("""select pr.supplier, pri.item_code from
|
||||
`tabPurchase Receipt` pr, `tabPurchase Receipt Item` pri
|
||||
where pr.name=pri.parent and pr.docstatus=1 and
|
||||
pri.item_code=(select name from `tabItem` where
|
||||
ifnull(is_stock_item, 'Yes')='Yes' and name=pri.item_code) %s""" % conditions,
|
||||
values, as_dict=1):
|
||||
ifnull(is_stock_item, 'Yes')='Yes' and name=pri.item_code)""", as_dict=1):
|
||||
item_supplier_map.setdefault(d.item_code, []).append(d.supplier)
|
||||
|
||||
|
||||
if supplier:
|
||||
for item_code, suppliers in item_supplier_map.items():
|
||||
if supplier not in suppliers:
|
||||
del item_supplier_map[item_code]
|
||||
|
||||
return item_supplier_map
|
||||
|
||||
def get_material_transfer_vouchers():
|
@ -1,8 +1,8 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-11-29 10:58:23",
|
||||
"creation": "2013-11-29 15:45:39",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-11-29 12:26:49",
|
||||
"modified": "2013-11-29 15:45:40",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@ -12,11 +12,11 @@
|
||||
"is_standard": "Yes",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "Stock Ledger Entry",
|
||||
"report_name": "Item-wise Consumption",
|
||||
"report_name": "Supplier-Wise Sales Analytics",
|
||||
"report_type": "Script Report"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"name": "Item-wise Consumption"
|
||||
"name": "Supplier-Wise Sales Analytics"
|
||||
}
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user