first implementation of --depth for register
This commit is contained in:
parent
71f1adad64
commit
a2d29dda5f
2 changed files with 29 additions and 29 deletions
|
|
@ -449,9 +449,9 @@ void collapse_posts::report_subtotal()
|
||||||
DEBUG("filters.collapse", "earliest date = " << earliest_date);
|
DEBUG("filters.collapse", "earliest date = " << earliest_date);
|
||||||
DEBUG("filters.collapse", "latest date = " << latest_date);
|
DEBUG("filters.collapse", "latest date = " << latest_date);
|
||||||
|
|
||||||
foreach (post_t * post, component_posts) {
|
foreach (totals_map::value_type& pat, totals) {
|
||||||
handle_value(/* value= */ subtotal,
|
handle_value(/* value= */ pat.second,
|
||||||
/* account= */ find_totals_account(post->account),
|
/* account= */ &temps.create_account(pat.first),
|
||||||
/* xact= */ &xact,
|
/* xact= */ &xact,
|
||||||
/* temps= */ temps,
|
/* temps= */ temps,
|
||||||
/* handler= */ handler,
|
/* handler= */ handler,
|
||||||
|
|
@ -461,6 +461,7 @@ void collapse_posts::report_subtotal()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
totals.clear();
|
||||||
component_posts.clear();
|
component_posts.clear();
|
||||||
|
|
||||||
last_xact = NULL;
|
last_xact = NULL;
|
||||||
|
|
@ -469,19 +470,14 @@ void collapse_posts::report_subtotal()
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
account_t* collapse_posts::find_totals_account(account_t* account)
|
value_t& collapse_posts::find_totals(account_t* account)
|
||||||
{
|
{
|
||||||
unsigned short depth=2;
|
unsigned short depth=3;
|
||||||
if(account->depth==depth)
|
if(account->depth==depth)
|
||||||
{
|
return totals[account->fullname()];
|
||||||
string name=account->fullname();
|
|
||||||
account_t*& acc = totals_accounts[name];
|
//else recurse
|
||||||
if(acc==NULL)
|
return find_totals(account->parent);
|
||||||
acc= &temps.create_account(name);
|
|
||||||
return acc;
|
|
||||||
}
|
|
||||||
//recurse
|
|
||||||
return find_totals_account(account->parent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void collapse_posts::operator()(post_t& post)
|
void collapse_posts::operator()(post_t& post)
|
||||||
|
|
@ -493,6 +489,7 @@ void collapse_posts::operator()(post_t& post)
|
||||||
report_subtotal();
|
report_subtotal();
|
||||||
|
|
||||||
post.add_to_value(subtotal, amount_expr);
|
post.add_to_value(subtotal, amount_expr);
|
||||||
|
post.add_to_value(find_totals(post.account), amount_expr);
|
||||||
|
|
||||||
component_posts.push_back(&post);
|
component_posts.push_back(&post);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -421,18 +421,21 @@ public:
|
||||||
|
|
||||||
class collapse_posts : public item_handler<post_t>
|
class collapse_posts : public item_handler<post_t>
|
||||||
{
|
{
|
||||||
expr_t& amount_expr;
|
|
||||||
predicate_t display_predicate;
|
typedef std::map<string,value_t> totals_map;
|
||||||
predicate_t only_predicate;
|
|
||||||
value_t subtotal;
|
expr_t& amount_expr;
|
||||||
std::size_t count;
|
predicate_t display_predicate;
|
||||||
xact_t * last_xact;
|
predicate_t only_predicate;
|
||||||
post_t * last_post;
|
value_t subtotal;
|
||||||
temporaries_t temps;
|
std::size_t count;
|
||||||
std::map<string,account_t *> totals_accounts;
|
xact_t * last_xact;
|
||||||
bool only_collapse_if_zero;
|
post_t * last_post;
|
||||||
std::list<post_t *> component_posts;
|
temporaries_t temps;
|
||||||
report_t& report;
|
totals_map totals;
|
||||||
|
bool only_collapse_if_zero;
|
||||||
|
std::list<post_t *> component_posts;
|
||||||
|
report_t& report;
|
||||||
|
|
||||||
collapse_posts();
|
collapse_posts();
|
||||||
|
|
||||||
|
|
@ -454,7 +457,7 @@ public:
|
||||||
TRACE_DTOR(collapse_posts);
|
TRACE_DTOR(collapse_posts);
|
||||||
handler.reset();
|
handler.reset();
|
||||||
}
|
}
|
||||||
account_t* find_totals_account(account_t* account);
|
value_t& find_totals(account_t* account);
|
||||||
|
|
||||||
virtual void flush() {
|
virtual void flush() {
|
||||||
report_subtotal();
|
report_subtotal();
|
||||||
|
|
@ -476,7 +479,7 @@ public:
|
||||||
last_post = NULL;
|
last_post = NULL;
|
||||||
|
|
||||||
temps.clear();
|
temps.clear();
|
||||||
totals_accounts.clear();
|
totals.clear();
|
||||||
component_posts.clear();
|
component_posts.clear();
|
||||||
|
|
||||||
item_handler<post_t>::clear();
|
item_handler<post_t>::clear();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue