Skip to content

Commit

Permalink
fix: Maintain same rate in Stock Ledger until stock become positive (f…
Browse files Browse the repository at this point in the history
…rappe#27227)

* fix: Maintain same rate in Stock Ledger until stock become positive

* fix: Maintain same rate in Stock Ledger until stock become positive
  • Loading branch information
nabinhait authored Sep 14, 2021
1 parent c9e7e72 commit 1075483
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions erpnext/stock/stock_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,11 +673,15 @@ def get_fifo_values(self, sle):
if self.wh_data.stock_queue[-1][1]==incoming_rate:
self.wh_data.stock_queue[-1][0] += actual_qty
else:
# Item has a positive balance qty, add new entry
if self.wh_data.stock_queue[-1][0] > 0:
self.wh_data.stock_queue.append([actual_qty, incoming_rate])
else:
else: # negative balance qty
qty = self.wh_data.stock_queue[-1][0] + actual_qty
self.wh_data.stock_queue[-1] = [qty, incoming_rate]
if qty > 0: # new balance qty is positive
self.wh_data.stock_queue[-1] = [qty, incoming_rate]
else: # new balance qty is still negative, maintain same rate
self.wh_data.stock_queue[-1][0] = qty
else:
qty_to_pop = abs(actual_qty)
while qty_to_pop:
Expand Down

0 comments on commit 1075483

Please sign in to comment.