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