@@ -230,6 +230,36 @@ def prepare_stock_reco_voucher_wise_count(self):
230230 .groupby (doctype .voucher_detail_no )
231231 )
232232
233+ if items := self .filters .item_code :
234+ if isinstance (items , str ):
235+ items = [items ]
236+
237+ query = query .where (item .name .isin (items ))
238+
239+ if self .filters .item_group :
240+ childrens = []
241+ childrens .append (self .filters .item_group )
242+ if item_group_childrens := get_descendants_of (
243+ "Item Group" , self .filters .item_group , ignore_permissions = True
244+ ):
245+ childrens .extend (item_group_childrens )
246+
247+ if childrens :
248+ query = query .where (item .item_group .isin (childrens ))
249+
250+ if warehouses := self .filters .get ("warehouse" ):
251+ if isinstance (warehouses , str ):
252+ warehouses = [warehouses ]
253+
254+ childrens = []
255+ for warehouse in warehouses :
256+ childrens .append (warehouse )
257+ if warehouse_childrens := get_descendants_of ("Warehouse" , warehouse , ignore_permissions = True ):
258+ childrens .extend (warehouse_childrens )
259+
260+ if childrens :
261+ query = query .where (doctype .warehouse .isin (childrens ))
262+
233263 data = query .run (as_dict = True )
234264 if not data :
235265 return
@@ -238,10 +268,12 @@ def prepare_stock_reco_voucher_wise_count(self):
238268 if row .count != 1 :
239269 continue
240270
241- current_qty = frappe .db .get_value (
242- "Stock Reconciliation Item" , row .voucher_detail_no , "current_qty"
271+ sr_item = frappe .db .get_value (
272+ "Stock Reconciliation Item" , row .voucher_detail_no , [ "current_qty" , "qty" ], as_dict = True
243273 )
244- self .stock_reco_voucher_wise_count [row .voucher_detail_no ] = current_qty
274+
275+ if sr_item .qty and sr_item .current_qty :
276+ self .stock_reco_voucher_wise_count [row .voucher_detail_no ] = sr_item .current_qty
245277
246278 def prepare_new_data (self ):
247279 if self .filters .get ("show_stock_ageing_data" ):
0 commit comments