Changeset - 58954aab235a
[Not reviewed]
0 2 0
Brett Smith - 4 years ago 2020-08-22 13:49:19
brettcsmith@brettcsmith.org
fund: Text output readability improvements.

Make it look more like the spreadsheets:

* Don't normalize Expenses negative.

* Consistent account order: Income, then Expenses, then Equity.

* Include a bottom line divider for each fund.
2 files changed with 21 insertions and 11 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reports/fund.py
Show inline comments
...
 
@@ -84,3 +84,3 @@ FundPosts = Tuple[MetaValue, AccountsMap]
 

	
 
EQUITY_ACCOUNTS = ['Equity', 'Income', 'Expenses']
 
EQUITY_ACCOUNTS = ['Income', 'Expenses', 'Equity']
 
INFO_ACCOUNTS = [
...
 
@@ -108,3 +108,3 @@ class ODSReport(core.BaseODS[FundPosts, None]):
 
            sheet_name = "With Breakdowns"
 
            headers += [["Income"], ["Expenses"], ["Equity"]]
 
            headers.extend([acct] for acct in EQUITY_ACCOUNTS)
 
        else:
...
 
@@ -178,6 +178,5 @@ class ODSReport(core.BaseODS[FundPosts, None]):
 
    def _row_balances(self, accounts_map: AccountsMap) -> Iterator[core.Balance]:
 
        acct_order = ['Income', 'Expenses', 'Equity']
 
        key_order = [core.OPENING_BALANCE_NAME, *acct_order, core.ENDING_BALANCE_NAME]
 
        key_order = [core.OPENING_BALANCE_NAME, *EQUITY_ACCOUNTS, core.ENDING_BALANCE_NAME]
 
        balances: Dict[str, core.Balance] = {key: core.MutableBalance() for key in key_order}
 
        for acct_s, balance in core.account_balances(accounts_map, acct_order):
 
        for acct_s, balance in core.account_balances(accounts_map, EQUITY_ACCOUNTS):
 
            if acct_s in balances:
...
 
@@ -244,3 +243,5 @@ class TextReport:
 
                acct_s = total_fmt.format(self.stop_date.isoformat())
 
            yield acct_s, (-balance).format(None, sep='\0').split('\0')
 
            if not acct_s.startswith('Expenses:'):
 
                balance = -balance
 
            yield acct_s, balance.format(None, sep='\0').split('\0')
 
        for _, account in core.sort_and_filter_accounts(account_map, INFO_ACCOUNTS):
...
 
@@ -264,5 +265,7 @@ class TextReport:
 
        fund_start = f' balance as of {self.start_date.isoformat()}'
 
        fund_end = f' balance as of {self.stop_date.isoformat()}'
 
        for acct_s, bal_seq in output:
 
            if acct_s.endswith(fund_start):
 
                print(line_fmt.format('―' * acct_width, '―' * bal_width),
 
            is_end_bal = acct_s.endswith(fund_end)
 
            if is_end_bal or acct_s.endswith(fund_start):
 
                print(line_fmt.format('─' * acct_width, '─' * bal_width),
 
                      file=self.out_file)
...
 
@@ -272,2 +275,5 @@ class TextReport:
 
                print(line_fmt.format('', bal_s), file=self.out_file)
 
            if is_end_bal:
 
                print(line_fmt.format('═' * acct_width, '═' * bal_width),
 
                      file=self.out_file)
 

	
tests/test_reports_fund.py
Show inline comments
...
 
@@ -113,2 +113,5 @@ def check_text_balances(actual, expected, *expect_accounts):
 
        expect_amount = expected[expect_account]
 
        balance += expect_amount
 
        if expect_account.startswith('Expenses:'):
 
            expect_amount *= -1
 
        if expect_amount:
...
 
@@ -117,3 +120,2 @@ def check_text_balances(actual, expected, *expect_accounts):
 
            assert actual_amount == format_amount(expect_amount)
 
            balance += expect_amount
 
    return balance
...
 
@@ -144,2 +146,4 @@ def check_text_report(output, project, start_date, stop_date):
 
        actual, expected,
 
        'Income:Other',
 
        'Expenses:Other',
 
        'Equity:Funds:Restricted',
...
 
@@ -147,5 +151,4 @@ def check_text_report(output, project, start_date, stop_date):
 
        'Equity:Realized:CurrencyConversion',
 
        'Income:Other',
 
        'Expenses:Other',
 
    )
 
    next(actual)
 
    end_acct, end_amt = next(actual)
...
 
@@ -155,2 +158,3 @@ def check_text_report(output, project, start_date, stop_date):
 
    assert end_amt == format_amount(balance_amount)
 
    next(actual)
 
    balance_amount += check_text_balances(
0 comments (0 inline, 0 general)