mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-23 05:04:52 +01:00
Merge pull request #53207 from frappe/mergify/bp/version-15-hotfix/pr-53200
fix: stock balance report qty (backport #53200)
This commit is contained in:
@@ -203,6 +203,36 @@ class StockBalanceReport:
|
||||
.groupby(doctype.voucher_detail_no)
|
||||
)
|
||||
|
||||
if items := self.filters.item_code:
|
||||
if isinstance(items, str):
|
||||
items = [items]
|
||||
|
||||
query = query.where(item.name.isin(items))
|
||||
|
||||
if self.filters.item_group:
|
||||
childrens = []
|
||||
childrens.append(self.filters.item_group)
|
||||
if item_group_childrens := get_descendants_of(
|
||||
"Item Group", self.filters.item_group, ignore_permissions=True
|
||||
):
|
||||
childrens.extend(item_group_childrens)
|
||||
|
||||
if childrens:
|
||||
query = query.where(item.item_group.isin(childrens))
|
||||
|
||||
if warehouses := self.filters.get("warehouse"):
|
||||
if isinstance(warehouses, str):
|
||||
warehouses = [warehouses]
|
||||
|
||||
childrens = []
|
||||
for warehouse in warehouses:
|
||||
childrens.append(warehouse)
|
||||
if warehouse_childrens := get_descendants_of("Warehouse", warehouse, ignore_permissions=True):
|
||||
childrens.extend(warehouse_childrens)
|
||||
|
||||
if childrens:
|
||||
query = query.where(doctype.warehouse.isin(childrens))
|
||||
|
||||
data = query.run(as_dict=True)
|
||||
if not data:
|
||||
return
|
||||
@@ -211,10 +241,12 @@ class StockBalanceReport:
|
||||
if row.count != 1:
|
||||
continue
|
||||
|
||||
current_qty = frappe.db.get_value(
|
||||
"Stock Reconciliation Item", row.voucher_detail_no, "current_qty"
|
||||
sr_item = frappe.db.get_value(
|
||||
"Stock Reconciliation Item", row.voucher_detail_no, ["current_qty", "qty"], as_dict=True
|
||||
)
|
||||
self.stock_reco_voucher_wise_count[row.voucher_detail_no] = current_qty
|
||||
|
||||
if sr_item.qty and sr_item.current_qty:
|
||||
self.stock_reco_voucher_wise_count[row.voucher_detail_no] = sr_item.current_qty
|
||||
|
||||
def get_sre_reserved_qty_details(self) -> dict:
|
||||
from erpnext.stock.doctype.stock_reservation_entry.stock_reservation_entry import (
|
||||
|
||||
Reference in New Issue
Block a user