diff --git a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py index 87d94f642ab..713161e3f8a 100644 --- a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py +++ b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py @@ -57,6 +57,11 @@ def execute(filters=None): flt(qty_dict.in_qty, float_precision), flt(qty_dict.out_qty, float_precision), flt(qty_dict.bal_qty, float_precision), + flt( + (qty_dict.bal_value / qty_dict.bal_qty) if qty_dict.bal_qty else 0, + float_precision, + ), + flt(qty_dict.bal_value, float_precision), item_map[item]["stock_uom"], ] ) @@ -69,14 +74,16 @@ def get_columns(filters): columns = [ _("Item") + ":Link/Item:100", - _("Item Name") + "::150", - _("Description") + "::150", + _("Item Name") + "::120", + _("Description") + "::90", _("Warehouse") + ":Link/Warehouse:100", _("Batch") + ":Link/Batch:100", _("Opening Qty") + ":Float:90", _("In Qty") + ":Float:80", _("Out Qty") + ":Float:80", - _("Balance Qty") + ":Float:90", + _("Balance Qty") + ":Float:120", + _("Valuation Rate") + ":Float:120", + _("Balance Value") + ":Currency:120", _("UOM") + "::90", ] @@ -132,6 +139,7 @@ def get_stock_ledger_entries_for_batch_no(filters): sle.batch_no, sle.posting_date, fn.Sum(sle.actual_qty).as_("actual_qty"), + fn.Sum(sle.stock_value_difference).as_("stock_value_difference"), ) .where( (sle.docstatus < 2) @@ -179,6 +187,7 @@ def get_stock_ledger_entries_for_batch_bundle(filters): batch_package.batch_no, sle.posting_date, fn.Sum(batch_package.qty).as_("actual_qty"), + fn.Sum(batch_package.stock_value_difference).as_("stock_value_difference"), ) .where( (sle.docstatus < 2) @@ -222,7 +231,10 @@ def get_item_warehouse_batch_map(filters, float_precision): for d in sle: iwb_map.setdefault(d.item_code, {}).setdefault(d.warehouse, {}).setdefault( - d.batch_no, frappe._dict({"opening_qty": 0.0, "in_qty": 0.0, "out_qty": 0.0, "bal_qty": 0.0}) + d.batch_no, + frappe._dict( + {"opening_qty": 0.0, "in_qty": 0.0, "out_qty": 0.0, "bal_qty": 0.0, "bal_value": 0.0} + ), ) qty_dict = iwb_map[d.item_code][d.warehouse][d.batch_no] if d.posting_date < from_date: @@ -238,6 +250,7 @@ def get_item_warehouse_batch_map(filters, float_precision): ) qty_dict.bal_qty = flt(qty_dict.bal_qty, float_precision) + flt(d.actual_qty, float_precision) + qty_dict.bal_value += flt(d.stock_value_difference, float_precision) return iwb_map