Changeset - cc1767a09d1d
[Not reviewed]
0 4 0
Brett Smith - 4 years ago 2020-08-22 13:25:53
brettcsmith@brettcsmith.org
fund: Incorporate Equity accounts into Release from Restrictions.

This matches what we do on our Statement of Activities in the
balance sheet report.
4 files changed with 34 insertions and 12 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reports/fund.py
Show inline comments
...
 
@@ -160,4 +160,7 @@ class ODSReport(core.BaseODS[FundPosts, None]):
 
        threshold = Decimal('.5')
 
        for fund, balances in self.balances.items():
 
            balances = [balances[index] for index in bal_indexes]
 
        for fund, source_bals in self.balances.items():
 
            balances = [source_bals[index] for index in bal_indexes]
 
            # Incorporate Equity changes to Release from Restrictions.
 
            # Note that using -= mutates the balance in a way we don't want.
 
            balances[2] = balances[2] - source_bals[3]
 
            if (not all(bal.clean_copy(threshold).le_zero() for bal in balances)
tests/books/fund.beancount
Show inline comments
...
 
@@ -111,3 +111,3 @@ option "inferred_tolerance_default" "USD:0.01"
 

	
 
2019-12-03 * "Delta income"
 
2019-09-06 * "Delta income"
 
  project: "Delta"
...
 
@@ -115 +115,7 @@ option "inferred_tolerance_default" "USD:0.01"
 
  Assets:Checking  4.60 USD
 

	
 
2019-12-03 * "Charlie release from restriction"
 
  Equity:Funds:Restricted     100 USD
 
  project: "Charlie"
 
  Equity:Funds:Unrestricted  -100 USD
 
  project: "Conservancy"
tests/test_opening_balances.py
Show inline comments
...
 
@@ -148,5 +148,5 @@ def test_2020_opening(arg):
 
        FlatPosting.make(A_RESTRICTED, -2180, project='Bravo'),
 
        FlatPosting.make(A_RESTRICTED, -1000, project='Charlie'),
 
        FlatPosting.make(A_RESTRICTED, -900, project='Charlie'),
 
        FlatPosting.make(A_RESTRICTED, -5, project='Delta'),
 
        FlatPosting.make(A_UNRESTRICTED, -4080, project='Conservancy'),
 
        FlatPosting.make(A_UNRESTRICTED, -4180, project='Conservancy'),
 
    ]
tests/test_reports_fund.py
Show inline comments
...
 
@@ -62,2 +62,3 @@ BALANCES_BY_YEAR = {
 
        ('Expenses:Other', Decimal('-4.20')),
 
        ('Equity:Funds:Unrestricted', 100),
 
        ('Equity:Realized:CurrencyConversion', Decimal('6.20')),
...
 
@@ -83,2 +84,5 @@ BALANCES_BY_YEAR = {
 
    ],
 
    ('Charlie', 2019): [
 
        ('Equity:Funds:Restricted', -100),
 
    ],
 
    ('Delta', 2018): [
...
 
@@ -140,2 +144,4 @@ def check_text_report(output, project, start_date, stop_date):
 
        actual, expected,
 
        'Equity:Funds:Restricted',
 
        'Equity:Funds:Unrestricted',
 
        'Equity:Realized:CurrencyConversion',
...
 
@@ -175,3 +181,3 @@ def check_ods_sheet(sheet, account_balances, *, full):
 
        totals = {key: Decimal() for key in
 
                  ['opening', 'Income', 'Expenses', 'Equity:Realized']}
 
                  ['opening', 'Income', 'Expenses', 'Equity']}
 
        for fund, balances in account_bals.items():
...
 
@@ -192,7 +198,11 @@ def check_ods_sheet(sheet, account_balances, *, full):
 
        check_cell_balance(next(cells), balances['Income'])
 
        check_cell_balance(next(cells), -balances['Expenses'])
 
        if full:
 
            check_cell_balance(next(cells), balances['Equity:Realized'])
 
            check_cell_balance(next(cells), -balances['Expenses'])
 
            check_cell_balance(next(cells), balances['Equity'])
 
        else:
 
            check_cell_balance(
 
                next(cells), -sum(balances[key] for key in ['Expenses', 'Equity']),
 
            )
 
        check_cell_balance(next(cells), sum(balances[key] for key in [
 
            'opening', 'Income', 'Expenses', 'Equity:Realized',
 
            'opening', 'Income', 'Expenses', 'Equity',
 
        ]))
...
 
@@ -211,3 +221,3 @@ def check_ods_report(ods, start_date, stop_date):
 
        'Expenses': Decimal(0),
 
        'Equity:Realized': Decimal(0),
 
        'Equity': Decimal(0),
 
        'Assets:Receivable': Decimal(0),
...
 
@@ -224,4 +234,7 @@ def check_ods_report(ods, start_date, stop_date):
 
            for account, amount in amounts:
 
                if year < start_date.year and account.startswith(EQUITY_ROOT_ACCOUNTS):
 
                    acct_key = 'opening'
 
                if account.startswith(EQUITY_ROOT_ACCOUNTS):
 
                    if year < start_date.year:
 
                        acct_key = 'opening'
 
                    else:
 
                        acct_key, _, _ = account.partition(':')
 
                else:
0 comments (0 inline, 0 general)