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.
This commit is contained in:
Brett Smith 2020-12-29 10:42:15 -05:00
parent e06b400998
commit 7abc01b1ac
3 changed files with 9 additions and 2 deletions

View file

@ -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:

View file

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

View file

@ -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),