From 9d177433cbbab279fb244b10e8491ab5d4cd1e43 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Sun, 19 Dec 2021 18:51:55 +0530 Subject: [PATCH] fix: return consumed bin on collapsing queue --- erpnext/stock/valuation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/valuation.py b/erpnext/stock/valuation.py index 86a4eb705e0..7f54facda8b 100644 --- a/erpnext/stock/valuation.py +++ b/erpnext/stock/valuation.py @@ -99,11 +99,12 @@ class FifoValuation: index = idx break - # If no entry found with outgoing rate, collapse stack + # If no entry found with outgoing rate, collapse queue if index is None: # nosemgrep new_stock_value = sum(d[QTY] * d[RATE] for d in self.queue) - qty * outgoing_rate new_stock_qty = sum(d[QTY] for d in self.queue) - qty self.queue = [[new_stock_qty, new_stock_value / new_stock_qty if new_stock_qty > 0 else outgoing_rate]] + consumed_bins.append([qty, outgoing_rate]) break else: index = 0