fix: negative stock error
(cherry picked from commit 6d513e2519)
# Conflicts:
# erpnext/stock/stock_ledger.py
This commit is contained in:
committed by
Mergify
parent
6735b09dd9
commit
2f4ffe137e
@@ -1021,7 +1021,7 @@ class update_entries_after(object):
|
||||
frappe.db.set_value("Bin", bin_name, updated_values)
|
||||
|
||||
|
||||
def get_previous_sle_of_current_voucher(args, exclude_current_voucher=False):
|
||||
def get_previous_sle_of_current_voucher(args, operator="<", exclude_current_voucher=False):
|
||||
"""get stock ledger entries filtered by specific posting datetime conditions"""
|
||||
|
||||
args["time_format"] = "%H:%i:%s"
|
||||
@@ -1043,11 +1043,21 @@ def get_previous_sle_of_current_voucher(args, exclude_current_voucher=False):
|
||||
and warehouse = %(warehouse)s
|
||||
and is_cancelled = 0
|
||||
{voucher_condition}
|
||||
<<<<<<< HEAD
|
||||
and timestamp(posting_date, time_format(posting_time, %(time_format)s)) < timestamp(%(posting_date)s, time_format(%(posting_time)s, %(time_format)s))
|
||||
=======
|
||||
and (
|
||||
posting_date < %(posting_date)s or
|
||||
(
|
||||
posting_date = %(posting_date)s and
|
||||
time_format(posting_time, %(time_format)s) {operator} time_format(%(posting_time)s, %(time_format)s)
|
||||
)
|
||||
)
|
||||
>>>>>>> 6d513e2519 (fix: negative stock error)
|
||||
order by timestamp(posting_date, posting_time) desc, creation desc
|
||||
limit 1
|
||||
for update""".format(
|
||||
voucher_condition=voucher_condition
|
||||
operator=operator, voucher_condition=voucher_condition
|
||||
),
|
||||
args,
|
||||
as_dict=1,
|
||||
@@ -1285,7 +1295,7 @@ def get_stock_reco_qty_shift(args):
|
||||
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(
|
||||
last_balance = get_previous_sle_of_current_voucher(args, "<=", exclude_current_voucher=True).get(
|
||||
"qty_after_transaction"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user