precision fixed in batch-wise balance report

This commit is contained in:
Nabin Hait 2015-04-28 12:53:26 +05:30
parent 3be69d4d81
commit 67fdbcf242

View File

@ -8,20 +8,21 @@ from frappe.utils import flt, cint, getdate
def execute(filters=None): def execute(filters=None):
if not filters: filters = {} if not filters: filters = {}
float_precision = cint(frappe.db.get_default("float_precision")) or 3
columns = get_columns(filters) columns = get_columns(filters)
item_map = get_item_details(filters) item_map = get_item_details(filters)
iwb_map = get_item_warehouse_batch_map(filters) iwb_map = get_item_warehouse_batch_map(filters, float_precision)
data = [] data = []
for item in sorted(iwb_map): for item in sorted(iwb_map):
for wh in sorted(iwb_map[item]): for wh in sorted(iwb_map[item]):
for batch in sorted(iwb_map[item][wh]): for batch in sorted(iwb_map[item][wh]):
qty_dict = iwb_map[item][wh][batch] qty_dict = iwb_map[item][wh][batch]
data.append([item, item_map[item]["item_name"], data.append([item, item_map[item]["item_name"], item_map[item]["description"], wh, batch,
item_map[item]["description"], wh, batch, flt(qty_dict.opening_qty, float_precision), flt(qty_dict.in_qty, float_precision),
qty_dict.opening_qty, qty_dict.in_qty, flt(qty_dict.out_qty, float_precision), flt(qty_dict.bal_qty, float_precision)
qty_dict.out_qty, qty_dict.bal_qty
]) ])
return columns, data return columns, data
@ -56,8 +57,7 @@ def get_stock_ledger_entries(filters):
where docstatus < 2 %s order by item_code, warehouse""" % where docstatus < 2 %s order by item_code, warehouse""" %
conditions, as_dict=1) conditions, as_dict=1)
def get_item_warehouse_batch_map(filters): def get_item_warehouse_batch_map(filters, float_precision):
float_precision = cint(frappe.db.get_default("float_precision")) or 3
sle = get_stock_ledger_entries(filters) sle = get_stock_ledger_entries(filters)
iwb_map = {} iwb_map = {}