Changeset - 39fa977f71ce
[Not reviewed]
0 2 0
Brett Smith - 4 years ago 2020-06-04 14:49:55
brettcsmith@brettcsmith.org
reports: Balance.le/ge_zero returns False when exactly at tolerance.
2 files changed with 8 insertions and 2 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reports/core.py
Show inline comments
...
 
@@ -168,9 +168,11 @@ class Balance(Mapping[str, data.Amount]):
 
    def ge_zero(self) -> bool:
 
        """Returns true if all amounts in the balance >= 0, within tolerance."""
 
        return self._all_amounts(operator.ge, -self.tolerance)
 
        op_func = operator.gt if self.tolerance else operator.ge
 
        return self._all_amounts(op_func, -self.tolerance)
 

	
 
    def le_zero(self) -> bool:
 
        """Returns true if all amounts in the balance <= 0, within tolerance."""
 
        return self._all_amounts(operator.le, self.tolerance)
 
        op_func = operator.lt if self.tolerance else operator.le
 
        return self._all_amounts(op_func, self.tolerance)
 

	
 
    def format(self,
tests/test_reports_balance.py
Show inline comments
...
 
@@ -113,4 +113,6 @@ def test_eq_zero(mapping, expected):
 
    ({'USD': '0.00015'}, True),
 
    ({'EUR': '-0.00052'}, True),
 
    ({'RUB': core.Balance.TOLERANCE}, True),
 
    ({'RUB': -core.Balance.TOLERANCE}, False),
 
])
 
def test_ge_zero(mapping, expected):
...
 
@@ -130,4 +132,6 @@ def test_ge_zero(mapping, expected):
 
    ({'USD': '0.00015'}, True),
 
    ({'EUR': '-0.00052'}, True),
 
    ({'RUB': core.Balance.TOLERANCE}, False),
 
    ({'RUB': -core.Balance.TOLERANCE}, True),
 
])
 
def test_le_zero(mapping, expected):
0 comments (0 inline, 0 general)