diff --git a/conservancy_beancount/reports/fund.py b/conservancy_beancount/reports/fund.py index a796686d6b627568ec6a0dfb8cfac2b241445cfb..71eaf69bcae2ec69630c9551b7e07c8774e170d6 100644 --- a/conservancy_beancount/reports/fund.py +++ b/conservancy_beancount/reports/fund.py @@ -214,7 +214,9 @@ class ODSReport(core.BaseODS[str, None]): # Write the expanded fund report. start_spreadsheet() will see we've # written the first sheet and adapt. super().write(iter(row_list)) + self.write_balance_row("", self.sheet_totals, self.style_total) self.write_balances("Unrestricted", fund=core.Fund.UNRESTRICTED) + self.write_balance_row("", self.sheet_totals, self.style_bottomline) self.set_open_sheet(self.sheet) diff --git a/setup.py b/setup.py index 7561748d2a1df3b3c61640413b056f1165c4dd72..31de759af818cdd2f8150f0d741852ea9a828506 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup setup( name='conservancy_beancount', description="Plugin, library, and reports for reading Conservancy's books", - version='1.12.1', + version='1.12.2', author='Software Freedom Conservancy', author_email='info@sfconservancy.org', license='GNU AGPLv3+', diff --git a/tests/test_reports_fund.py b/tests/test_reports_fund.py index f04238dcc4121f5760ccd93a2af834aad0f064bf..fbcba40fc8f6f70d089286c80a864f42b0e59a5f 100644 --- a/tests/test_reports_fund.py +++ b/tests/test_reports_fund.py @@ -175,21 +175,29 @@ def check_cell_balance(cell, balance): assert not cell.value def check_ods_sheet(sheet, account_balances, *, full): + total_keys = ['opening', 'Income', 'Expenses', 'Equity'] if full: account_bals = account_balances.copy() - account_bals['Unrestricted'] = account_bals.pop('Conservancy') + unrestricted = account_bals.pop('Conservancy') + total_keys += [ + 'Assets:Receivable', + 'Assets:Prepaid', + 'Liabilities', + 'Liabilities:Payable', + ] else: account_bals = { key: balances for key, balances in account_balances.items() if key != 'Conservancy' and any(v >= .5 for v in balances.values()) } - totals = {key: Decimal() for key in - ['opening', 'Income', 'Expenses', 'Equity']} - for fund, balances in account_bals.items(): - for key in totals: - totals[key] += balances[key] - account_bals[''] = totals + totals = {key: Decimal() for key in total_keys} + for fund, balances in account_bals.items(): + for key in totals: + totals[key] += balances[key] + account_bals[''] = totals + if full: + account_bals['Unrestricted'] = unrestricted for row in itertools.islice(sheet.getElementsByType(odf.table.TableRow), 4, None): cells = iter(testutil.ODSCell.from_row(row)) try: @@ -218,6 +226,11 @@ def check_ods_sheet(sheet, account_balances, *, full): check_cell_balance(next(cells), balances['Liabilities']) check_cell_balance(next(cells), balances['Liabilities:Payable']) assert next(cells, None) is None + if full and fund == 'Unrestricted': + assert '' not in account_bals, "Unrestricted funds reported before subtotals" + for key, bal in balances.items(): + totals[key] += bal + account_bals[''] = totals assert not account_bals, "did not see all funds in report" def check_ods_report(ods, start_date, stop_date):