From 977b16e365ec2de4a308f9c5b51e1858cb9487f2 Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Sat, 29 Aug 2020 17:18:38 -0400 Subject: [PATCH] balance_sheet: Remove custom data normalizations. These can be supported with rewrite rules now. --- conservancy_beancount/reports/balance_sheet.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/conservancy_beancount/reports/balance_sheet.py b/conservancy_beancount/reports/balance_sheet.py index d7b7a3c..61d1f1b 100644 --- a/conservancy_beancount/reports/balance_sheet.py +++ b/conservancy_beancount/reports/balance_sheet.py @@ -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,