fix: get stock balance filtered by company for validating stock value in jv (backport #45549) (#45577)

* fix: get stock balance filtered by company for validating stock value in jv (#45549)

* fix: get stock balance filtered by company for validating stock value in jv

* test: error is raised  on validate

(cherry picked from commit 9f20854bd9)

# Conflicts:
#	erpnext/accounts/doctype/journal_entry/test_journal_entry.py

* fix: conflict

---------

Co-authored-by: Lakshit Jain <108322669+ljain112@users.noreply.github.com>
Co-authored-by: ljain112 <ljain112@gmail.com>
This commit is contained in:
mergify[bot]
2025-01-29 12:46:13 +05:30
committed by GitHub
parent 1160df9350
commit e682d2c9ae
2 changed files with 8 additions and 2 deletions

View File

@@ -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

View File

@@ -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]