From d473ed54fc6b625797fe6ec0e94f5a19c8605614 2020-06-27 20:51:35 From: Brett Smith Date: 2020-06-27 20:51:35 Subject: [PATCH] fund: Add outstanding balances to ODS fund report. --- diff --git a/conservancy_beancount/reports/fund.py b/conservancy_beancount/reports/fund.py index 1b1f16821df692fe6b5a937373f45fea5ffb9d18..2152cdaace078737aa7bfce6b1131ab2148a0a17 100644 --- a/conservancy_beancount/reports/fund.py +++ b/conservancy_beancount/reports/fund.py @@ -103,7 +103,7 @@ class ODSReport(core.BaseODS[FundPosts, None]): def start_spreadsheet(self) -> None: self.use_sheet("Fund Report") - for width in [2.5, 1.5, 1.2, 1.2, 1.2, 1.5]: + for width in [2.5, 1.5, 1.2, 1.2, 1.2, 1.5, 1.2, 1.3, 1.2, 1.3]: col_style = self.column_style(width) self.sheet.addElement(odf.table.TableColumn(stylename=col_style)) center_bold = self.merge_styles(self.style_centertext, self.style_bold) @@ -118,6 +118,10 @@ class ODSReport(core.BaseODS[FundPosts, None]): self.multiline_cell(["Realized", "Gain/Loss"], stylename=center_bold), self.multiline_cell(["Balance as of", self.stop_date.isoformat()], stylename=center_bold), + self.multiline_cell(["Of Which", "Receivable"], stylename=center_bold), + self.multiline_cell(["Of Which", "Prepaid Expenses"], stylename=center_bold), + self.multiline_cell(["Of Which", "Payable"], stylename=center_bold), + self.multiline_cell(["Of Which", "Unearned Income"], stylename=center_bold), ) self.lock_first_row() self.add_row() @@ -143,6 +147,10 @@ class ODSReport(core.BaseODS[FundPosts, None]): yield balances[key] else: yield -balances[key] + for info_key in INFO_ACCOUNTS: + for _, balance in core.account_balances(accounts_map, [info_key]): + pass + yield core.normalize_amount_func(info_key)(balance) def write_row(self, row: FundPosts) -> None: fund, accounts_map = row diff --git a/tests/test_reports_fund.py b/tests/test_reports_fund.py index 41691a328b8064b4faecbd451ed7b062fd6962fd..f5ddb38d25e5d7005472285a74ff43f9a5b59929 100644 --- a/tests/test_reports_fund.py +++ b/tests/test_reports_fund.py @@ -149,6 +149,12 @@ def check_text_report(output, project, start_date, stop_date): ) assert next(actual, None) is None +def check_cell_balance(cell, balance): + if balance: + assert cell.value == balance + else: + assert not cell.value + def check_ods_report(ods, start_date, stop_date): account_bals = collections.OrderedDict((key, { 'opening': Decimal(amount), @@ -181,16 +187,17 @@ def check_ods_report(ods, start_date, stop_date): fund = None if fund in account_bals: balances = account_bals.pop(fund) - assert next(cells).value == balances['opening'] - assert next(cells).value == balances['Income'] - assert next(cells).value == -balances['Expenses'] - if balances['Equity:Realized']: - assert next(cells).value == balances['Equity:Realized'] - else: - assert not next(cells).value - assert next(cells).value == sum(balances[key] for key in [ + check_cell_balance(next(cells), balances['opening']) + check_cell_balance(next(cells), balances['Income']) + check_cell_balance(next(cells), -balances['Expenses']) + check_cell_balance(next(cells), balances['Equity:Realized']) + check_cell_balance(next(cells), sum(balances[key] for key in [ 'opening', 'Income', 'Expenses', 'Equity:Realized', - ]) + ])) + check_cell_balance(next(cells), balances['Assets:Receivable']) + check_cell_balance(next(cells), balances['Assets:Prepaid']) + check_cell_balance(next(cells), balances['Liabilities:Payable']) + check_cell_balance(next(cells), balances['Liabilities']) assert not account_bals, "did not see all funds in report" def run_main(out_type, arglist, config=None):