corrected the way that transaction handlers are flushed

This commit is contained in:
John Wiegley 2004-09-26 00:29:41 -04:00
parent 26de701a4e
commit c2c59d612b
2 changed files with 9 additions and 7 deletions

10
walk.cc
View file

@ -212,7 +212,7 @@ void changed_value_transactions::operator()(transaction_t& xact)
last_xact = &xact; last_xact = &xact;
} }
void subtotal_transactions::flush(const char * spec_fmt) void subtotal_transactions::report_subtotal(const char * spec_fmt)
{ {
char buf[256]; char buf[256];
@ -248,8 +248,6 @@ void subtotal_transactions::flush(const char * spec_fmt)
} }
balances.clear(); balances.clear();
item_handler<transaction_t>::flush();
} }
void subtotal_transactions::operator()(transaction_t& xact) void subtotal_transactions::operator()(transaction_t& xact)
@ -287,7 +285,7 @@ void interval_transactions::operator()(transaction_t& xact)
if (last_xact) { if (last_xact) {
start = interval.begin; start = interval.begin;
finish = quant; finish = quant;
flush(); report_subtotal();
} }
if (! interval.seconds) { if (! interval.seconds) {
@ -332,9 +330,11 @@ void dow_transactions::flush()
d != days_of_the_week[i].end(); d != days_of_the_week[i].end();
d++) d++)
subtotal_transactions::operator()(**d); subtotal_transactions::operator()(**d);
subtotal_transactions::flush("%As"); subtotal_transactions::report_subtotal("%As");
days_of_the_week[i].clear(); days_of_the_week[i].clear();
} }
subtotal_transactions::flush();
} }
void clear_transactions_xdata() void clear_transactions_xdata()

6
walk.h
View file

@ -332,10 +332,12 @@ class subtotal_transactions : public item_handler<transaction_t>
subtotal_transactions(item_handler<transaction_t> * handler) subtotal_transactions(item_handler<transaction_t> * handler)
: item_handler<transaction_t>(handler) {} : item_handler<transaction_t>(handler) {}
void flush(const char * spec_fmt); void report_subtotal(const char * spec_fmt = NULL);
virtual void flush() { virtual void flush() {
flush(NULL); if (balances.size() > 0)
report_subtotal();
item_handler<transaction_t>::flush();
} }
virtual void operator()(transaction_t& xact); virtual void operator()(transaction_t& xact);
}; };