Switched from using POST_AUTO to ITEM_GENERATED

This commit is contained in:
John Wiegley 2009-02-24 02:23:20 -04:00
parent cb751913ef
commit 625b94cf04
5 changed files with 19 additions and 17 deletions

View file

@ -351,7 +351,7 @@ void related_posts::flush()
post_t::xdata_t& xdata(r_post->xdata());
if (! xdata.has_flags(POST_EXT_HANDLED) &&
(! xdata.has_flags(POST_EXT_RECEIVED) ?
! r_post->has_flags(POST_AUTO | POST_VIRTUAL) :
! r_post->has_flags(ITEM_GENERATED | POST_VIRTUAL) :
also_matching)) {
xdata.add_flags(POST_EXT_HANDLED);
item_handler<post_t>::operator()(*r_post);
@ -363,7 +363,7 @@ void related_posts::flush()
// output auto or period xacts.
post_t::xdata_t& xdata(post->xdata());
if (! xdata.has_flags(POST_EXT_HANDLED) &&
! post->has_flags(POST_AUTO)) {
! post->has_flags(ITEM_GENERATED)) {
xdata.add_flags(POST_EXT_HANDLED);
item_handler<post_t>::operator()(*post);
}
@ -720,7 +720,7 @@ void budget_posts::report_budget_items(const date_t& date)
post_temps.push_back(post);
post_t& temp = post_temps.back();
temp.xact = &xact;
temp.add_flags(POST_AUTO | ITEM_TEMP);
temp.add_flags(ITEM_TEMP);
temp.amount.in_place_negate();
xact.add_post(&temp);
@ -808,7 +808,7 @@ void forecast_posts::flush()
post_temps.push_back(post);
post_t& temp = post_temps.back();
temp.xact = &xact;
temp.add_flags(POST_AUTO | ITEM_TEMP);
temp.add_flags(ITEM_TEMP);
xact.add_post(&temp);
date_t next = (*least).first.increment(begin);

View file

@ -180,6 +180,10 @@ namespace {
return item.state() == item_t::PENDING;
}
value_t get_actual(item_t& item) {
return ! item.has_flags(ITEM_GENERATED);
}
value_t get_date(item_t& item) {
return item.date();
}
@ -196,8 +200,7 @@ namespace {
else if (args[0].is_mask())
return item.has_tag(args[0].as_mask());
} else {
return item.has_tag(args[0].to_mask(),
args[1].to_mask());
return item.has_tag(args[0].to_mask(), args[1].to_mask());
}
return false;
}
@ -265,6 +268,11 @@ value_t get_comment(item_t& item)
expr_t::ptr_op_t item_t::lookup(const string& name)
{
switch (name[0]) {
case 'a':
if (name == "actual")
return WRAP_FUNCTOR(get_wrapper<&get_actual>);
break;
case 'b':
if (name == "beg_line")
return WRAP_FUNCTOR(get_wrapper<&get_beg_line>);

View file

@ -130,10 +130,6 @@ namespace {
return ! post.has_flags(POST_VIRTUAL);
}
value_t get_actual(post_t& post) {
return ! post.has_flags(POST_AUTO);
}
value_t get_xact(post_t& post) {
return value_t(static_cast<scope_t *>(post.xact));
}
@ -234,8 +230,6 @@ expr_t::ptr_op_t post_t::lookup(const string& name)
return WRAP_FUNCTOR(get_account);
else if (name == "account_base")
return WRAP_FUNCTOR(get_wrapper<&get_account_base>);
else if (name == "actual")
return WRAP_FUNCTOR(get_wrapper<&get_actual>);
break;
case 'c':

View file

@ -65,9 +65,8 @@ class post_t : public item_t
{
public:
#define POST_VIRTUAL 0x10 // the account was specified with (parens)
#define POST_MUST_BALANCE 0x20 // the account was specified with [brackets]
#define POST_AUTO 0x40 // posting created by automated xact
#define POST_CALCULATED 0x80 // posting's amount was auto-calculated
#define POST_MUST_BALANCE 0x20 // posting must balance in the transaction
#define POST_CALCULATED 0x40 // posting's amount was calculated
xact_t * xact; // only set for posts of regular xacts
account_t * account;

View file

@ -362,7 +362,8 @@ void auto_xact_t::extend_xact(xact_base_t& xact, bool post_handler)
posts_list initial_posts(xact.posts.begin(), xact.posts.end());
foreach (post_t * initial_post, initial_posts) {
if (! initial_post->has_flags(POST_AUTO) && predicate(*initial_post)) {
if (! initial_post->has_flags(ITEM_GENERATED) &&
predicate(*initial_post)) {
foreach (post_t * post, posts) {
amount_t amt;
assert(post->amount);
@ -408,7 +409,7 @@ void auto_xact_t::extend_xact(xact_base_t& xact, bool post_handler)
// the automated xact's one.
post_t * new_post = new post_t(account, amt);
new_post->copy_details(*post);
new_post->add_flags(POST_AUTO);
new_post->add_flags(ITEM_GENERATED);
xact.add_post(new_post);
}