From 5dd988207f0542def75cf66cba26c5dd5578269d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 10 Jan 2017 16:10:40 +0530 Subject: [PATCH] Show values based on precision and filter out zero value rows --- .../report/stock_balance/stock_balance.py | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/report/stock_balance/stock_balance.py b/erpnext/stock/report/stock_balance/stock_balance.py index d5d6f9dbe4d..a8db4e09b66 100644 --- a/erpnext/stock/report/stock_balance/stock_balance.py +++ b/erpnext/stock/report/stock_balance/stock_balance.py @@ -102,7 +102,7 @@ def get_item_warehouse_map(filters): "in_qty": 0.0, "in_val": 0.0, "out_qty": 0.0, "out_val": 0.0, "bal_qty": 0.0, "bal_val": 0.0, - "val_rate": 0.0, "uom": None + "val_rate": 0.0 }) qty_dict = iwb_map[(d.company, d.item_code, d.warehouse)] @@ -129,6 +129,24 @@ def get_item_warehouse_map(filters): qty_dict.val_rate = d.valuation_rate qty_dict.bal_qty += qty_diff qty_dict.bal_val += value_diff + + iwb_map = filter_items_with_no_transactions(iwb_map) + + return iwb_map + +def filter_items_with_no_transactions(iwb_map): + for (company, item, warehouse) in sorted(iwb_map): + qty_dict = iwb_map[(company, item, warehouse)] + + no_transactions = True + for key, val in qty_dict.items(): + val = flt(val, 3) + qty_dict[key] = val + if key != "val_rate" and val: + no_transactions = False + + if no_transactions: + iwb_map.pop((company, item, warehouse)) return iwb_map