mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 17:04:47 +00:00
Merge pull request #55298 from frappe/mergify/bp/version-15-hotfix/pr-55242
fix: stock reco for legacy serial nos (backport #55242)
This commit is contained in:
@@ -887,7 +887,7 @@ class update_entries_after:
|
||||
# Only run in reposting
|
||||
self.get_serialized_values(sle)
|
||||
self.wh_data.qty_after_transaction += flt(sle.actual_qty)
|
||||
if sle.voucher_type == "Stock Reconciliation" and not sle.batch_no:
|
||||
if sle.voucher_type == "Stock Reconciliation" and not sle.batch_no and has_correct_data(sle):
|
||||
self.wh_data.qty_after_transaction = sle.qty_after_transaction
|
||||
|
||||
self.wh_data.stock_value = flt(self.wh_data.qty_after_transaction) * flt(
|
||||
@@ -2517,3 +2517,28 @@ def get_incoming_rate_for_serial_and_batch(item_code, row, sn_obj):
|
||||
@frappe.request_cache
|
||||
def is_repack_entry(stock_entry_id):
|
||||
return frappe.get_cached_value("Stock Entry", stock_entry_id, "purpose") == "Repack"
|
||||
|
||||
|
||||
def has_correct_data(sle):
|
||||
previous_sle = get_previous_sle(
|
||||
{
|
||||
"item_code": sle.item_code,
|
||||
"warehouse": sle.warehouse,
|
||||
"posting_date": sle.posting_date,
|
||||
"posting_time": sle.posting_time,
|
||||
"creation": sle.creation,
|
||||
"sle": sle.name,
|
||||
}
|
||||
)
|
||||
|
||||
if not previous_sle:
|
||||
return True
|
||||
|
||||
previous_qty = previous_sle.get("qty_after_transaction") or 0
|
||||
if previous_qty and not frappe.db.get_value(
|
||||
"Stock Ledger Entry",
|
||||
{"voucher_detail_no": sle.voucher_detail_no, "is_cancelled": 0, "actual_qty": ("<", 0)},
|
||||
):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user