fix: incorrect available quantity in BIN
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index 6106809..9f81a8c 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -443,12 +443,11 @@
i += 1
self.process_sle(sle)
+ self.update_bin_data(sle)
if sle.dependant_sle_voucher_detail_no:
entries_to_fix = self.get_dependent_entries_to_fix(entries_to_fix, sle)
- self.update_bin()
-
if self.exceptions:
self.raise_exceptions()
@@ -1065,6 +1064,18 @@
else:
raise NegativeStockError(message)
+ def update_bin_data(self, sle):
+ bin_name = get_or_make_bin(sle.item_code, sle.warehouse)
+ frappe.db.set_value(
+ "Bin",
+ bin_name,
+ {
+ "actual_qty": sle.qty_after_transaction,
+ "valuation_rate": sle.valuation_rate,
+ "stock_value": sle.stock_value,
+ },
+ )
+
def update_bin(self):
# update bin for each warehouse
for warehouse, data in self.data.items():
diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py
index 10654dd..ba36983 100644
--- a/erpnext/stock/utils.py
+++ b/erpnext/stock/utils.py
@@ -220,7 +220,7 @@
def get_or_make_bin(item_code: str, warehouse: str) -> str:
- bin_record = frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse})
+ bin_record = frappe.get_cached_value("Bin", {"item_code": item_code, "warehouse": warehouse})
if not bin_record:
bin_obj = _create_bin(item_code, warehouse)