diff options
author | John Wiegley <johnw@newartisans.com> | 2004-08-07 22:09:14 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-08-07 22:09:14 -0400 |
commit | 84fe84bbd2185d3bd997a3ebac99417f99376cfb (patch) | |
tree | 1060009564c8f08788bc28d665846189c8e03181 /format.h | |
parent | 3bedc69b762dcf6e813eff51667d5c2dd62bc58b (diff) | |
download | fork-ledger-84fe84bbd2185d3bd997a3ebac99417f99376cfb.tar.gz fork-ledger-84fe84bbd2185d3bd997a3ebac99417f99376cfb.tar.bz2 fork-ledger-84fe84bbd2185d3bd997a3ebac99417f99376cfb.zip |
equity reports are restored
Diffstat (limited to 'format.h')
-rw-r--r-- | format.h | 44 |
1 files changed, 44 insertions, 0 deletions
@@ -207,6 +207,50 @@ class format_account const bool report_top = false) const; }; + +class format_equity +{ + std::ostream& output_stream; + const format_t& first_line_format; + const format_t& next_lines_format; + + item_predicate<account_t> disp_pred_functor; + + mutable balance_t total; + + public: + format_equity(std::ostream& _output_stream, + const format_t& _first_line_format, + const format_t& _next_lines_format, + const node_t * display_predicate = NULL) + : output_stream(_output_stream), + first_line_format(_first_line_format), + next_lines_format(_next_lines_format), + disp_pred_functor(display_predicate) { + entry_t header_entry; + header_entry.payee = "Opening Balances"; + header_entry.date = std::time(NULL); + first_line_format.format_elements(output_stream, details_t(&header_entry)); + } + + ~format_equity() { + account_t summary(NULL, "Equity:Opening Balances"); + summary.value = - total; + next_lines_format.format_elements(output_stream, details_t(&summary)); + } + + void operator()(account_t * account, + const unsigned int max_depth = 1, + const bool report_top = false) const { + if ((report_top || account->parent != NULL) && + disp_pred_functor(account)) { + next_lines_format.format_elements(output_stream, details_t(account)); + account->flags |= ACCOUNT_DISPLAYED; + total += account->value.quantity; + } + } +}; + } // namespace ledger #endif // _REPORT_H |