fix: negative stock error
This commit is contained in:
parent
6b31c27ed6
commit
6d513e2519
@ -1050,7 +1050,7 @@ class update_entries_after(object):
|
||||
frappe.db.set_value("Bin", bin_name, updated_values, update_modified=True)
|
||||
|
||||
|
||||
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"
|
||||
@ -1076,13 +1076,13 @@ def get_previous_sle_of_current_voucher(args, exclude_current_voucher=False):
|
||||
posting_date < %(posting_date)s or
|
||||
(
|
||||
posting_date = %(posting_date)s and
|
||||
time_format(posting_time, %(time_format)s) < time_format(%(posting_time)s, %(time_format)s)
|
||||
time_format(posting_time, %(time_format)s) {operator} time_format(%(posting_time)s, %(time_format)s)
|
||||
)
|
||||
)
|
||||
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,
|
||||
@ -1375,7 +1375,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"
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user