diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index 99930768ea5..4e624c9acb0 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -1490,6 +1490,10 @@ def get_stock_reco_qty_shift(args): stock_reco_qty_shift = flt(args.qty_after_transaction) - flt(last_balance) else: stock_reco_qty_shift = flt(args.actual_qty) + + elif args.get("serial_no") or args.get("batch_no"): + stock_reco_qty_shift = flt(args.actual_qty) + else: # reco is being submitted last_balance = get_previous_sle_of_current_voucher(args, "<=", exclude_current_voucher=True).get( @@ -1559,6 +1563,15 @@ def get_datetime_limit_condition(detail): def validate_negative_qty_in_future_sle(args, allow_negative_stock=False): if allow_negative_stock or is_negative_stock_allowed(item_code=args.item_code): return + + if ( + args.voucher_type == "Stock Reconciliation" + and args.actual_qty < 0 + and args.get("batch_no") + and frappe.db.get_value("Stock Reconciliation Item", args.voucher_detail_no, "qty") > 0 + ): + return + if not (args.actual_qty < 0 or args.voucher_type == "Stock Reconciliation"): return