Merge pull request #25779 from ankush/parallel_stock_transactions

fix: wrong quantity after transaction for parallel stock transactions
This commit is contained in:
rohitwaghchaure 2021-05-21 18:11:34 +05:30 committed by GitHub
commit 579a1b7028
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -232,7 +232,8 @@ class update_entries_after(object):
and is_cancelled = 0 and is_cancelled = 0
and timestamp(posting_date, time_format(posting_time, %(time_format)s)) < timestamp(%(posting_date)s, time_format(%(posting_time)s, %(time_format)s)) and timestamp(posting_date, time_format(posting_time, %(time_format)s)) < timestamp(%(posting_date)s, time_format(%(posting_time)s, %(time_format)s))
order by timestamp(posting_date, posting_time) desc, creation desc order by timestamp(posting_date, posting_time) desc, creation desc
limit 1""", args, as_dict=1) limit 1
for update""", args, as_dict=1)
return sle[0] if sle else frappe._dict() return sle[0] if sle else frappe._dict()
@ -623,7 +624,7 @@ class update_entries_after(object):
break break
# If no entry found with outgoing rate, collapse stack # If no entry found with outgoing rate, collapse stack
if index == None: if index is None: # nosemgrep
new_stock_value = sum((d[0]*d[1] for d in self.wh_data.stock_queue)) - qty_to_pop*outgoing_rate new_stock_value = sum((d[0]*d[1] for d in self.wh_data.stock_queue)) - qty_to_pop*outgoing_rate
new_stock_qty = sum((d[0] for d in self.wh_data.stock_queue)) - qty_to_pop new_stock_qty = sum((d[0] for d in self.wh_data.stock_queue)) - qty_to_pop
self.wh_data.stock_queue = [[new_stock_qty, new_stock_value/new_stock_qty if new_stock_qty > 0 else outgoing_rate]] self.wh_data.stock_queue = [[new_stock_qty, new_stock_value/new_stock_qty if new_stock_qty > 0 else outgoing_rate]]