summaryrefslogtreecommitdiff
path: root/src/filters.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/filters.cc')
-rw-r--r--src/filters.cc586
1 files changed, 293 insertions, 293 deletions
diff --git a/src/filters.cc b/src/filters.cc
index e0c67024..ade349bd 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -37,46 +37,46 @@
namespace ledger {
-pass_down_xacts::pass_down_xacts(xact_handler_ptr handler,
- xacts_iterator& iter)
- : item_handler<xact_t>(handler)
+pass_down_posts::pass_down_posts(post_handler_ptr handler,
+ posts_iterator& iter)
+ : item_handler<post_t>(handler)
{
- TRACE_CTOR(pass_down_xacts, "xact_handler_ptr, xacts_iterator");
+ TRACE_CTOR(pass_down_posts, "post_handler_ptr, posts_iterator");
- for (xact_t * xact = iter(); xact; xact = iter()) {
+ for (post_t * post = iter(); post; post = iter()) {
try {
- item_handler<xact_t>::operator()(*xact);
+ item_handler<post_t>::operator()(*post);
}
catch (const std::exception& err) {
- add_error_context(item_context(*xact, "While handling transaction"));
+ add_error_context(item_context(*post, "While handling posting"));
throw;
}
}
- item_handler<xact_t>::flush();
+ item_handler<post_t>::flush();
}
-void truncate_entries::flush()
+void truncate_xacts::flush()
{
- if (! xacts.size())
+ if (! posts.size())
return;
- entry_t * last_entry = (*xacts.begin())->entry;
+ xact_t * last_xact = (*posts.begin())->xact;
int l = 0;
- foreach (xact_t * xact, xacts)
- if (last_entry != xact->entry) {
+ foreach (post_t * post, posts)
+ if (last_xact != post->xact) {
l++;
- last_entry = xact->entry;
+ last_xact = post->xact;
}
l++;
- last_entry = (*xacts.begin())->entry;
+ last_xact = (*posts.begin())->xact;
int i = 0;
- foreach (xact_t * xact, xacts) {
- if (last_entry != xact->entry) {
- last_entry = xact->entry;
+ foreach (post_t * post, posts) {
+ if (last_xact != post->xact) {
+ last_xact = post->xact;
i++;
}
@@ -96,44 +96,44 @@ void truncate_entries::flush()
}
if (print)
- item_handler<xact_t>::operator()(*xact);
+ item_handler<post_t>::operator()(*post);
}
- xacts.clear();
+ posts.clear();
- item_handler<xact_t>::flush();
+ item_handler<post_t>::flush();
}
-void set_account_value::operator()(xact_t& xact)
+void set_account_value::operator()(post_t& post)
{
- account_t * acct = xact.reported_account();
+ account_t * acct = post.reported_account();
account_t::xdata_t& xdata(acct->xdata());
DEBUG("account.sums", "Account value was = " << xdata.value);
- xact.add_to_value(xdata.value, amount_expr);
+ post.add_to_value(xdata.value, amount_expr);
DEBUG("account.sums", "Account value is = " << xdata.value);
xdata.count++;
- if (xact.has_flags(XACT_VIRTUAL))
+ if (post.has_flags(POST_VIRTUAL))
xdata.virtuals++;
DEBUG("account.display",
- "Visiting account: " << xact.account->fullname());
- xact.account->xdata().add_flags(ACCOUNT_EXT_VISITED);
+ "Visiting account: " << post.account->fullname());
+ post.account->xdata().add_flags(ACCOUNT_EXT_VISITED);
- item_handler<xact_t>::operator()(xact);
+ item_handler<post_t>::operator()(post);
}
-void sort_xacts::post_accumulated_xacts()
+void sort_posts::post_accumulated_posts()
{
- std::stable_sort(xacts.begin(), xacts.end(),
- compare_items<xact_t>(sort_order));
+ std::stable_sort(posts.begin(), posts.end(),
+ compare_items<post_t>(sort_order));
- foreach (xact_t * xact, xacts) {
- xact->xdata().drop_flags(XACT_EXT_SORT_CALC);
- item_handler<xact_t>::operator()(*xact);
+ foreach (post_t * post, posts) {
+ post->xdata().drop_flags(POST_EXT_SORT_CALC);
+ item_handler<post_t>::operator()(*post);
}
- xacts.clear();
+ posts.clear();
}
namespace {
@@ -150,96 +150,96 @@ namespace {
}
}
-void anonymize_xacts::operator()(xact_t& xact)
+void anonymize_posts::operator()(post_t& post)
{
SHA1 sha;
uint_least32_t message_digest[5];
- bool copy_entry_details = false;
+ bool copy_xact_details = false;
- if (last_entry != xact.entry) {
- entry_temps.push_back(*xact.entry);
- last_entry = xact.entry;
- copy_entry_details = true;
+ if (last_xact != post.xact) {
+ xact_temps.push_back(*post.xact);
+ last_xact = post.xact;
+ copy_xact_details = true;
}
- entry_t& entry = entry_temps.back();
+ xact_t& xact = xact_temps.back();
- if (copy_entry_details) {
- entry.copy_details(*xact.entry);
+ if (copy_xact_details) {
+ xact.copy_details(*post.xact);
sha.Reset();
- sha << xact.entry->payee.c_str();
+ sha << post.xact->payee.c_str();
sha.Result(message_digest);
- entry.payee = to_hex(message_digest);
- entry.note = none;
+ xact.payee = to_hex(message_digest);
+ xact.note = none;
}
- xact_temps.push_back(xact);
- xact_t& temp = xact_temps.back();
- temp.entry = &entry;
+ post_temps.push_back(post);
+ post_t& temp = post_temps.back();
+ temp.xact = &xact;
sha.Reset();
- sha << xact.account->fullname().c_str();
+ sha << post.account->fullname().c_str();
sha.Result(message_digest);
- temp.copy_details(xact);
+ temp.copy_details(post);
- temp.account = xact.entry->journal->find_account(to_hex(message_digest));
+ temp.account = post.xact->journal->find_account(to_hex(message_digest));
temp.note = none;
temp.add_flags(ITEM_TEMP);
- entry.add_xact(&temp);
+ xact.add_post(&temp);
(*handler)(temp);
}
-void calc_xacts::operator()(xact_t& xact)
+void calc_posts::operator()(post_t& post)
{
- xact_t::xdata_t& xdata(xact.xdata());
+ post_t::xdata_t& xdata(post.xdata());
- if (last_xact) {
- assert(last_xact->has_xdata());
- add_or_set_value(xdata.total, last_xact->xdata().total);
- xdata.count = last_xact->xdata().count + 1;
+ if (last_post) {
+ assert(last_post->has_xdata());
+ add_or_set_value(xdata.total, last_post->xdata().total);
+ xdata.count = last_post->xdata().count + 1;
} else {
xdata.count = 1;
}
- xact.add_to_value(xdata.total, amount_expr);
+ post.add_to_value(xdata.total, amount_expr);
- item_handler<xact_t>::operator()(xact);
+ item_handler<post_t>::operator()(post);
- last_xact = &xact;
+ last_post = &post;
}
namespace {
void handle_value(const value_t& value,
account_t * account,
- entry_t * entry,
+ xact_t * xact,
unsigned int flags,
- std::list<xact_t>& temps,
- item_handler<xact_t>& handler,
+ std::list<post_t>& temps,
+ item_handler<post_t>& handler,
const date_t& date = date_t(),
const value_t& total = value_t())
{
- temps.push_back(xact_t(account));
- xact_t& xact(temps.back());
- xact.entry = entry;
- xact.add_flags(ITEM_TEMP);
- entry->add_xact(&xact);
+ temps.push_back(post_t(account));
+ post_t& post(temps.back());
+ post.xact = xact;
+ post.add_flags(ITEM_TEMP);
+ xact->add_post(&post);
- // If the account for this xact is all virtual, then report the xact as
+ // If the account for this post is all virtual, then report the post as
// such. This allows subtotal reports to show "(Account)" for accounts
- // that contain only virtual xacts.
+ // that contain only virtual posts.
if (account && account->has_xdata()) {
if (! account->xdata().has_flags(ACCOUNT_EXT_HAS_NON_VIRTUALS)) {
- xact.add_flags(XACT_VIRTUAL);
+ post.add_flags(POST_VIRTUAL);
if (! account->xdata().has_flags(ACCOUNT_EXT_HAS_UNB_VIRTUALS))
- xact.add_flags(XACT_MUST_BALANCE);
+ post.add_flags(POST_MUST_BALANCE);
}
}
- xact_t::xdata_t& xdata(xact.xdata());
+ post_t::xdata_t& xdata(post.xdata());
if (is_valid(date))
xdata.date = date;
@@ -253,13 +253,13 @@ namespace {
// fall through...
case value_t::AMOUNT:
- xact.amount = temp.as_amount();
+ post.amount = temp.as_amount();
break;
case value_t::BALANCE:
case value_t::SEQUENCE:
xdata.value = temp;
- flags |= XACT_EXT_COMPOUND;
+ flags |= POST_EXT_COMPOUND;
break;
case value_t::DATETIME:
@@ -275,120 +275,120 @@ namespace {
if (flags)
xdata.add_flags(flags);
- handler(xact);
+ handler(post);
}
}
-void collapse_xacts::report_subtotal()
+void collapse_posts::report_subtotal()
{
if (! count)
return;
std::size_t displayed_count = 0;
- foreach (xact_t * xact, component_xacts) {
- if (only_predicate(*xact) && display_predicate(*xact))
+ foreach (post_t * post, component_posts) {
+ if (only_predicate(*post) && display_predicate(*post))
displayed_count++;
}
if (displayed_count == 1) {
- item_handler<xact_t>::operator()(*last_xact);
+ item_handler<post_t>::operator()(*last_post);
}
else if (only_collapse_if_zero && ! subtotal.is_zero()) {
- foreach (xact_t * xact, component_xacts)
- item_handler<xact_t>::operator()(*xact);
+ foreach (post_t * post, component_posts)
+ item_handler<post_t>::operator()(*post);
}
else {
date_t earliest_date;
- foreach (xact_t * xact, component_xacts) {
- date_t reported = xact->date();
+ foreach (post_t * post, component_posts) {
+ date_t reported = post->date();
if (! is_valid(earliest_date) ||
reported < earliest_date)
earliest_date = reported;
}
- entry_temps.push_back(entry_t());
- entry_t& entry = entry_temps.back();
- entry.payee = last_entry->payee;
- entry._date = (is_valid(earliest_date) ?
- earliest_date : last_entry->_date);
- DEBUG("filter.collapse", "Pseudo-entry date = " << *entry._date);
+ xact_temps.push_back(xact_t());
+ xact_t& xact = xact_temps.back();
+ xact.payee = last_xact->payee;
+ xact._date = (is_valid(earliest_date) ?
+ earliest_date : last_xact->_date);
+ DEBUG("filter.collapse", "Pseudo-xact date = " << *xact._date);
- handle_value(subtotal, &totals_account, &entry, 0, xact_temps, *handler);
+ handle_value(subtotal, &totals_account, &xact, 0, post_temps, *handler);
}
- component_xacts.clear();
+ component_posts.clear();
- last_entry = NULL;
- last_xact = NULL;
+ last_xact = NULL;
+ last_post = NULL;
subtotal = 0L;
count = 0;
}
-void collapse_xacts::operator()(xact_t& xact)
+void collapse_posts::operator()(post_t& post)
{
- // If we've reached a new entry, report on the subtotal
+ // If we've reached a new xact, report on the subtotal
// accumulated thus far.
- if (last_entry != xact.entry && count > 0)
+ if (last_xact != post.xact && count > 0)
report_subtotal();
- xact.add_to_value(subtotal, amount_expr);
+ post.add_to_value(subtotal, amount_expr);
count++;
- component_xacts.push_back(&xact);
+ component_posts.push_back(&post);
- last_entry = xact.entry;
- last_xact = &xact;
+ last_xact = post.xact;
+ last_post = &post;
}
-void related_xacts::flush()
+void related_posts::flush()
{
- if (xacts.size() > 0) {
- foreach (xact_t * xact, xacts) {
- if (xact->entry) {
- foreach (xact_t * r_xact, xact->entry->xacts) {
- xact_t::xdata_t& xdata(r_xact->xdata());
- if (! xdata.has_flags(XACT_EXT_HANDLED) &&
- (! xdata.has_flags(XACT_EXT_RECEIVED) ?
- ! r_xact->has_flags(XACT_AUTO | XACT_VIRTUAL) :
+ if (posts.size() > 0) {
+ foreach (post_t * post, posts) {
+ if (post->xact) {
+ foreach (post_t * r_post, post->xact->posts) {
+ 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) :
also_matching)) {
- xdata.add_flags(XACT_EXT_HANDLED);
- item_handler<xact_t>::operator()(*r_xact);
+ xdata.add_flags(POST_EXT_HANDLED);
+ item_handler<post_t>::operator()(*r_post);
}
}
} else {
// This code should only be reachable from the "output"
// command, since that is the only command which attempts to
- // output auto or period entries.
- xact_t::xdata_t& xdata(xact->xdata());
- if (! xdata.has_flags(XACT_EXT_HANDLED) &&
- ! xact->has_flags(XACT_AUTO)) {
- xdata.add_flags(XACT_EXT_HANDLED);
- item_handler<xact_t>::operator()(*xact);
+ // output auto or period xacts.
+ post_t::xdata_t& xdata(post->xdata());
+ if (! xdata.has_flags(POST_EXT_HANDLED) &&
+ ! post->has_flags(POST_AUTO)) {
+ xdata.add_flags(POST_EXT_HANDLED);
+ item_handler<post_t>::operator()(*post);
}
}
}
}
- item_handler<xact_t>::flush();
+ item_handler<post_t>::flush();
}
-void changed_value_xacts::output_diff(xact_t * xact, const date_t& date)
+void changed_value_posts::output_diff(post_t * post, const date_t& date)
{
if (is_valid(date))
- xact->xdata().date = date;
+ post->xdata().date = date;
value_t repriced_total;
try {
- bind_scope_t bound_scope(report, *xact);
+ bind_scope_t bound_scope(report, *post);
repriced_total = total_expr.calc(bound_scope);
}
catch (...) {
- xact->xdata().date = date_t();
+ post->xdata().date = date_t();
throw;
}
- xact->xdata().date = date_t();
+ post->xdata().date = date_t();
DEBUG("filter.changed_value",
"output_diff(last_balance) = " << last_balance);
@@ -399,49 +399,49 @@ void changed_value_xacts::output_diff(xact_t * xact, const date_t& date)
DEBUG("filter.changed_value", "output_diff(strip(diff)) = "
<< diff.strip_annotations(report.what_to_keep()));
- entry_temps.push_back(entry_t());
- entry_t& entry = entry_temps.back();
- entry.payee = "Commodities revalued";
- entry._date = is_valid(date) ? date : xact->date();
+ xact_temps.push_back(xact_t());
+ xact_t& xact = xact_temps.back();
+ xact.payee = "Commodities revalued";
+ xact._date = is_valid(date) ? date : post->date();
- handle_value(diff, &revalued_account, &entry, XACT_EXT_NO_TOTAL,
- xact_temps, *handler, *entry._date, repriced_total);
+ handle_value(diff, &revalued_account, &xact, POST_EXT_NO_TOTAL,
+ post_temps, *handler, *xact._date, repriced_total);
}
}
-void changed_value_xacts::operator()(xact_t& xact)
+void changed_value_posts::operator()(post_t& post)
{
- if (last_xact)
- output_diff(last_xact, xact.date());
+ if (last_post)
+ output_diff(last_post, post.date());
if (changed_values_only)
- xact.xdata().add_flags(XACT_EXT_DISPLAYED);
+ post.xdata().add_flags(POST_EXT_DISPLAYED);
- item_handler<xact_t>::operator()(xact);
+ item_handler<post_t>::operator()(post);
- bind_scope_t bound_scope(report, xact);
+ bind_scope_t bound_scope(report, post);
last_balance = total_expr.calc(bound_scope);
- last_xact = &xact;
+ last_post = &post;
}
-void subtotal_xacts::report_subtotal(const char * spec_fmt,
+void subtotal_posts::report_subtotal(const char * spec_fmt,
const date_t& start,
const date_t& finish)
{
- if (component_xacts.empty())
+ if (component_posts.empty())
return;
date_t range_start = start;
date_t range_finish = finish;
- foreach (xact_t * xact, component_xacts) {
- date_t date = xact->date();
+ foreach (post_t * post, component_posts) {
+ date_t date = post->date();
if (! is_valid(range_start) || date < range_start)
range_start = date;
if (! is_valid(range_finish) || date > range_finish)
range_finish = date;
}
- component_xacts.clear();
+ component_posts.clear();
std::ostringstream out_date;
if (spec_fmt) {
@@ -456,61 +456,61 @@ void subtotal_xacts::report_subtotal(const char * spec_fmt,
out_date << format_date(range_finish, std::string("- ") + output_date_format);
}
- entry_temps.push_back(entry_t());
- entry_t& entry = entry_temps.back();
- entry.payee = out_date.str();
- entry._date = range_start;
+ xact_temps.push_back(xact_t());
+ xact_t& xact = xact_temps.back();
+ xact.payee = out_date.str();
+ xact._date = range_start;
foreach (values_map::value_type& pair, values)
- handle_value(pair.second.value, pair.second.account, &entry, 0,
- xact_temps, *handler);
+ handle_value(pair.second.value, pair.second.account, &xact, 0,
+ post_temps, *handler);
values.clear();
}
-void subtotal_xacts::operator()(xact_t& xact)
+void subtotal_posts::operator()(post_t& post)
{
- component_xacts.push_back(&xact);
+ component_posts.push_back(&post);
- account_t * acct = xact.reported_account();
+ account_t * acct = post.reported_account();
assert(acct);
values_map::iterator i = values.find(acct->fullname());
if (i == values.end()) {
value_t temp;
- xact.add_to_value(temp, amount_expr);
+ post.add_to_value(temp, amount_expr);
std::pair<values_map::iterator, bool> result
= values.insert(values_pair(acct->fullname(), acct_value_t(acct, temp)));
assert(result.second);
} else {
- xact.add_to_value((*i).second.value, amount_expr);
+ post.add_to_value((*i).second.value, amount_expr);
}
- // If the account for this xact is all virtual, mark it as
+ // If the account for this post is all virtual, mark it as
// such, so that `handle_value' can show "(Account)" for accounts
- // that contain only virtual xacts.
+ // that contain only virtual posts.
- if (! xact.has_flags(XACT_VIRTUAL))
- xact.reported_account()->xdata().add_flags(ACCOUNT_EXT_HAS_NON_VIRTUALS);
- else if (! xact.has_flags(XACT_MUST_BALANCE))
- xact.reported_account()->xdata().add_flags(ACCOUNT_EXT_HAS_UNB_VIRTUALS);
+ if (! post.has_flags(POST_VIRTUAL))
+ post.reported_account()->xdata().add_flags(ACCOUNT_EXT_HAS_NON_VIRTUALS);
+ else if (! post.has_flags(POST_MUST_BALANCE))
+ post.reported_account()->xdata().add_flags(ACCOUNT_EXT_HAS_UNB_VIRTUALS);
}
-void interval_xacts::report_subtotal(const date_t& finish)
+void interval_posts::report_subtotal(const date_t& finish)
{
- if (last_xact && interval) {
+ if (last_post && interval) {
if (exact_periods)
- subtotal_xacts::report_subtotal();
+ subtotal_posts::report_subtotal();
else
- subtotal_xacts::report_subtotal(NULL, interval.begin, finish);
+ subtotal_posts::report_subtotal(NULL, interval.begin, finish);
}
- last_xact = NULL;
+ last_post = NULL;
}
-void interval_xacts::operator()(xact_t& xact)
+void interval_posts::operator()(post_t& post)
{
- date_t date = xact.date();
+ date_t date = post.date();
if ((is_valid(interval.begin) && date < interval.begin) ||
(is_valid(interval.end) && date >= interval.end))
@@ -523,7 +523,7 @@ void interval_xacts::operator()(xact_t& xact)
date_t quant = interval.increment(interval.begin);
if (date >= quant) {
- if (last_xact)
+ if (last_post)
report_subtotal(quant - gregorian::days(1));
date_t temp;
@@ -533,56 +533,56 @@ void interval_xacts::operator()(xact_t& xact)
interval.begin = quant;
quant = temp;
- if (generate_empty_xacts) {
- // Generate a null transaction, so the intervening periods can be
+ if (generate_empty_posts) {
+ // Generate a null posting, so the intervening periods can be
// seen when -E is used, or if the calculated amount ends up being
// non-zero
- entry_temps.push_back(entry_t());
- entry_t& null_entry = entry_temps.back();
- null_entry.add_flags(ITEM_TEMP);
- null_entry._date = quant - gregorian::days(1);
-
- xact_temps.push_back(xact_t(&empty_account));
+ xact_temps.push_back(xact_t());
xact_t& null_xact = xact_temps.back();
- null_xact.add_flags(ITEM_TEMP | XACT_CALCULATED);
- null_xact.amount = 0L;
- null_entry.add_xact(&null_xact);
+ null_xact.add_flags(ITEM_TEMP);
+ null_xact._date = quant - gregorian::days(1);
+
+ post_temps.push_back(post_t(&empty_account));
+ post_t& null_post = post_temps.back();
+ null_post.add_flags(ITEM_TEMP | POST_CALCULATED);
+ null_post.amount = 0L;
+ null_xact.add_post(&null_post);
- last_xact = &null_xact;
- subtotal_xacts::operator()(null_xact);
+ last_post = &null_post;
+ subtotal_posts::operator()(null_post);
report_subtotal(quant - gregorian::days(1));
}
}
start = interval.begin = quant;
}
- subtotal_xacts::operator()(xact);
+ subtotal_posts::operator()(post);
} else {
- item_handler<xact_t>::operator()(xact);
+ item_handler<post_t>::operator()(post);
}
- last_xact = &xact;
+ last_post = &post;
}
-void xacts_as_equity::report_subtotal()
+void posts_as_equity::report_subtotal()
{
date_t finish;
- foreach (xact_t * xact, component_xacts) {
- date_t date = xact->date();
+ foreach (post_t * post, component_posts) {
+ date_t date = post->date();
if (! is_valid(finish) || date > finish)
finish = date;
}
- component_xacts.clear();
+ component_posts.clear();
- entry_temps.push_back(entry_t());
- entry_t& entry = entry_temps.back();
- entry.payee = "Opening Balances";
- entry._date = finish;
+ xact_temps.push_back(xact_t());
+ xact_t& xact = xact_temps.back();
+ xact.payee = "Opening Balances";
+ xact._date = finish;
value_t total = 0L;
foreach (values_map::value_type& pair, values) {
- handle_value(pair.second.value, pair.second.account, &entry, 0,
- xact_temps, *handler);
+ handle_value(pair.second.value, pair.second.account, &xact, 0,
+ post_temps, *handler);
total += pair.second.value;
}
values.clear();
@@ -590,40 +590,40 @@ void xacts_as_equity::report_subtotal()
if (total.is_balance()) {
foreach (balance_t::amounts_map::value_type pair,
total.as_balance().amounts) {
- xact_temps.push_back(xact_t(balance_account));
- xact_t& balance_xact = xact_temps.back();
- balance_xact.add_flags(ITEM_TEMP);
- balance_xact.amount = - pair.second;
- entry.add_xact(&balance_xact);
- (*handler)(balance_xact);
+ post_temps.push_back(post_t(balance_account));
+ post_t& balance_post = post_temps.back();
+ balance_post.add_flags(ITEM_TEMP);
+ balance_post.amount = - pair.second;
+ xact.add_post(&balance_post);
+ (*handler)(balance_post);
}
} else {
- xact_temps.push_back(xact_t(balance_account));
- xact_t& balance_xact = xact_temps.back();
- balance_xact.add_flags(ITEM_TEMP);
- balance_xact.amount = - total.to_amount();
- entry.add_xact(&balance_xact);
- (*handler)(balance_xact);
+ post_temps.push_back(post_t(balance_account));
+ post_t& balance_post = post_temps.back();
+ balance_post.add_flags(ITEM_TEMP);
+ balance_post.amount = - total.to_amount();
+ xact.add_post(&balance_post);
+ (*handler)(balance_post);
}
}
-void by_payee_xacts::flush()
+void by_payee_posts::flush()
{
foreach (payee_subtotals_map::value_type& pair, payee_subtotals)
pair.second->report_subtotal(pair.first.c_str());
- item_handler<xact_t>::flush();
+ item_handler<post_t>::flush();
payee_subtotals.clear();
}
-void by_payee_xacts::operator()(xact_t& xact)
+void by_payee_posts::operator()(post_t& post)
{
- payee_subtotals_map::iterator i = payee_subtotals.find(xact.entry->payee);
+ payee_subtotals_map::iterator i = payee_subtotals.find(post.xact->payee);
if (i == payee_subtotals.end()) {
payee_subtotals_pair
- temp(xact.entry->payee,
- shared_ptr<subtotal_xacts>(new subtotal_xacts(handler, amount_expr)));
+ temp(post.xact->payee,
+ shared_ptr<subtotal_posts>(new subtotal_posts(handler, amount_expr)));
std::pair<payee_subtotals_map::iterator, bool> result
= payee_subtotals.insert(temp);
@@ -633,27 +633,27 @@ void by_payee_xacts::operator()(xact_t& xact)
i = result.first;
}
- (*(*i).second)(xact);
+ (*(*i).second)(post);
}
-void transfer_details::operator()(xact_t& xact)
+void transfer_details::operator()(post_t& post)
{
- entry_temps.push_back(*xact.entry);
- entry_t& entry = entry_temps.back();
- entry._date = xact.date();
-
- xact_temps.push_back(xact);
- xact_t& temp = xact_temps.back();
- temp.entry = &entry;
- temp.set_state(xact.state());
+ xact_temps.push_back(*post.xact);
+ xact_t& xact = xact_temps.back();
+ xact._date = post.date();
+
+ post_temps.push_back(post);
+ post_t& temp = post_temps.back();
+ temp.xact = &xact;
+ temp.set_state(post.state());
temp.add_flags(ITEM_TEMP);
- entry.add_xact(&temp);
+ xact.add_post(&temp);
bind_scope_t bound_scope(scope, temp);
switch (which_element) {
case SET_PAYEE:
- entry.payee = expr.calc(bound_scope).to_string();
+ xact.payee = expr.calc(bound_scope).to_string();
break;
case SET_ACCOUNT:
temp.account = master->find_account(expr.calc(bound_scope).to_string());
@@ -663,42 +663,42 @@ void transfer_details::operator()(xact_t& xact)
break;
}
- item_handler<xact_t>::operator()(temp);
+ item_handler<post_t>::operator()(temp);
}
-void dow_xacts::flush()
+void dow_posts::flush()
{
for (int i = 0; i < 7; i++) {
- foreach (xact_t * xact, days_of_the_week[i])
- subtotal_xacts::operator()(*xact);
- subtotal_xacts::report_subtotal("%As");
+ foreach (post_t * post, days_of_the_week[i])
+ subtotal_posts::operator()(*post);
+ subtotal_posts::report_subtotal("%As");
days_of_the_week[i].clear();
}
- subtotal_xacts::flush();
+ subtotal_posts::flush();
}
-void generate_xacts::add_period_entries(period_entries_list& period_entries)
+void generate_posts::add_period_xacts(period_xacts_list& period_xacts)
{
- foreach (period_entry_t * entry, period_entries)
- foreach (xact_t * xact, entry->xacts)
- add_xact(entry->period, *xact);
+ foreach (period_xact_t * xact, period_xacts)
+ foreach (post_t * post, xact->posts)
+ add_post(xact->period, *post);
}
-void generate_xacts::add_xact(const interval_t& period, xact_t& xact)
+void generate_posts::add_post(const interval_t& period, post_t& post)
{
- pending_xacts.push_back(pending_xacts_pair(period, &xact));
+ pending_posts.push_back(pending_posts_pair(period, &post));
}
-void budget_xacts::report_budget_items(const date_t& date)
+void budget_posts::report_budget_items(const date_t& date)
{
- if (pending_xacts.size() == 0)
+ if (pending_posts.size() == 0)
return;
bool reported;
do {
reported = false;
- foreach (pending_xacts_list::value_type& pair, pending_xacts) {
+ foreach (pending_posts_list::value_type& pair, pending_posts) {
date_t& begin = pair.first.begin;
if (! is_valid(begin)) {
pair.first.set_start(date);
@@ -707,26 +707,26 @@ void budget_xacts::report_budget_items(const date_t& date)
if (begin < date &&
(! is_valid(pair.first.end) || begin < pair.first.end)) {
- xact_t& xact = *pair.second;
+ post_t& post = *pair.second;
DEBUG("ledger.walk.budget", "Reporting budget for "
- << xact.reported_account()->fullname());
+ << post.reported_account()->fullname());
- entry_temps.push_back(entry_t());
- entry_t& entry = entry_temps.back();
- entry.payee = "Budget entry";
- entry._date = begin;
+ xact_temps.push_back(xact_t());
+ xact_t& xact = xact_temps.back();
+ xact.payee = "Budget transaction";
+ xact._date = begin;
- xact_temps.push_back(xact);
- xact_t& temp = xact_temps.back();
- temp.entry = &entry;
- temp.add_flags(XACT_AUTO | ITEM_TEMP);
+ post_temps.push_back(post);
+ post_t& temp = post_temps.back();
+ temp.xact = &xact;
+ temp.add_flags(POST_AUTO | ITEM_TEMP);
temp.amount.in_place_negate();
- entry.add_xact(&temp);
+ xact.add_post(&temp);
begin = pair.first.increment(begin);
- item_handler<xact_t>::operator()(temp);
+ item_handler<post_t>::operator()(temp);
reported = true;
}
@@ -734,40 +734,40 @@ void budget_xacts::report_budget_items(const date_t& date)
} while (reported);
}
-void budget_xacts::operator()(xact_t& xact)
+void budget_posts::operator()(post_t& post)
{
- bool xact_in_budget = false;
+ bool post_in_budget = false;
- foreach (pending_xacts_list::value_type& pair, pending_xacts) {
- for (account_t * acct = xact.reported_account();
+ foreach (pending_posts_list::value_type& pair, pending_posts) {
+ for (account_t * acct = post.reported_account();
acct;
acct = acct->parent) {
if (acct == (*pair.second).reported_account()) {
- xact_in_budget = true;
- // Report the xact as if it had occurred in the parent
+ post_in_budget = true;
+ // Report the post as if it had occurred in the parent
// account.
- if (xact.reported_account() != acct)
- xact.xdata().account = acct;
+ if (post.reported_account() != acct)
+ post.xdata().account = acct;
goto handle;
}
}
}
handle:
- if (xact_in_budget && flags & BUDGET_BUDGETED) {
- report_budget_items(xact.date());
- item_handler<xact_t>::operator()(xact);
+ if (post_in_budget && flags & BUDGET_BUDGETED) {
+ report_budget_items(post.date());
+ item_handler<post_t>::operator()(post);
}
- else if (! xact_in_budget && flags & BUDGET_UNBUDGETED) {
- item_handler<xact_t>::operator()(xact);
+ else if (! post_in_budget && flags & BUDGET_UNBUDGETED) {
+ item_handler<post_t>::operator()(post);
}
}
-void forecast_xacts::add_xact(const interval_t& period, xact_t& xact)
+void forecast_posts::add_post(const interval_t& period, post_t& post)
{
- generate_xacts::add_xact(period, xact);
+ generate_posts::add_post(period, post);
- interval_t& i = pending_xacts.back().first;
+ interval_t& i = pending_posts.back().first;
if (! is_valid(i.begin)) {
i.set_start(CURRENT_DATE());
i.begin = i.increment(i.begin);
@@ -777,15 +777,15 @@ void forecast_xacts::add_xact(const interval_t& period, xact_t& xact)
}
}
-void forecast_xacts::flush()
+void forecast_posts::flush()
{
- xacts_list passed;
+ posts_list passed;
date_t last;
- while (pending_xacts.size() > 0) {
- pending_xacts_list::iterator least = pending_xacts.begin();
- for (pending_xacts_list::iterator i = ++pending_xacts.begin();
- i != pending_xacts.end();
+ while (pending_posts.size() > 0) {
+ pending_posts_list::iterator least = pending_posts.begin();
+ for (pending_posts_list::iterator i = ++pending_posts.begin();
+ i != pending_posts.end();
i++)
if ((*i).first.begin < (*least).first.begin)
least = i;
@@ -793,33 +793,33 @@ void forecast_xacts::flush()
date_t& begin = (*least).first.begin;
if (is_valid((*least).first.end) && begin >= (*least).first.end) {
- pending_xacts.erase(least);
+ pending_posts.erase(least);
passed.remove((*least).second);
continue;
}
- xact_t& xact = *(*least).second;
+ post_t& post = *(*least).second;
- entry_temps.push_back(entry_t());
- entry_t& entry = entry_temps.back();
- entry.payee = "Forecast entry";
- entry._date = begin;
+ xact_temps.push_back(xact_t());
+ xact_t& xact = xact_temps.back();
+ xact.payee = "Forecast transaction";
+ xact._date = begin;
- xact_temps.push_back(xact);
- xact_t& temp = xact_temps.back();
- temp.entry = &entry;
- temp.add_flags(XACT_AUTO | ITEM_TEMP);
- entry.add_xact(&temp);
+ post_temps.push_back(post);
+ post_t& temp = post_temps.back();
+ temp.xact = &xact;
+ temp.add_flags(POST_AUTO | ITEM_TEMP);
+ xact.add_post(&temp);
date_t next = (*least).first.increment(begin);
if (next < begin || (is_valid(last) && (next - last).days() > 365 * 5))
break;
begin = next;
- item_handler<xact_t>::operator()(temp);
+ item_handler<post_t>::operator()(temp);
if (temp.has_xdata() &&
- temp.xdata().has_flags(XACT_EXT_MATCHES)) {
+ temp.xdata().has_flags(POST_EXT_MATCHES)) {
bind_scope_t bound_scope(context, temp);
if (! pred(bound_scope))
break;
@@ -827,21 +827,21 @@ void forecast_xacts::flush()
passed.clear();
} else {
bool found = false;
- foreach (xact_t * x, passed)
- if (x == &xact) {
+ foreach (post_t * x, passed)
+ if (x == &post) {
found = true;
break;
}
if (! found) {
- passed.push_back(&xact);
- if (passed.size() >= pending_xacts.size())
+ passed.push_back(&post);
+ if (passed.size() >= pending_posts.size())
break;
}
}
}
- item_handler<xact_t>::flush();
+ item_handler<post_t>::flush();
}
pass_down_accounts::pass_down_accounts(acct_handler_ptr handler,