Changeset - 1fcab6af321b
[Not reviewed]
0 3 0
Brett Smith - 4 years ago 2020-10-16 20:41:08
brettcsmith@brettcsmith.org
fund: Add totals rows to the full report.

This is easy to do with the current infrastructure, and it's nice to have.
3 files changed with 23 insertions and 8 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reports/fund.py
Show inline comments
...
 
@@ -216,3 +216,5 @@ class ODSReport(core.BaseODS[str, None]):
 
        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)
setup.py
Show inline comments
...
 
@@ -7,3 +7,3 @@ setup(
 
    description="Plugin, library, and reports for reading Conservancy's books",
 
    version='1.12.1',
 
    version='1.12.2',
 
    author='Software Freedom Conservancy',
tests/test_reports_fund.py
Show inline comments
...
 
@@ -177,5 +177,12 @@ def check_cell_balance(cell, balance):
 
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:
...
 
@@ -186,8 +193,9 @@ def check_ods_sheet(sheet, account_balances, *, full):
 
        }
 
        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):
...
 
@@ -220,2 +228,7 @@ def check_ods_sheet(sheet, account_balances, *, full):
 
        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"
0 comments (0 inline, 0 general)