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
...
 
@@ -298,13 +298,13 @@ class TextReport:
 
        for acct_s, bal_seq in output:
 
            is_end_bal = acct_s.endswith(fund_end)
 
            if is_end_bal or acct_s.endswith(fund_start):
 
                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:
 
                print(line_fmt.format('═' * acct_width, '═' * bal_width),
 
                      file=self.out_file)
 

	
setup.py
Show inline comments
...
 
@@ -2,13 +2,13 @@
 

	
 
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+',
 

	
 
    install_requires=[
 
        'babel>=2.6',  # Debian:python3-babel
tests/test_reports_fund.py
Show inline comments
...
 
@@ -293,12 +293,19 @@ def test_text_report(project, start_date, stop_date):
 
        '-b', start_date.isoformat(), '-e', stop_date.isoformat(), project,
 
    ])
 
    assert not errors.getvalue()
 
    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),
 
    (START_DATE, MID_DATE),
 
])
 
def test_ods_report(start_date, stop_date):
0 comments (0 inline, 0 general)