fix: Unable to submit backdated stock transactions for different items (#22822)
* fix: Unable to submit backdated stock transactions for different items
* fix: Test cases
* fix: Test Cases
* fix: Test Cases
* fix: Test for stock account JV
* fix: Journal Entry Test
* fix: Delete unwanted code
diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py
index a245d63..cf3deb8 100644
--- a/erpnext/accounts/general_ledger.py
+++ b/erpnext/accounts/general_ledger.py
@@ -158,8 +158,10 @@
if account not in aii_accounts:
continue
+ # Always use current date to get stock and account balance as there can future entries for
+ # other items
account_bal, stock_bal, warehouse_list = get_stock_and_account_balance(account,
- gl_map[0].posting_date, gl_map[0].company)
+ getdate(), gl_map[0].company)
if gl_map[0].voucher_type=="Journal Entry":
# In case of Journal Entry, there are no corresponding SL entries,
@@ -169,7 +171,6 @@
frappe.throw(_("Account: {0} can only be updated via Stock Transactions")
.format(account), StockAccountInvalidTransaction)
- # This has been comment for a temporary, will add this code again on release of immutable ledger
elif account_bal != stock_bal:
precision = get_field_precision(frappe.get_meta("GL Entry").get_field("debit"),
currency=frappe.get_cached_value('Company', gl_map[0].company, "default_currency"))