balance_sheet: Remove custom data normalizations.
These can be supported with rewrite rules now.
This commit is contained in:
parent
153361ce9f
commit
977b16e365
1 changed files with 4 additions and 11 deletions
|
@ -88,12 +88,6 @@ 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,
|
||||||
|
@ -134,20 +128,19 @@ class Balances:
|
||||||
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 = post.account.meta['classification']
|
||||||
if isinstance(classification_s, str):
|
if isinstance(classification_s, str):
|
||||||
classification = data.Account(classification_s)
|
classification = data.Account(classification_s)
|
||||||
else:
|
else:
|
||||||
raise TypeError()
|
raise TypeError()
|
||||||
except (KeyError, TypeError):
|
except (KeyError, TypeError):
|
||||||
classification = account
|
classification = post.account
|
||||||
if account.root_part() == 'Expenses':
|
if post.account.root_part() == 'Expenses':
|
||||||
post_type = post.meta.get('expense-type')
|
post_type = post.meta.get('expense-type')
|
||||||
else:
|
else:
|
||||||
post_type = None
|
post_type = None
|
||||||
key = BalanceKey(account, classification, period, fund, post_type)
|
key = BalanceKey(post.account, classification, period, fund, post_type)
|
||||||
self.balances[key] += post.at_cost()
|
self.balances[key] += post.at_cost()
|
||||||
|
|
||||||
def total(self,
|
def total(self,
|
||||||
|
|
Loading…
Reference in a new issue