feat: add `Reserved Stock` column in `Stock Balance` Report
diff --git a/erpnext/stock/report/stock_balance/stock_balance.py b/erpnext/stock/report/stock_balance/stock_balance.py
index 68df918..8eb1c74 100644
--- a/erpnext/stock/report/stock_balance/stock_balance.py
+++ b/erpnext/stock/report/stock_balance/stock_balance.py
@@ -100,6 +100,7 @@
_func = itemgetter(1)
self.item_warehouse_map = self.get_item_warehouse_map()
+ sre_details = self.get_sre_reserved_qty_details()
variant_values = {}
if self.filters.get("show_variant_attributes"):
@@ -133,6 +134,9 @@
report_data.update(stock_ageing_data)
+ report_data.update(
+ {"reserved_stock": sre_details.get((report_data.item_code, report_data.warehouse), 0.0)}
+ )
self.data.append(report_data)
def get_item_warehouse_map(self):
@@ -159,6 +163,18 @@
return item_warehouse_map
+ def get_sre_reserved_qty_details(self) -> dict:
+ from erpnext.stock.doctype.stock_reservation_entry.stock_reservation_entry import (
+ get_sre_reserved_qty_details_for_item_and_warehouse as get_reserved_qty_details,
+ )
+
+ item_code_list, warehouse_list = [], []
+ for d in self.item_warehouse_map:
+ item_code_list.append(d[1])
+ warehouse_list.append(d[2])
+
+ return get_reserved_qty_details(item_code_list, warehouse_list)
+
def prepare_item_warehouse_map(self, item_warehouse_map, entry, group_by_key):
qty_dict = item_warehouse_map[group_by_key]
for field in self.inventory_dimensions:
@@ -436,6 +452,13 @@
"options": "currency",
},
{
+ "label": _("Reserved Stock"),
+ "fieldname": "reserved_stock",
+ "fieldtype": "Float",
+ "width": 80,
+ "convertible": "qty",
+ },
+ {
"label": _("Company"),
"fieldname": "company",
"fieldtype": "Link",