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:
|
def start_spreadsheet(self) -> None:
|
||||||
self.use_sheet("Fund Report")
|
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)
|
col_style = self.column_style(width)
|
||||||
self.sheet.addElement(odf.table.TableColumn(stylename=col_style))
|
self.sheet.addElement(odf.table.TableColumn(stylename=col_style))
|
||||||
center_bold = self.merge_styles(self.style_centertext, self.style_bold)
|
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(["Realized", "Gain/Loss"], stylename=center_bold),
|
||||||
self.multiline_cell(["Balance as of", self.stop_date.isoformat()],
|
self.multiline_cell(["Balance as of", self.stop_date.isoformat()],
|
||||||
stylename=center_bold),
|
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.lock_first_row()
|
||||||
self.add_row()
|
self.add_row()
|
||||||
|
@ -143,6 +147,10 @@ class ODSReport(core.BaseODS[FundPosts, None]):
|
||||||
yield balances[key]
|
yield balances[key]
|
||||||
else:
|
else:
|
||||||
yield -balances[key]
|
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:
|
def write_row(self, row: FundPosts) -> None:
|
||||||
fund, accounts_map = row
|
fund, accounts_map = row
|
||||||
|
|
|
@ -149,6 +149,12 @@ def check_text_report(output, project, start_date, stop_date):
|
||||||
)
|
)
|
||||||
assert next(actual, None) is None
|
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):
|
def check_ods_report(ods, start_date, stop_date):
|
||||||
account_bals = collections.OrderedDict((key, {
|
account_bals = collections.OrderedDict((key, {
|
||||||
'opening': Decimal(amount),
|
'opening': Decimal(amount),
|
||||||
|
@ -181,16 +187,17 @@ def check_ods_report(ods, start_date, stop_date):
|
||||||
fund = None
|
fund = None
|
||||||
if fund in account_bals:
|
if fund in account_bals:
|
||||||
balances = account_bals.pop(fund)
|
balances = account_bals.pop(fund)
|
||||||
assert next(cells).value == balances['opening']
|
check_cell_balance(next(cells), balances['opening'])
|
||||||
assert next(cells).value == balances['Income']
|
check_cell_balance(next(cells), balances['Income'])
|
||||||
assert next(cells).value == -balances['Expenses']
|
check_cell_balance(next(cells), -balances['Expenses'])
|
||||||
if balances['Equity:Realized']:
|
check_cell_balance(next(cells), balances['Equity:Realized'])
|
||||||
assert next(cells).value == balances['Equity:Realized']
|
check_cell_balance(next(cells), sum(balances[key] for key in [
|
||||||
else:
|
|
||||||
assert not next(cells).value
|
|
||||||
assert next(cells).value == sum(balances[key] for key in [
|
|
||||||
'opening', 'Income', 'Expenses', 'Equity:Realized',
|
'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"
|
assert not account_bals, "did not see all funds in report"
|
||||||
|
|
||||||
def run_main(out_type, arglist, config=None):
|
def run_main(out_type, arglist, config=None):
|
||||||
|
|
Loading…
Reference in a new issue