From e6e679cf7add6e7beaa7db783b078ad6f6b22792 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Sat, 18 Dec 2021 20:36:47 +0530 Subject: [PATCH] fix: round off if near zero while popping from queue --- erpnext/stock/valuation.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/erpnext/stock/valuation.py b/erpnext/stock/valuation.py index 617e1ca15a8..80e5d376e13 100644 --- a/erpnext/stock/valuation.py +++ b/erpnext/stock/valuation.py @@ -120,17 +120,17 @@ class FifoValuation: else: # qty found in current bin consume it and exit - fifo_bin[QTY] = fifo_bin[QTY] - qty + fifo_bin[QTY] = _round_off_if_near_zero(fifo_bin[QTY] - qty) qty = 0 return self.get_state() -def _round_off_if_near_zero(number: float, precision: int = 6) -> float: +def _round_off_if_near_zero(number: float, precision: int = 7) -> float: """Rounds off the number to zero only if number is close to zero for decimal specified in precision. Precision defaults to 6. """ - if flt(number) < (1.0 / (10 ** precision)): - return 0 + if abs(0.0 - flt(number)) < (1.0 / (10 ** precision)): + return 0.0 return flt(number)