fix: negative stock qty error for stock reconciliation (#41283)

fix: negative stock qty error for stock reco
This commit is contained in:
rohitwaghchaure
2024-05-02 09:38:33 +05:30
committed by GitHub
parent 82b2675aa8
commit 9aa054c400

View File

@@ -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