fund: Add outstanding balances to ODS fund report.
This commit is contained in:
parent
9ae974009b
commit
d473ed54fc
2 changed files with 25 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue