Changeset - 7abc01b1ac35
[Not reviewed]
0 3 0
Brett Smith - 3 years ago 2020-12-29 15:53:55
brettcsmith@brettcsmith.org
fund: Bugfix crash when text report has an empty balance.

This mostly happens when a date range includes the opening or closing of a
fund account, because then the reported beginning/ending balance is empty.
3 files changed with 9 insertions and 2 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reports/fund.py
Show inline comments
...
 
@@ -301,7 +301,7 @@ class TextReport:
 
                print(line_fmt.format('─' * acct_width, '─' * bal_width),
 
                      file=self.out_file)
 
            bal_iter = iter(bal_seq)
 
            print(line_fmt.format(acct_s, next(bal_iter)), file=self.out_file)
 
            print(line_fmt.format(acct_s, next(bal_iter, "—")), file=self.out_file)
 
            for bal_s in bal_iter:
 
                print(line_fmt.format('', bal_s), file=self.out_file)
 
            if is_end_bal:
setup.py
Show inline comments
...
 
@@ -5,7 +5,7 @@ from setuptools import setup
 
setup(
 
    name='conservancy_beancount',
 
    description="Plugin, library, and reports for reading Conservancy's books",
 
    version='1.14.1',
 
    version='1.14.2',
 
    author='Software Freedom Conservancy',
 
    author_email='info@sfconservancy.org',
 
    license='GNU AGPLv3+',
tests/test_reports_fund.py
Show inline comments
...
 
@@ -296,6 +296,13 @@ def test_text_report(project, start_date, stop_date):
 
    assert retcode == 0
 
    check_text_report(output, project, start_date, stop_date)
 

	
 
def test_text_report_empty_balances():
 
    retcode, output, errors = run_main(io.StringIO, [
 
        '-t', 'text', '-b', '2018-01-01',
 
    ])
 
    assert not errors.getvalue()
 
    assert retcode == 0
 

	
 
@pytest.mark.parametrize('start_date,stop_date', [
 
    (START_DATE, STOP_DATE),
 
    (MID_DATE, STOP_DATE),
0 comments (0 inline, 0 general)