diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index fe63fa0a654..8cada34f0b9 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -1587,7 +1587,7 @@ def get_stock_and_account_balance(account=None, posting_date=None, company=None) if wh_details.account == account and not wh_details.is_group ] - total_stock_value = get_stock_value_on(related_warehouses, posting_date) + total_stock_value = get_stock_value_on(related_warehouses, posting_date, company=company) precision = frappe.get_precision("Journal Entry Account", "debit_in_account_currency") return flt(account_balance, precision), flt(total_stock_value, precision), related_warehouses diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py index 058db2a6e20..f951ac019f5 100644 --- a/erpnext/stock/utils.py +++ b/erpnext/stock/utils.py @@ -54,7 +54,10 @@ def get_stock_value_from_bin(warehouse=None, item_code=None): def get_stock_value_on( - warehouses: list | str | None = None, posting_date: str | None = None, item_code: str | None = None + warehouses: list | str | None = None, + posting_date: str | None = None, + item_code: str | None = None, + company: str | None = None, ) -> float: if not posting_date: posting_date = nowdate() @@ -82,6 +85,9 @@ def get_stock_value_on( if item_code: query = query.where(sle.item_code == item_code) + if company: + query = query.where(sle.company == company) + return query.run(as_list=True)[0][0]