balance_sheet: Add account code column to chart of accounts.

This commit is contained in:
Brett Smith 2020-09-03 15:03:28 -04:00
parent 5081c8934c
commit 2c3438ba0f
2 changed files with 8 additions and 2 deletions

View file

@ -198,7 +198,7 @@ class Balances:
return prefix, -max_bal
return sorted(class_bals, key=sortkey)
def iter_accounts(self, root: str) -> Sequence[data.Account]:
def iter_accounts(self, root: Optional[str]=None) -> Sequence[data.Account]:
start_date = self.period_range.start
stop_date = self.period_range.stop
return sorted(
@ -573,6 +573,7 @@ class Report(core.BaseODS[Sequence[None], None]):
"Trial Balances",
["Account Name"],
["Classification"],
["Account Code"],
["Balance Beginning", self.balances.period_range.start.strftime(self.date_fmt)],
totals_prefix=["Change During", f"{self.period_desc} Ending"],
title_fmt="Chart of Accounts with DRAFT {sheet_name}",
@ -588,6 +589,10 @@ class Report(core.BaseODS[Sequence[None], None]):
["Balance Ending", self.period_name],
stylename=header_row.lastChild.getAttribute('stylename'),
), header_row.lastChild)
# Hide account code if it's not ready.
# FIXME: This code can be removed once codes are fully established.
if not any(acct.meta.get('account-code') for acct in self.balances.iter_accounts()):
self.sheet.childNodes[2].setAttribute('visibility', 'collapse')
for acct_root in ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity']:
norm_func = core.normalize_amount_func(f'{acct_root}:Dummy')
@ -606,6 +611,7 @@ class Report(core.BaseODS[Sequence[None], None]):
self.add_row(
self.string_cell(account),
self.string_cell(account.meta.get('classification', '')),
self.string_cell(account.meta.get('account-code', '')),
open_cell,
self.balance_cell(norm_func(period_bal)),
close_cell,

View file

@ -5,7 +5,7 @@ from setuptools import setup
setup(
name='conservancy_beancount',
description="Plugin, library, and reports for reading Conservancy's books",
version='1.9.4',
version='1.9.5',
author='Software Freedom Conservancy',
author_email='info@sfconservancy.org',
license='GNU AGPLv3+',