From d3c74c1a1bbb023fd4b2314a098c659624fca7dd Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Tue, 9 Jul 2013 11:51:24 +0530 Subject: [PATCH] [Cleanup][Report] Added company in Warehouse-wise Stock Balance & removed filters from both reports --- .../batch_wise_balance_history.js | 21 ---------- .../batch_wise_balance_history.py | 11 ------ .../warehouse_wise_stock_balance.js | 14 ------- .../warehouse_wise_stock_balance.py | 38 ++++++++----------- 4 files changed, 16 insertions(+), 68 deletions(-) diff --git a/stock/report/batch_wise_balance_history/batch_wise_balance_history.js b/stock/report/batch_wise_balance_history/batch_wise_balance_history.js index 0ba1938a59..98293e45f7 100644 --- a/stock/report/batch_wise_balance_history/batch_wise_balance_history.js +++ b/stock/report/batch_wise_balance_history/batch_wise_balance_history.js @@ -1,26 +1,5 @@ wn.query_reports["Batch-Wise Balance History"] = { "filters": [ - { - "fieldname":"item_code", - "label": "Item", - "fieldtype": "Link", - "options": "Item", - "width": "80" - }, - { - "fieldname":"warehouse", - "label": "Warehouse", - "fieldtype": "Link", - "options": "Warehouse", - "width": "80" - }, - { - "fieldname":"batch_no", - "label": "Batch", - "fieldtype": "Link", - "options": "Batch", - "width": "80" - }, { "fieldname":"from_date", "label": "From Date", diff --git a/stock/report/batch_wise_balance_history/batch_wise_balance_history.py b/stock/report/batch_wise_balance_history/batch_wise_balance_history.py index ca3e775f72..530465e9ae 100644 --- a/stock/report/batch_wise_balance_history/batch_wise_balance_history.py +++ b/stock/report/batch_wise_balance_history/batch_wise_balance_history.py @@ -49,15 +49,6 @@ def get_columns(filters): def get_conditions(filters): conditions = "" - if filters.get("item_code"): - conditions += " and item_code='%s'" % filters["item_code"] - - if filters.get("warehouse"): - conditions += " and warehouse='%s'" % filters["warehouse"] - - if filters.get("batch_no"): - conditions += " and batch_no='%s'" % filters["batch_no"] - if not filters.get("from_date"): webnotes.msgprint("Please enter From Date", raise_exception=1) @@ -100,8 +91,6 @@ def get_item_warehouse_batch_map(filters): return iwb_map def get_item_details(filters): - if filters.get("item_code"): - conditions = " and name = '%s'" % filters["item_code"] item_map = {} for d in webnotes.conn.sql("select name, item_name, description from tabItem", as_dict=1): item_map.setdefault(d.name, d) diff --git a/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.js b/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.js index 5e1eb3a7b2..2ce5b4b4ab 100644 --- a/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.js +++ b/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.js @@ -1,19 +1,5 @@ wn.query_reports["Warehouse-Wise Stock Balance"] = { "filters": [ - { - "fieldname":"item_code", - "label": "Item", - "fieldtype": "Link", - "options": "Item", - "width": "80" - }, - { - "fieldname":"warehouse", - "label": "Warehouse", - "fieldtype": "Link", - "options": "Warehouse", - "width": "80" - }, { "fieldname":"from_date", "label": "From Date", diff --git a/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.py b/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.py index 324bbe3e8c..4389aa59e4 100644 --- a/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.py +++ b/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.py @@ -26,34 +26,29 @@ def execute(filters=None): iwb_map = get_item_warehouse_map(filters) data = [] - for item in sorted(iwb_map): - for wh in sorted(iwb_map[item]): - qty_dict = iwb_map[item][wh] - data.append([item, item_map[item]["item_name"], - item_map[item]["description"], wh, - qty_dict.opening_qty, qty_dict.in_qty, - qty_dict.out_qty, qty_dict.bal_qty - ]) + for company in sorted(iwb_map): + for item in sorted(iwb_map[company]): + for wh in sorted(iwb_map[company][item]): + qty_dict = iwb_map[company][item][wh] + data.append([item, item_map[item]["item_name"], + item_map[item]["description"], wh, + qty_dict.opening_qty, qty_dict.in_qty, + qty_dict.out_qty, qty_dict.bal_qty, company + ]) return columns, data def get_columns(filters): """return columns based on filters""" - columns = ["Item:Link/Item:100"] + ["Item Name::150"] + ["Description::150"] + \ - ["Warehouse:Link/Warehouse:100"] + ["Opening Qty::90"] + \ - ["In Qty::80"] + ["Out Qty::80"] + ["Balance Qty::90"] + columns = ["Item:Link/Item:100", "Item Name::150", "Description::150", \ + "Warehouse:Link/Warehouse:100", "Opening Qty::90", \ + "In Qty::80", "Out Qty::80", "Balance Qty::90", "Company:Link/Company:100"] return columns def get_conditions(filters): conditions = "" - if filters.get("item_code"): - conditions += " and item_code='%s'" % filters["item_code"] - - if filters.get("warehouse"): - conditions += " and warehouse='%s'" % filters["warehouse"] - if not filters.get("from_date"): webnotes.msgprint("Please enter From Date", raise_exception=1) @@ -68,7 +63,7 @@ def get_conditions(filters): def get_stock_ledger_entries(filters): conditions = get_conditions(filters) return webnotes.conn.sql("""select item_code, warehouse, - posting_date, actual_qty + posting_date, actual_qty, company from `tabStock Ledger Entry` where ifnull(is_cancelled, 'No') = 'No' %s order by item_code, warehouse""" % conditions, as_dict=1) @@ -78,10 +73,11 @@ def get_item_warehouse_map(filters): iwb_map = {} for d in sle: - iwb_map.setdefault(d.item_code, {}).setdefault(d.warehouse, webnotes._dict({\ + iwb_map.setdefault(d.company, {}).setdefault(d.item_code, {}).\ + setdefault(d.warehouse, webnotes._dict({\ "opening_qty": 0.0, "in_qty": 0.0, "out_qty": 0.0, "bal_qty": 0.0 })) - qty_dict = iwb_map[d.item_code][d.warehouse] + qty_dict = iwb_map[d.company][d.item_code][d.warehouse] if d.posting_date < filters["from_date"]: qty_dict.opening_qty += flt(d.actual_qty) elif d.posting_date >= filters["from_date"] and d.posting_date <= filters["to_date"]: @@ -95,8 +91,6 @@ def get_item_warehouse_map(filters): return iwb_map def get_item_details(filters): - if filters.get("item_code"): - conditions = " and name = '%s'" % filters["item_code"] item_map = {} for d in webnotes.conn.sql("select name, item_name, description from tabItem", as_dict=1): item_map.setdefault(d.name, d)