diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-16 01:14:23 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-16 01:14:23 -0400 |
commit | be208ef260998615d7bf59066e851b30d3164a33 (patch) | |
tree | 53bb0dee3afee791846b791689e06fe1ea1be839 /src/filters.cc | |
parent | f8681e482e10d4fcb6e53faf0bf658652457928f (diff) | |
download | fork-ledger-be208ef260998615d7bf59066e851b30d3164a33.tar.gz fork-ledger-be208ef260998615d7bf59066e851b30d3164a33.tar.bz2 fork-ledger-be208ef260998615d7bf59066e851b30d3164a33.zip |
Report collapsed xacts using earliest date
Diffstat (limited to 'src/filters.cc')
-rw-r--r-- | src/filters.cc | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/filters.cc b/src/filters.cc index c3007f01..57ab2e7c 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -293,21 +293,29 @@ void collapse_xacts::report_subtotal() else if (only_collapse_if_zero && ! subtotal.is_zero()) { foreach (xact_t * xact, component_xacts) item_handler<xact_t>::operator()(*xact); - component_xacts.clear(); } else { - if (only_collapse_if_zero) - component_xacts.clear(); + date_t earliest_date; + + foreach (xact_t * xact, component_xacts) { + date_t reported = xact->reported_date(); + if (! is_valid(earliest_date) || + reported < earliest_date) + earliest_date = reported; + } entry_temps.push_back(entry_t()); entry_t& entry = entry_temps.back(); - entry.payee = last_entry->payee; - entry._date = last_entry->_date; + entry.payee = last_entry->payee; + entry._date = (is_valid(earliest_date) ? + earliest_date : last_entry->_date); + DEBUG("filters.collapse", "Pseudo-entry date = " << *entry._date); - handle_value(subtotal, &totals_account, last_entry, 0, xact_temps, - *handler); + handle_value(subtotal, &totals_account, &entry, 0, xact_temps, *handler); } + component_xacts.clear(); + last_entry = NULL; last_xact = NULL; subtotal = 0L; @@ -325,8 +333,7 @@ void collapse_xacts::operator()(xact_t& xact) xact.add_to_value(subtotal, amount_expr); count++; - if (only_collapse_if_zero) - component_xacts.push_back(&xact); + component_xacts.push_back(&xact); last_entry = xact.entry; last_xact = &xact; |