ledger: Include balances for accounts without activity.

This commit is contained in:
Brett Smith 2020-07-17 10:56:12 -04:00
parent 4483d76999
commit e5aa63996a

View file

@ -252,17 +252,16 @@ class LedgerODS(core.BaseODS[data.Posting, data.Account]):
self.lock_first_row()
def _report_section_balance(self, key: data.Account, date_key: str) -> None:
uses_opening = key.is_under('Assets', 'Equity', 'Liabilities')
related = self.account_groups[key]
if date_key == 'start':
if not uses_opening:
if not key.keeps_balance():
return
date = self.date_range.start
balance = related.start_bal
description = "Opening Balance"
else:
date = self.date_range.stop
if uses_opening:
if key.keeps_balance():
balance = related.stop_bal
description = "Ending Balance"
else:
@ -358,7 +357,7 @@ class LedgerODS(core.BaseODS[data.Posting, data.Account]):
tally_by_account = {
account: count
for account, count in tally_by_account_iter
if count
if count or account.keeps_balance()
}
sheet_names = self.plan_sheets(
tally_by_account, self.required_sheet_names, self.sheet_size,
@ -370,7 +369,12 @@ class LedgerODS(core.BaseODS[data.Posting, data.Account]):
while using_sheet_index < sheet_index:
using_sheet_index += 1
self.start_sheet(sheet_names[using_sheet_index])
super().write(self.account_groups[account])
postings = self.account_groups[account]
if postings:
super().write(postings)
elif account.keeps_balance() and account.is_open_on_date(self.date_range.start):
self.start_section(account)
self.end_section(account)
for index in range(using_sheet_index + 1, len(sheet_names)):
self.start_sheet(sheet_names[index])