Switched from using POST_AUTO to ITEM_GENERATED
This commit is contained in:
parent
cb751913ef
commit
625b94cf04
5 changed files with 19 additions and 17 deletions
|
|
@ -351,7 +351,7 @@ void related_posts::flush()
|
||||||
post_t::xdata_t& xdata(r_post->xdata());
|
post_t::xdata_t& xdata(r_post->xdata());
|
||||||
if (! xdata.has_flags(POST_EXT_HANDLED) &&
|
if (! xdata.has_flags(POST_EXT_HANDLED) &&
|
||||||
(! xdata.has_flags(POST_EXT_RECEIVED) ?
|
(! xdata.has_flags(POST_EXT_RECEIVED) ?
|
||||||
! r_post->has_flags(POST_AUTO | POST_VIRTUAL) :
|
! r_post->has_flags(ITEM_GENERATED | POST_VIRTUAL) :
|
||||||
also_matching)) {
|
also_matching)) {
|
||||||
xdata.add_flags(POST_EXT_HANDLED);
|
xdata.add_flags(POST_EXT_HANDLED);
|
||||||
item_handler<post_t>::operator()(*r_post);
|
item_handler<post_t>::operator()(*r_post);
|
||||||
|
|
@ -363,7 +363,7 @@ void related_posts::flush()
|
||||||
// output auto or period xacts.
|
// output auto or period xacts.
|
||||||
post_t::xdata_t& xdata(post->xdata());
|
post_t::xdata_t& xdata(post->xdata());
|
||||||
if (! xdata.has_flags(POST_EXT_HANDLED) &&
|
if (! xdata.has_flags(POST_EXT_HANDLED) &&
|
||||||
! post->has_flags(POST_AUTO)) {
|
! post->has_flags(ITEM_GENERATED)) {
|
||||||
xdata.add_flags(POST_EXT_HANDLED);
|
xdata.add_flags(POST_EXT_HANDLED);
|
||||||
item_handler<post_t>::operator()(*post);
|
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_temps.push_back(post);
|
||||||
post_t& temp = post_temps.back();
|
post_t& temp = post_temps.back();
|
||||||
temp.xact = &xact;
|
temp.xact = &xact;
|
||||||
temp.add_flags(POST_AUTO | ITEM_TEMP);
|
temp.add_flags(ITEM_TEMP);
|
||||||
temp.amount.in_place_negate();
|
temp.amount.in_place_negate();
|
||||||
xact.add_post(&temp);
|
xact.add_post(&temp);
|
||||||
|
|
||||||
|
|
@ -808,7 +808,7 @@ void forecast_posts::flush()
|
||||||
post_temps.push_back(post);
|
post_temps.push_back(post);
|
||||||
post_t& temp = post_temps.back();
|
post_t& temp = post_temps.back();
|
||||||
temp.xact = &xact;
|
temp.xact = &xact;
|
||||||
temp.add_flags(POST_AUTO | ITEM_TEMP);
|
temp.add_flags(ITEM_TEMP);
|
||||||
xact.add_post(&temp);
|
xact.add_post(&temp);
|
||||||
|
|
||||||
date_t next = (*least).first.increment(begin);
|
date_t next = (*least).first.increment(begin);
|
||||||
|
|
|
||||||
12
src/item.cc
12
src/item.cc
|
|
@ -180,6 +180,10 @@ namespace {
|
||||||
return item.state() == item_t::PENDING;
|
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) {
|
value_t get_date(item_t& item) {
|
||||||
return item.date();
|
return item.date();
|
||||||
}
|
}
|
||||||
|
|
@ -196,8 +200,7 @@ namespace {
|
||||||
else if (args[0].is_mask())
|
else if (args[0].is_mask())
|
||||||
return item.has_tag(args[0].as_mask());
|
return item.has_tag(args[0].as_mask());
|
||||||
} else {
|
} else {
|
||||||
return item.has_tag(args[0].to_mask(),
|
return item.has_tag(args[0].to_mask(), args[1].to_mask());
|
||||||
args[1].to_mask());
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -265,6 +268,11 @@ value_t get_comment(item_t& item)
|
||||||
expr_t::ptr_op_t item_t::lookup(const string& name)
|
expr_t::ptr_op_t item_t::lookup(const string& name)
|
||||||
{
|
{
|
||||||
switch (name[0]) {
|
switch (name[0]) {
|
||||||
|
case 'a':
|
||||||
|
if (name == "actual")
|
||||||
|
return WRAP_FUNCTOR(get_wrapper<&get_actual>);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
if (name == "beg_line")
|
if (name == "beg_line")
|
||||||
return WRAP_FUNCTOR(get_wrapper<&get_beg_line>);
|
return WRAP_FUNCTOR(get_wrapper<&get_beg_line>);
|
||||||
|
|
|
||||||
|
|
@ -130,10 +130,6 @@ namespace {
|
||||||
return ! post.has_flags(POST_VIRTUAL);
|
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) {
|
value_t get_xact(post_t& post) {
|
||||||
return value_t(static_cast<scope_t *>(post.xact));
|
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);
|
return WRAP_FUNCTOR(get_account);
|
||||||
else if (name == "account_base")
|
else if (name == "account_base")
|
||||||
return WRAP_FUNCTOR(get_wrapper<&get_account_base>);
|
return WRAP_FUNCTOR(get_wrapper<&get_account_base>);
|
||||||
else if (name == "actual")
|
|
||||||
return WRAP_FUNCTOR(get_wrapper<&get_actual>);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
|
|
|
||||||
|
|
@ -65,9 +65,8 @@ class post_t : public item_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
#define POST_VIRTUAL 0x10 // the account was specified with (parens)
|
#define POST_VIRTUAL 0x10 // the account was specified with (parens)
|
||||||
#define POST_MUST_BALANCE 0x20 // the account was specified with [brackets]
|
#define POST_MUST_BALANCE 0x20 // posting must balance in the transaction
|
||||||
#define POST_AUTO 0x40 // posting created by automated xact
|
#define POST_CALCULATED 0x40 // posting's amount was calculated
|
||||||
#define POST_CALCULATED 0x80 // posting's amount was auto-calculated
|
|
||||||
|
|
||||||
xact_t * xact; // only set for posts of regular xacts
|
xact_t * xact; // only set for posts of regular xacts
|
||||||
account_t * account;
|
account_t * account;
|
||||||
|
|
|
||||||
|
|
@ -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());
|
posts_list initial_posts(xact.posts.begin(), xact.posts.end());
|
||||||
|
|
||||||
foreach (post_t * initial_post, initial_posts) {
|
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) {
|
foreach (post_t * post, posts) {
|
||||||
amount_t amt;
|
amount_t amt;
|
||||||
assert(post->amount);
|
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.
|
// the automated xact's one.
|
||||||
post_t * new_post = new post_t(account, amt);
|
post_t * new_post = new post_t(account, amt);
|
||||||
new_post->copy_details(*post);
|
new_post->copy_details(*post);
|
||||||
new_post->add_flags(POST_AUTO);
|
new_post->add_flags(ITEM_GENERATED);
|
||||||
|
|
||||||
xact.add_post(new_post);
|
xact.add_post(new_post);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue