data: Define EQUITY_ACCOUNTS and FUND_ACCOUNTS.
This commit is contained in:
parent
97dbce5b4c
commit
73bbc1e4ec
3 changed files with 18 additions and 23 deletions
|
@ -62,6 +62,17 @@ from .beancount_types import (
|
||||||
|
|
||||||
DecimalCompat = Union[decimal.Decimal, int]
|
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([
|
LINK_METADATA = frozenset([
|
||||||
'approval',
|
'approval',
|
||||||
'bank-statement',
|
'bank-statement',
|
||||||
|
|
|
@ -56,7 +56,6 @@ from .. import config as configmod
|
||||||
from .. import data
|
from .. import data
|
||||||
from .. import ranges
|
from .. import ranges
|
||||||
|
|
||||||
EQUITY_ACCOUNTS = frozenset(['Equity', 'Income', 'Expenses'])
|
|
||||||
PROGNAME = 'balance-sheet-report'
|
PROGNAME = 'balance-sheet-report'
|
||||||
logger = logging.getLogger('conservancy_beancount.reports.balance_sheet')
|
logger = logging.getLogger('conservancy_beancount.reports.balance_sheet')
|
||||||
|
|
||||||
|
@ -186,7 +185,7 @@ class Balances:
|
||||||
sort_period: Optional[int]=None,
|
sort_period: Optional[int]=None,
|
||||||
) -> Sequence[data.Account]:
|
) -> Sequence[data.Account]:
|
||||||
if sort_period is None:
|
if sort_period is None:
|
||||||
if account in EQUITY_ACCOUNTS:
|
if account in data.EQUITY_ACCOUNTS:
|
||||||
sort_period = Period.PERIOD
|
sort_period = Period.PERIOD
|
||||||
else:
|
else:
|
||||||
sort_period = Period.ANY
|
sort_period = Period.ANY
|
||||||
|
@ -399,7 +398,7 @@ class Report(core.BaseODS[Sequence[None], None]):
|
||||||
preposition = "Without" if fund is Fund.UNRESTRICTED else "With"
|
preposition = "Without" if fund is Fund.UNRESTRICTED else "With"
|
||||||
row = self.add_row(self.string_cell(f"{preposition} donor restrictions"))
|
row = self.add_row(self.string_cell(f"{preposition} donor restrictions"))
|
||||||
for kwargs, total_bal in zip(balance_kwargs, equity_totals):
|
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))
|
row.addElement(self.balance_cell(balance))
|
||||||
total_bal += balance
|
total_bal += balance
|
||||||
self.write_totals_row(
|
self.write_totals_row(
|
||||||
|
@ -500,7 +499,7 @@ class Report(core.BaseODS[Sequence[None], None]):
|
||||||
else:
|
else:
|
||||||
kwargs['period'] = Period.OPENING
|
kwargs['period'] = Period.OPENING
|
||||||
equity_totals = [
|
equity_totals = [
|
||||||
-self.balances.total(account=EQUITY_ACCOUNTS, **kwargs)
|
-self.balances.total(account=data.EQUITY_ACCOUNTS, **kwargs)
|
||||||
for kwargs in bal_kwargs
|
for kwargs in bal_kwargs
|
||||||
]
|
]
|
||||||
self.write_totals_row("Beginning Net Assets", equity_totals)
|
self.write_totals_row("Beginning Net Assets", equity_totals)
|
||||||
|
@ -544,7 +543,7 @@ class Report(core.BaseODS[Sequence[None], None]):
|
||||||
stylename=self.style_bold,
|
stylename=self.style_bold,
|
||||||
))
|
))
|
||||||
equity_totals = [
|
equity_totals = [
|
||||||
-self.balances.total(account=EQUITY_ACCOUNTS, **kwargs)
|
-self.balances.total(account=data.EQUITY_ACCOUNTS, **kwargs)
|
||||||
for kwargs in bal_kwargs
|
for kwargs in bal_kwargs
|
||||||
]
|
]
|
||||||
self.write_totals_row("Change in Net Assets", equity_totals, leading_rows=1)
|
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']:
|
for acct_root in ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity']:
|
||||||
norm_func = core.normalize_amount_func(f'{acct_root}:Dummy')
|
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()
|
self.add_row()
|
||||||
for account in self.balances.iter_accounts(acct_root):
|
for account in self.balances.iter_accounts(acct_root):
|
||||||
period_bal = self.balances.total(
|
period_bal = self.balances.total(
|
||||||
|
|
|
@ -70,21 +70,6 @@ from beancount.core.convert import get_cost
|
||||||
from beancount.core.inventory import Inventory
|
from beancount.core.inventory import Inventory
|
||||||
from beancount.core.position import Position, get_position
|
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')
|
RESTRICTED_ACCOUNT = data.Account('Equity:Funds:Restricted')
|
||||||
UNRESTRICTED_ACCOUNT = data.Account('Equity:Funds:Unrestricted')
|
UNRESTRICTED_ACCOUNT = data.Account('Equity:Funds:Unrestricted')
|
||||||
PROGNAME = 'opening-balances'
|
PROGNAME = 'opening-balances'
|
||||||
|
@ -206,8 +191,8 @@ def main(arglist: Optional[Sequence[str]]=None,
|
||||||
if post.meta.date >= args.as_of_date:
|
if post.meta.date >= args.as_of_date:
|
||||||
continue
|
continue
|
||||||
account = post.account
|
account = post.account
|
||||||
fund_acct_match = post.account.is_under(*FUND_ACCOUNTS)
|
fund_acct_match = post.account.is_under(*data.FUND_ACCOUNTS)
|
||||||
is_equity = account.root_part() in EQUITY_ACCOUNTS
|
is_equity = account.root_part() in data.EQUITY_ACCOUNTS
|
||||||
if fund_acct_match is None:
|
if fund_acct_match is None:
|
||||||
project: MetaValue = None
|
project: MetaValue = None
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue