balance_sheet: Normalize handling of release from restrictions.
This commit is contained in:
parent
bd33c04932
commit
3519933b8c
2 changed files with 13 additions and 13 deletions
|
@ -87,6 +87,12 @@ class BalanceKey(NamedTuple):
|
||||||
|
|
||||||
|
|
||||||
class Balances:
|
class Balances:
|
||||||
|
ACCOUNT_REWRITES: Mapping[str, data.Account] = {
|
||||||
|
# Normalize the chart of accounts from prior FYs to the current one.
|
||||||
|
'Expenses:CurrencyConversion': data.Account('Income:CurrencyConversion'),
|
||||||
|
'Income:Donations:Released': data.Account('Equity:Funds:Restricted'),
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
postings: Iterable[data.Posting],
|
postings: Iterable[data.Posting],
|
||||||
start_date: datetime.date,
|
start_date: datetime.date,
|
||||||
|
@ -123,14 +129,11 @@ class Balances:
|
||||||
period = Period.PRIOR
|
period = Period.PRIOR
|
||||||
else:
|
else:
|
||||||
period = Period.OPENING
|
period = Period.OPENING
|
||||||
if post.account == 'Expenses:CurrencyConversion':
|
|
||||||
account = data.Account('Income:CurrencyConversion')
|
|
||||||
else:
|
|
||||||
account = post.account
|
|
||||||
if post.meta.get(fund_key) == unrestricted_fund_value:
|
if post.meta.get(fund_key) == unrestricted_fund_value:
|
||||||
fund = Fund.UNRESTRICTED
|
fund = Fund.UNRESTRICTED
|
||||||
else:
|
else:
|
||||||
fund = Fund.RESTRICTED
|
fund = Fund.RESTRICTED
|
||||||
|
account = self.ACCOUNT_REWRITES.get(post.account, post.account)
|
||||||
try:
|
try:
|
||||||
classification_s = account.meta['classification']
|
classification_s = account.meta['classification']
|
||||||
if isinstance(classification_s, str):
|
if isinstance(classification_s, str):
|
||||||
|
@ -216,7 +219,6 @@ class Balances:
|
||||||
|
|
||||||
class Report(core.BaseODS[Sequence[None], None]):
|
class Report(core.BaseODS[Sequence[None], None]):
|
||||||
C_CASH = 'Cash'
|
C_CASH = 'Cash'
|
||||||
C_SATISFIED = 'Satisfaction of program restrictions'
|
|
||||||
NO_BALANCE = core.Balance()
|
NO_BALANCE = core.Balance()
|
||||||
SPACE = ' ' * 4
|
SPACE = ' ' * 4
|
||||||
|
|
||||||
|
@ -425,23 +427,21 @@ class Report(core.BaseODS[Sequence[None], None]):
|
||||||
|
|
||||||
self.add_row(self.string_cell("Support and Revenue", stylename=self.style_bold))
|
self.add_row(self.string_cell("Support and Revenue", stylename=self.style_bold))
|
||||||
self.add_row()
|
self.add_row()
|
||||||
income_totals = self.write_classifications_by_account(
|
income_totals = self.write_classifications_by_account('Income', bal_kwargs)
|
||||||
'Income', bal_kwargs, (self.C_SATISFIED,),
|
|
||||||
)
|
|
||||||
self.write_totals_row("", income_totals, stylename=self.style_subtotline)
|
self.write_totals_row("", income_totals, stylename=self.style_subtotline)
|
||||||
self.add_row()
|
self.add_row()
|
||||||
self.add_row(
|
self.add_row(
|
||||||
self.string_cell("Net Assets released from restrictions:"),
|
self.string_cell("Net Assets released from restrictions:"),
|
||||||
)
|
)
|
||||||
released = self.balances.total(
|
released = self.balances.total(
|
||||||
account='Expenses', period=Period.PERIOD, fund=Fund.RESTRICTED,
|
account=('Expenses', 'Equity'),
|
||||||
) - self.balances.total(
|
period=Period.PERIOD,
|
||||||
classification=self.C_SATISFIED, period=Period.PERIOD, fund=Fund.UNRESTRICTED,
|
fund=Fund.RESTRICTED,
|
||||||
)
|
)
|
||||||
other_totals = [core.MutableBalance() for _ in bal_kwargs]
|
other_totals = [core.MutableBalance() for _ in bal_kwargs]
|
||||||
other_totals[0] += released
|
other_totals[0] += released
|
||||||
other_totals[1] -= released
|
other_totals[1] -= released
|
||||||
self.write_totals_row(self.C_SATISFIED, other_totals)
|
self.write_totals_row("Satisfaction of program restrictions", other_totals)
|
||||||
self.write_totals_row(
|
self.write_totals_row(
|
||||||
"Total Support and Revenue",
|
"Total Support and Revenue",
|
||||||
income_totals, other_totals,
|
income_totals, other_totals,
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -5,7 +5,7 @@ from setuptools import setup
|
||||||
setup(
|
setup(
|
||||||
name='conservancy_beancount',
|
name='conservancy_beancount',
|
||||||
description="Plugin, library, and reports for reading Conservancy's books",
|
description="Plugin, library, and reports for reading Conservancy's books",
|
||||||
version='1.8.5',
|
version='1.8.6',
|
||||||
author='Software Freedom Conservancy',
|
author='Software Freedom Conservancy',
|
||||||
author_email='info@sfconservancy.org',
|
author_email='info@sfconservancy.org',
|
||||||
license='GNU AGPLv3+',
|
license='GNU AGPLv3+',
|
||||||
|
|
Loading…
Reference in a new issue