Merge pull request #35426 from rohitwaghchaure/fixed-incorrect-actual-qty-bin
fix: incorrect available quantity in BIN
This commit is contained in:
commit
4099330bf4
@ -447,12 +447,11 @@ class update_entries_after(object):
|
|||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
self.process_sle(sle)
|
self.process_sle(sle)
|
||||||
|
self.update_bin_data(sle)
|
||||||
|
|
||||||
if sle.dependant_sle_voucher_detail_no:
|
if sle.dependant_sle_voucher_detail_no:
|
||||||
entries_to_fix = self.get_dependent_entries_to_fix(entries_to_fix, sle)
|
entries_to_fix = self.get_dependent_entries_to_fix(entries_to_fix, sle)
|
||||||
|
|
||||||
self.update_bin()
|
|
||||||
|
|
||||||
if self.exceptions:
|
if self.exceptions:
|
||||||
self.raise_exceptions()
|
self.raise_exceptions()
|
||||||
|
|
||||||
@ -1075,6 +1074,18 @@ class update_entries_after(object):
|
|||||||
else:
|
else:
|
||||||
raise NegativeStockError(message)
|
raise NegativeStockError(message)
|
||||||
|
|
||||||
|
def update_bin_data(self, sle):
|
||||||
|
bin_name = get_or_make_bin(sle.item_code, sle.warehouse)
|
||||||
|
values_to_update = {
|
||||||
|
"actual_qty": sle.qty_after_transaction,
|
||||||
|
"stock_value": sle.stock_value,
|
||||||
|
}
|
||||||
|
|
||||||
|
if sle.valuation_rate is not None:
|
||||||
|
values_to_update["valuation_rate"] = sle.valuation_rate
|
||||||
|
|
||||||
|
frappe.db.set_value("Bin", bin_name, values_to_update)
|
||||||
|
|
||||||
def update_bin(self):
|
def update_bin(self):
|
||||||
# update bin for each warehouse
|
# update bin for each warehouse
|
||||||
for warehouse, data in self.data.items():
|
for warehouse, data in self.data.items():
|
||||||
|
@ -220,7 +220,7 @@ def get_bin(item_code, warehouse):
|
|||||||
|
|
||||||
|
|
||||||
def get_or_make_bin(item_code: str, warehouse: str) -> str:
|
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:
|
if not bin_record:
|
||||||
bin_obj = _create_bin(item_code, warehouse)
|
bin_obj = _create_bin(item_code, warehouse)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user