From f9c4f85870a03722953e950ef27f01a44a911c4d Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 30 Jun 2004 02:09:42 -0400 Subject: fixes --- ledger.cc | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'ledger.cc') diff --git a/ledger.cc b/ledger.cc index 5f5326a4..4985fba6 100644 --- a/ledger.cc +++ b/ledger.cc @@ -447,21 +447,37 @@ void totals::print(std::ostream& out, int width) const } } -void totals::print_street(std::ostream& out, int width, std::time_t * when, - bool use_history, bool download) const +totals * totals::value() const +{ + totals * cost_basis = new totals; + + for (const_iterator i = amounts.begin(); i != amounts.end(); i++) { + if ((*i).second->is_zero()) + continue; + + amount * value = (*i).second->value(); + cost_basis->credit(value); + delete value; + } + + return cost_basis; +} + +totals * totals::street(std::time_t * when, bool use_history, + bool download) const { - totals street_balance; + totals * street_balance = new totals; for (const_iterator i = amounts.begin(); i != amounts.end(); i++) { if ((*i).second->is_zero()) continue; amount * street = (*i).second->street(when, use_history, download); - street_balance.credit(street); + street_balance->credit(street); delete street; } - street_balance.print(out, width); + return street_balance; } account::~account() -- cgit v1.2.3