summaryrefslogtreecommitdiff
path: root/format.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-08-07 22:09:14 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-08-07 22:09:14 -0400
commit84fe84bbd2185d3bd997a3ebac99417f99376cfb (patch)
tree1060009564c8f08788bc28d665846189c8e03181 /format.h
parent3bedc69b762dcf6e813eff51667d5c2dd62bc58b (diff)
downloadfork-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.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/format.h b/format.h
index 649bb190..3077b739 100644
--- a/format.h
+++ b/format.h
@@ -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