diff --git a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py index 8f4c4e3ccda..54aa3eaf96f 100644 --- a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py @@ -146,10 +146,9 @@ class TestJournalEntry(unittest.TestCase): "credit_in_account_currency": 0 if diff > 0 else abs(diff), }, ) - jv.insert() if account_bal == stock_bal: - self.assertRaises(StockAccountInvalidTransaction, jv.submit) + self.assertRaises(StockAccountInvalidTransaction, jv.save) frappe.db.rollback() else: jv.submit() diff --git a/erpnext/accounts/doctype/payment_request/test_payment_request.py b/erpnext/accounts/doctype/payment_request/test_payment_request.py index eadb714baa3..ed940470d6c 100644 --- a/erpnext/accounts/doctype/payment_request/test_payment_request.py +++ b/erpnext/accounts/doctype/payment_request/test_payment_request.py @@ -83,8 +83,7 @@ class TestPaymentRequest(FrappeTestCase): def test_payment_entry_against_purchase_invoice(self): si_usd = make_purchase_invoice( - customer="_Test Supplier USD", - debit_to="_Test Payable USD - _TC", + supplier="_Test Supplier USD", currency="USD", conversion_rate=50, ) @@ -108,8 +107,7 @@ class TestPaymentRequest(FrappeTestCase): def test_multiple_payment_entry_against_purchase_invoice(self): purchase_invoice = make_purchase_invoice( - customer="_Test Supplier USD", - debit_to="_Test Payable USD - _TC", + supplier="_Test Supplier USD", currency="USD", conversion_rate=50, ) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index a7f8581e0f8..b3c82e84192 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -1644,7 +1644,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 ee5893eb826..6369562a62d 100644 --- a/erpnext/stock/utils.py +++ b/erpnext/stock/utils.py @@ -58,7 +58,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() @@ -84,6 +87,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]