From dbc55008cb6587d6466bb48b939249cd0490c3f7 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 26 Sep 2004 00:57:15 -0400 Subject: [PATCH] finished balance reporting capability in main.py --- main.cc | 2 +- main.py | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/main.cc b/main.cc index b34078f0..94440eaf 100644 --- a/main.cc +++ b/main.cc @@ -305,9 +305,9 @@ int parse_and_report(int argc, char * argv[], char * envp[]) if (account_has_xdata(*journal->master)) { account_xdata_t& xdata = account_xdata(*journal->master); - xdata.value = xdata.total; if (xdata.dflags & ACCOUNT_TO_DISPLAY) { *out << "--------------------\n"; + xdata.value = xdata.total; acct_formatter.format.format(*out, details_t(*journal->master)); } } diff --git a/main.py b/main.py index ab7bca1e..0386b509 100755 --- a/main.py +++ b/main.py @@ -215,7 +215,7 @@ class FormatEntries (FormatTransactions): self.last_entry = xact.entry; -class FormatAccount (AccountHandler): +class FormatAccounts (AccountHandler): output = None def __init__ (self, fmt, pred): @@ -233,6 +233,14 @@ class FormatAccount (AccountHandler): if config.output_file: self.output.close () + def final (self, account): + if account_has_xdata(account): + xdata = account_xdata(account) + if xdata.dflags & ACCOUNT_TO_DISPLAY: + print "--------------------" + xdata.value = xdata.total + self.output.write(self.formatter.format(account)) + def flush (self): self.output.flush () @@ -369,13 +377,8 @@ if command == "b": acct_formatter = FormatAccounts (format, config.display_predicate) sum_accounts (journal.master) walk_accounts (journal.master, acct_formatter, config.sort_string) + acct_formatter.final (journal.master) acct_formatter.flush () - #if account_has_xdata(journal.master): - # account_xdata(journal.master).value = account_xdata(journal.master).total; - # - # if account_xdata(journal.master).dflags & ACCOUNT_TO_DISPLAY: - # print "--------------------" - # config.format.format(out, details_t(*journal->master)); elif command == "E": acct_formatter = FormatEquity (format, config.display_predicate)