(subtotal_transactions::operator()): Changed the usage of the
temporary `values' map so that account names are always properly sorted in the subtotaled output view. As it was, they were being reported in account creation order.
This commit is contained in:
parent
d83aa2f732
commit
ed8a236fe6
2 changed files with 20 additions and 7 deletions
13
walk.cc
13
walk.cc
|
|
@ -355,8 +355,8 @@ void subtotal_transactions::report_subtotal(const char * spec_fmt)
|
||||||
for (values_map::iterator i = values.begin();
|
for (values_map::iterator i = values.begin();
|
||||||
i != values.end();
|
i != values.end();
|
||||||
i++)
|
i++)
|
||||||
handle_value((*i).second, (*i).first, &entry, 0, xact_temps,
|
handle_value((*i).second.value, (*i).second.account, &entry, 0,
|
||||||
*handler, finish);
|
xact_temps, *handler, finish);
|
||||||
|
|
||||||
values.clear();
|
values.clear();
|
||||||
}
|
}
|
||||||
|
|
@ -368,13 +368,16 @@ void subtotal_transactions::operator()(transaction_t& xact)
|
||||||
if (! finish || std::difftime(xact.entry->date, finish) > 0)
|
if (! finish || std::difftime(xact.entry->date, finish) > 0)
|
||||||
finish = xact.entry->date;
|
finish = xact.entry->date;
|
||||||
|
|
||||||
values_map::iterator i = values.find(xact.account);
|
account_t * acct = xact.account;
|
||||||
|
assert(acct);
|
||||||
|
|
||||||
|
values_map::iterator i = values.find(acct->fullname());
|
||||||
if (i == values.end()) {
|
if (i == values.end()) {
|
||||||
value_t temp;
|
value_t temp;
|
||||||
add_transaction_to(xact, temp);
|
add_transaction_to(xact, temp);
|
||||||
values.insert(values_pair(xact.account, temp));
|
values.insert(values_pair(acct->fullname(), acct_value_t(acct, temp)));
|
||||||
} else {
|
} else {
|
||||||
add_transaction_to(xact, (*i).second);
|
add_transaction_to(xact, (*i).second.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the account for this transaction is all virtual, mark it as
|
// If the account for this transaction is all virtual, mark it as
|
||||||
|
|
|
||||||
14
walk.h
14
walk.h
|
|
@ -367,8 +367,18 @@ class changed_value_transactions : public item_handler<transaction_t>
|
||||||
|
|
||||||
class subtotal_transactions : public item_handler<transaction_t>
|
class subtotal_transactions : public item_handler<transaction_t>
|
||||||
{
|
{
|
||||||
typedef std::map<account_t *, value_t> values_map;
|
struct acct_value_t {
|
||||||
typedef std::pair<account_t *, value_t> values_pair;
|
account_t * account;
|
||||||
|
value_t value;
|
||||||
|
|
||||||
|
acct_value_t(account_t * a) : account(a) {}
|
||||||
|
acct_value_t(account_t * a, value_t& v) : account(a), value(v) {}
|
||||||
|
acct_value_t(const acct_value_t& av)
|
||||||
|
: account(av.account), value(av.value) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::map<std::string, acct_value_t> values_map;
|
||||||
|
typedef std::pair<std::string, acct_value_t> values_pair;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
values_map values;
|
values_map values;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue