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:
|
||||
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,
|
||||
postings: Iterable[data.Posting],
|
||||
start_date: datetime.date,
|
||||
|
@ -134,20 +128,19 @@ class Balances:
|
|||
fund = Fund.UNRESTRICTED
|
||||
else:
|
||||
fund = Fund.RESTRICTED
|
||||
account = self.ACCOUNT_REWRITES.get(post.account, post.account)
|
||||
try:
|
||||
classification_s = account.meta['classification']
|
||||
classification_s = post.account.meta['classification']
|
||||
if isinstance(classification_s, str):
|
||||
classification = data.Account(classification_s)
|
||||
else:
|
||||
raise TypeError()
|
||||
except (KeyError, TypeError):
|
||||
classification = account
|
||||
if account.root_part() == 'Expenses':
|
||||
classification = post.account
|
||||
if post.account.root_part() == 'Expenses':
|
||||
post_type = post.meta.get('expense-type')
|
||||
else:
|
||||
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()
|
||||
|
||||
def total(self,
|
||||
|
|
Loading…
Reference in a new issue