Changeset - 950536e4f19b
[Not reviewed]
0 2 0
Brett Smith - 4 years ago 2020-08-18 17:22:07
brettcsmith@brettcsmith.org
balance_sheet: Transform "chart of accounts" into trial balances.

It was mostly this already, just needed to add a column and change the
title.
2 files changed with 17 insertions and 12 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reports/balance_sheet.py
Show inline comments
...
 
@@ -242,7 +242,7 @@ class Report(core.BaseODS[Sequence[None], None]):
 
        self.write_activities()
 
        self.write_functional_expenses()
 
        self.write_cash_flows()
 
        self.write_chart_of_accounts()
 
        self.write_trial_balances()
 

	
 
    def walk_classifications(self, cseq: Iterable[data.Account]) \
 
        -> Iterator[Tuple[str, Optional[data.Account]]]:
...
 
@@ -565,12 +565,14 @@ class Report(core.BaseODS[Sequence[None], None]):
 
            stylename=self.style_bottomline,
 
        )
 

	
 
    def write_chart_of_accounts(self) -> None:
 
    def write_trial_balances(self) -> None:
 
        self.start_sheet(
 
            "Chart of Accounts",
 
            ["Account Name"], ["Classification"],
 
            "Trial Balances",
 
            ["Account Name"],
 
            ["Classification"],
 
            ["Balance Ending", self.opening_name],
 
            totals_prefix=["Change During", "Year Ending"],
 
            title_fmt="{sheet_name}",
 
            title_fmt="Chart of Accounts with DRAFT {sheet_name}",
 
        )
 
        # Widen text columns
 
        col_style = self.column_style(3.5)
...
 
@@ -579,10 +581,10 @@ class Report(core.BaseODS[Sequence[None], None]):
 
        # Patch up header row text
 
        header_row = self.sheet.lastChild
 
        header_row.removeChild(header_row.firstChild)
 
        header_row.addElement(self.multiline_cell(
 
        header_row.insertBefore(self.multiline_cell(
 
            ["Balance Ending", self.period_name],
 
            stylename=header_row.lastChild.getAttribute('stylename'),
 
        ))
 
        ), header_row.lastChild)
 

	
 
        for acct_root in ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity']:
 
            norm_func = core.normalize_amount_func(f'{acct_root}:Dummy')
...
 
@@ -592,16 +594,19 @@ class Report(core.BaseODS[Sequence[None], None]):
 
                period_bal = self.balances.total(account=account, period=Period.PERIOD)
 
                prior_bal = self.balances.total(account=account, period=Period.PRIOR)
 
                if want_balance:
 
                    total_bal = self.balances.total(account=account)
 
                    total_cell = self.balance_cell(norm_func(total_bal))
 
                    close_bal = self.balances.total(account=account)
 
                    close_cell = self.balance_cell(norm_func(close_bal))
 
                    open_cell = self.balance_cell(norm_func(close_bal - period_bal))
 
                else:
 
                    total_cell = odf.table.TableCell()
 
                    close_cell = odf.table.TableCell()
 
                    open_cell = odf.table.TableCell()
 
                self.add_row(
 
                    self.string_cell(account),
 
                    self.string_cell(account.meta.get('classification', '')),
 
                    open_cell,
 
                    self.balance_cell(norm_func(period_bal)),
 
                    close_cell,
 
                    self.balance_cell(norm_func(prior_bal)),
 
                    total_cell,
 
                )
 

	
 

	
setup.py
Show inline comments
...
 
@@ -5,7 +5,7 @@ from setuptools import setup
 
setup(
 
    name='conservancy_beancount',
 
    description="Plugin, library, and reports for reading Conservancy's books",
 
    version='1.8.1',
 
    version='1.8.2',
 
    author='Software Freedom Conservancy',
 
    author_email='info@sfconservancy.org',
 
    license='GNU AGPLv3+',
0 comments (0 inline, 0 general)