balance_sheet: Transform "chart of accounts" into trial balances.
It was mostly this already, just needed to add a column and change the title.
This commit is contained in:
parent
ee40b5b5c2
commit
950536e4f1
2 changed files with 17 additions and 12 deletions
|
@ -242,7 +242,7 @@ class Report(core.BaseODS[Sequence[None], None]):
|
||||||
self.write_activities()
|
self.write_activities()
|
||||||
self.write_functional_expenses()
|
self.write_functional_expenses()
|
||||||
self.write_cash_flows()
|
self.write_cash_flows()
|
||||||
self.write_chart_of_accounts()
|
self.write_trial_balances()
|
||||||
|
|
||||||
def walk_classifications(self, cseq: Iterable[data.Account]) \
|
def walk_classifications(self, cseq: Iterable[data.Account]) \
|
||||||
-> Iterator[Tuple[str, Optional[data.Account]]]:
|
-> Iterator[Tuple[str, Optional[data.Account]]]:
|
||||||
|
@ -565,12 +565,14 @@ class Report(core.BaseODS[Sequence[None], None]):
|
||||||
stylename=self.style_bottomline,
|
stylename=self.style_bottomline,
|
||||||
)
|
)
|
||||||
|
|
||||||
def write_chart_of_accounts(self) -> None:
|
def write_trial_balances(self) -> None:
|
||||||
self.start_sheet(
|
self.start_sheet(
|
||||||
"Chart of Accounts",
|
"Trial Balances",
|
||||||
["Account Name"], ["Classification"],
|
["Account Name"],
|
||||||
|
["Classification"],
|
||||||
|
["Balance Ending", self.opening_name],
|
||||||
totals_prefix=["Change During", "Year Ending"],
|
totals_prefix=["Change During", "Year Ending"],
|
||||||
title_fmt="{sheet_name}",
|
title_fmt="Chart of Accounts with DRAFT {sheet_name}",
|
||||||
)
|
)
|
||||||
# Widen text columns
|
# Widen text columns
|
||||||
col_style = self.column_style(3.5)
|
col_style = self.column_style(3.5)
|
||||||
|
@ -579,10 +581,10 @@ class Report(core.BaseODS[Sequence[None], None]):
|
||||||
# Patch up header row text
|
# Patch up header row text
|
||||||
header_row = self.sheet.lastChild
|
header_row = self.sheet.lastChild
|
||||||
header_row.removeChild(header_row.firstChild)
|
header_row.removeChild(header_row.firstChild)
|
||||||
header_row.addElement(self.multiline_cell(
|
header_row.insertBefore(self.multiline_cell(
|
||||||
["Balance Ending", self.period_name],
|
["Balance Ending", self.period_name],
|
||||||
stylename=header_row.lastChild.getAttribute('stylename'),
|
stylename=header_row.lastChild.getAttribute('stylename'),
|
||||||
))
|
), header_row.lastChild)
|
||||||
|
|
||||||
for acct_root in ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity']:
|
for acct_root in ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity']:
|
||||||
norm_func = core.normalize_amount_func(f'{acct_root}:Dummy')
|
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)
|
period_bal = self.balances.total(account=account, period=Period.PERIOD)
|
||||||
prior_bal = self.balances.total(account=account, period=Period.PRIOR)
|
prior_bal = self.balances.total(account=account, period=Period.PRIOR)
|
||||||
if want_balance:
|
if want_balance:
|
||||||
total_bal = self.balances.total(account=account)
|
close_bal = self.balances.total(account=account)
|
||||||
total_cell = self.balance_cell(norm_func(total_bal))
|
close_cell = self.balance_cell(norm_func(close_bal))
|
||||||
|
open_cell = self.balance_cell(norm_func(close_bal - period_bal))
|
||||||
else:
|
else:
|
||||||
total_cell = odf.table.TableCell()
|
close_cell = odf.table.TableCell()
|
||||||
|
open_cell = odf.table.TableCell()
|
||||||
self.add_row(
|
self.add_row(
|
||||||
self.string_cell(account),
|
self.string_cell(account),
|
||||||
self.string_cell(account.meta.get('classification', '')),
|
self.string_cell(account.meta.get('classification', '')),
|
||||||
|
open_cell,
|
||||||
self.balance_cell(norm_func(period_bal)),
|
self.balance_cell(norm_func(period_bal)),
|
||||||
|
close_cell,
|
||||||
self.balance_cell(norm_func(prior_bal)),
|
self.balance_cell(norm_func(prior_bal)),
|
||||||
total_cell,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -5,7 +5,7 @@ from setuptools import setup
|
||||||
setup(
|
setup(
|
||||||
name='conservancy_beancount',
|
name='conservancy_beancount',
|
||||||
description="Plugin, library, and reports for reading Conservancy's books",
|
description="Plugin, library, and reports for reading Conservancy's books",
|
||||||
version='1.8.1',
|
version='1.8.2',
|
||||||
author='Software Freedom Conservancy',
|
author='Software Freedom Conservancy',
|
||||||
author_email='info@sfconservancy.org',
|
author_email='info@sfconservancy.org',
|
||||||
license='GNU AGPLv3+',
|
license='GNU AGPLv3+',
|
||||||
|
|
Loading…
Reference in a new issue