fix: round off if near zero while popping from queue
This commit is contained in:
parent
a71b476652
commit
e6e679cf7a
@ -120,17 +120,17 @@ class FifoValuation:
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
# qty found in current bin consume it and exit
|
# 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
|
qty = 0
|
||||||
|
|
||||||
return self.get_state()
|
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
|
"""Rounds off the number to zero only if number is close to zero for decimal
|
||||||
specified in precision. Precision defaults to 6.
|
specified in precision. Precision defaults to 6.
|
||||||
"""
|
"""
|
||||||
if flt(number) < (1.0 / (10 ** precision)):
|
if abs(0.0 - flt(number)) < (1.0 / (10 ** precision)):
|
||||||
return 0
|
return 0.0
|
||||||
|
|
||||||
return flt(number)
|
return flt(number)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user