diff --git a/conservancy_beancount/reports/ledger.py b/conservancy_beancount/reports/ledger.py index 57043d7854630ccf2239e65376ba45104a6ef639..02306da856cd88244e1a4225df3b85b2e569eee1 100644 --- a/conservancy_beancount/reports/ledger.py +++ b/conservancy_beancount/reports/ledger.py @@ -446,18 +446,20 @@ class LedgerODS(core.BaseODS[data.Posting, None]): for sheet_index, account in core.sort_and_filter_accounts( tally_by_account, sheet_names, ): - if not account.is_open_on_date(self.date_range.start): - continue while using_sheet_index < sheet_index: using_sheet_index += 1 self.start_sheet(sheet_names[using_sheet_index]) - self.norm_func = core.normalize_amount_func(account) postings = self.account_groups[account] - if postings: + # Accounts that aren't open can still have postings because of + # malformed input or rewrite rules. + if not (postings or account.is_open_on_date(self.date_range.start)): + continue + elif postings: totals_set = self.totals_with_entries else: totals_set = self.totals_without_entries want_totals = account.is_under(*totals_set) is not None + self.norm_func = core.normalize_amount_func(account) if postings or want_totals: self.write_header(account) if want_totals: