From 950536e4f19baf9a29b326082ce326937a5b484c 2020-08-18 17:22:07 From: Brett Smith Date: 2020-08-18 17:22:07 Subject: [PATCH] balance_sheet: Transform "chart of accounts" into trial balances. It was mostly this already, just needed to add a column and change the title. --- diff --git a/conservancy_beancount/reports/balance_sheet.py b/conservancy_beancount/reports/balance_sheet.py index ef96940b14705165c71f104bb255290602e6a273..5dcb5c438369dd544b0fa09f3bb0ec95f90dc89c 100644 --- a/conservancy_beancount/reports/balance_sheet.py +++ b/conservancy_beancount/reports/balance_sheet.py @@ -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, ) diff --git a/setup.py b/setup.py index 8f4a501c385e158c2fddced0cbb3f38530ab61b6..576a4fa26cf6f81eef9dba5b2d48b8e1f4792234 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.8.1', + version='1.8.2', author='Software Freedom Conservancy', author_email='info@sfconservancy.org', license='GNU AGPLv3+',