Changeset - 73bbc1e4ec8a
[Not reviewed]
0 3 0
Brett Smith - 4 years ago 2020-10-16 14:05:23
brettcsmith@brettcsmith.org
data: Define EQUITY_ACCOUNTS and FUND_ACCOUNTS.
3 files changed with 18 insertions and 23 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/data.py
Show inline comments
...
 
@@ -62,6 +62,17 @@ from .beancount_types import (
 

	
 
DecimalCompat = Union[decimal.Decimal, int]
 

	
 
EQUITY_ACCOUNTS = frozenset([
 
    'Equity',
 
    'Expenses',
 
    'Income',
 
])
 
FUND_ACCOUNTS = EQUITY_ACCOUNTS | frozenset([
 
    'Assets:Prepaid',
 
    'Assets:Receivable',
 
    'Liabilities:Payable',
 
    'Liabilities:UnearnedIncome',
 
])
 
LINK_METADATA = frozenset([
 
    'approval',
 
    'bank-statement',
conservancy_beancount/reports/balance_sheet.py
Show inline comments
...
 
@@ -56,7 +56,6 @@ from .. import config as configmod
 
from .. import data
 
from .. import ranges
 

	
 
EQUITY_ACCOUNTS = frozenset(['Equity', 'Income', 'Expenses'])
 
PROGNAME = 'balance-sheet-report'
 
logger = logging.getLogger('conservancy_beancount.reports.balance_sheet')
 

	
...
 
@@ -186,7 +185,7 @@ class Balances:
 
                        sort_period: Optional[int]=None,
 
    ) -> Sequence[data.Account]:
 
        if sort_period is None:
 
            if account in EQUITY_ACCOUNTS:
 
            if account in data.EQUITY_ACCOUNTS:
 
                sort_period = Period.PERIOD
 
            else:
 
                sort_period = Period.ANY
...
 
@@ -399,7 +398,7 @@ class Report(core.BaseODS[Sequence[None], None]):
 
            preposition = "Without" if fund is Fund.UNRESTRICTED else "With"
 
            row = self.add_row(self.string_cell(f"{preposition} donor restrictions"))
 
            for kwargs, total_bal in zip(balance_kwargs, equity_totals):
 
                balance = -self.balances.total(account=EQUITY_ACCOUNTS, fund=fund, **kwargs)
 
                balance = -self.balances.total(account=data.EQUITY_ACCOUNTS, fund=fund, **kwargs)
 
                row.addElement(self.balance_cell(balance))
 
                total_bal += balance
 
        self.write_totals_row(
...
 
@@ -500,7 +499,7 @@ class Report(core.BaseODS[Sequence[None], None]):
 
            else:
 
                kwargs['period'] = Period.OPENING
 
        equity_totals = [
 
            -self.balances.total(account=EQUITY_ACCOUNTS, **kwargs)
 
            -self.balances.total(account=data.EQUITY_ACCOUNTS, **kwargs)
 
            for kwargs in bal_kwargs
 
        ]
 
        self.write_totals_row("Beginning Net Assets", equity_totals)
...
 
@@ -544,7 +543,7 @@ class Report(core.BaseODS[Sequence[None], None]):
 
            stylename=self.style_bold,
 
        ))
 
        equity_totals = [
 
            -self.balances.total(account=EQUITY_ACCOUNTS, **kwargs)
 
            -self.balances.total(account=data.EQUITY_ACCOUNTS, **kwargs)
 
            for kwargs in bal_kwargs
 
        ]
 
        self.write_totals_row("Change in Net Assets", equity_totals, leading_rows=1)
...
 
@@ -605,7 +604,7 @@ class Report(core.BaseODS[Sequence[None], None]):
 

	
 
        for acct_root in ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity']:
 
            norm_func = core.normalize_amount_func(f'{acct_root}:Dummy')
 
            want_balance = acct_root not in EQUITY_ACCOUNTS
 
            want_balance = acct_root not in data.EQUITY_ACCOUNTS
 
            self.add_row()
 
            for account in self.balances.iter_accounts(acct_root):
 
                period_bal = self.balances.total(
conservancy_beancount/tools/opening_balances.py
Show inline comments
...
 
@@ -70,21 +70,6 @@ from beancount.core.convert import get_cost
 
from beancount.core.inventory import Inventory
 
from beancount.core.position import Position, get_position
 

	
 
EQUITY_ACCOUNTS = frozenset([
 
    'Equity',
 
    'Expenses',
 
    'Income',
 
])
 
FUND_ACCOUNTS = frozenset([
 
    'Assets:Prepaid',
 
    'Assets:Receivable',
 
    'Equity:Funds',
 
    'Equity:Realized',
 
    'Expenses',
 
    'Income',
 
    'Liabilities:Payable',
 
    'Liabilities:UnearnedIncome',
 
])
 
RESTRICTED_ACCOUNT = data.Account('Equity:Funds:Restricted')
 
UNRESTRICTED_ACCOUNT = data.Account('Equity:Funds:Unrestricted')
 
PROGNAME = 'opening-balances'
...
 
@@ -206,8 +191,8 @@ def main(arglist: Optional[Sequence[str]]=None,
 
        if post.meta.date >= args.as_of_date:
 
            continue
 
        account = post.account
 
        fund_acct_match = post.account.is_under(*FUND_ACCOUNTS)
 
        is_equity = account.root_part() in EQUITY_ACCOUNTS
 
        fund_acct_match = post.account.is_under(*data.FUND_ACCOUNTS)
 
        is_equity = account.root_part() in data.EQUITY_ACCOUNTS
 
        if fund_acct_match is None:
 
            project: MetaValue = None
 
        else:
0 comments (0 inline, 0 general)