From 5bb4058ef448d9bf2bef4bc336b54cfe19768f8d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 14 Sep 2021 13:34:36 +0530 Subject: [PATCH] fix: Maintain same rate in Stock Ledger until stock become positive (#27227) * fix: Maintain same rate in Stock Ledger until stock become positive * fix: Maintain same rate in Stock Ledger until stock become positive (cherry picked from commit 10754831c33b3459d5a45c98f875afa48a444627) # Conflicts: # erpnext/stock/stock_ledger.py --- erpnext/stock/stock_ledger.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index 3a332ceaf16..50fd37404b9 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -1376,8 +1376,24 @@ class update_entries_after: self.wh_data.qty_after_transaction + actual_qty ) +<<<<<<< HEAD if self.valuation_method == "LIFO": stock_queue = LIFOValuation(self.wh_data.stock_queue) +======= + # last row has the same rate, just updated the qty + 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: # negative balance qty + qty = self.wh_data.stock_queue[-1][0] + actual_qty + 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 +>>>>>>> 10754831c3 (fix: Maintain same rate in Stock Ledger until stock become positive (#27227)) else: stock_queue = FIFOValuation(self.wh_data.stock_queue)