diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/account.cc | 9 | ||||
-rw-r--r-- | src/filters.cc | 10 | ||||
-rw-r--r-- | src/filters.h | 12 | ||||
-rw-r--r-- | src/report.cc | 4 | ||||
-rw-r--r-- | src/value.cc | 2 |
5 files changed, 24 insertions, 13 deletions
diff --git a/src/account.cc b/src/account.cc index 6c1f81a0..f613d983 100644 --- a/src/account.cc +++ b/src/account.cc @@ -219,8 +219,13 @@ void account_t::calculate_sums() (*pair.second).calculate_sums(); xdata_t& child_xd((*pair.second).xdata()); - add_or_set_value(xd.total, child_xd.total); - xd.total_count += child_xd.total_count + child_xd.count; + if (! child_xd.total.is_null()) { + add_or_set_value(xd.total, child_xd.total); + xd.total_count += child_xd.total_count + child_xd.count; + } else { + assert(child_xd.total_count == 0); + assert(child_xd.count == 0); + } } call_scope_t args(*this); diff --git a/src/filters.cc b/src/filters.cc index f9115c37..03063264 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -739,14 +739,16 @@ void forecast_xacts::flush() item_handler<xact_t>::flush(); } -pass_down_accounts::pass_down_accounts(acct_handler_ptr handler, - accounts_iterator& iter) - : item_handler<account_t>(handler) +pass_down_accounts::pass_down_accounts(acct_handler_ptr handler, + accounts_iterator& iter, + const expr_t& predicate) + : item_handler<account_t>(handler), pred(predicate) { TRACE_CTOR(pass_down_accounts, "acct_handler_ptr, accounts_iterator"); for (account_t * account = iter(); account; account = iter()) - item_handler<account_t>::operator()(*account); + if (pred(*account)) + item_handler<account_t>::operator()(*account); } } // namespace ledger diff --git a/src/filters.h b/src/filters.h index 093f2de7..eda50732 100644 --- a/src/filters.h +++ b/src/filters.h @@ -651,13 +651,11 @@ class forecast_xacts : public generate_xacts item_predicate<xact_t> pred; public: - forecast_xacts(xact_handler_ptr handler, - const expr_t& predicate) + forecast_xacts(xact_handler_ptr handler, const expr_t& predicate) : generate_xacts(handler), pred(predicate) { TRACE_CTOR(forecast_xacts, "xact_handler_ptr, const expr_t&"); } - forecast_xacts(xact_handler_ptr handler, - const string& predicate) + forecast_xacts(xact_handler_ptr handler, const string& predicate) : generate_xacts(handler), pred(predicate) { TRACE_CTOR(forecast_xacts, "xact_handler_ptr, const string&"); } @@ -689,8 +687,12 @@ class pass_down_accounts : public item_handler<account_t> { pass_down_accounts(); + item_predicate<account_t> pred; + public: - pass_down_accounts(acct_handler_ptr handler, accounts_iterator& iter); + pass_down_accounts(acct_handler_ptr handler, + accounts_iterator& iter, + const expr_t& predicate = expr_t()); virtual ~pass_down_accounts() { TRACE_DTOR(pass_down_accounts); diff --git a/src/report.cc b/src/report.cc index 03b519ab..360b7685 100644 --- a/src/report.cc +++ b/src/report.cc @@ -336,10 +336,10 @@ void report_t::accounts_report(acct_handler_ptr handler) if (sort_string.empty()) { basic_accounts_iterator walker(*session.master); - pass_down_accounts(handler, walker); + pass_down_accounts(handler, walker, expr_t("total")); } else { sorted_accounts_iterator walker(*session.master, sort_string); - pass_down_accounts(handler, walker); + pass_down_accounts(handler, walker, expr_t("total")); } handler->flush(); diff --git a/src/value.cc b/src/value.cc index 16d114ca..09b43cbf 100644 --- a/src/value.cc +++ b/src/value.cc @@ -185,6 +185,8 @@ void value_t::_dup() value_t::operator bool() const { switch (type()) { + case VOID: + return false; case BOOLEAN: return as_boolean(); case DATETIME: |