summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/entry.cc10
-rw-r--r--src/report.cc10
-rw-r--r--src/textual.cc9
-rw-r--r--src/xact.cc9
4 files changed, 24 insertions, 14 deletions
diff --git a/src/entry.cc b/src/entry.cc
index 4309f9d9..5082b34a 100644
--- a/src/entry.cc
+++ b/src/entry.cc
@@ -61,14 +61,14 @@ entry_base_t::~entry_base_t()
item_t::state_t entry_base_t::state() const
{
bool first = true;
- state_t result = UNCLEARED;
+ state_t result = CLEARED;
foreach (xact_t * xact, xacts) {
- if ((result == UNCLEARED && xact->_state != UNCLEARED) ||
- (result == PENDING && xact->_state == CLEARED))
- result = xact->_state;
+ if (xact->_state == UNCLEARED)
+ return UNCLEARED;
+ else if (xact->_state == PENDING)
+ result = PENDING;
}
-
return result;
}
diff --git a/src/report.cc b/src/report.cc
index 6d045a73..3b2ac90d 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -58,11 +58,13 @@ report_t::report_t(session_t& _session) : session(_session)
"%48|%-.38A %22.108t %!22.132T\n");
HANDLER(print_format_).on(
- "%(entry.date)%(entry.cleared ? \" *\" : (entry.uncleared ? \"\" : \" !\"))"
+ "%(entry.date)%(entry.cleared ? \" *\" : (entry.pending ? \" !\" : \"\"))"
"%(code ? \" (\" + code + \")\" : \"\") %(payee)%(entry.comment | \"\")\n"
- " %(cleared ? \"* \" : (uncleared ? \"\" : \"! \"))%-34(account)"
+ " %(entry.uncleared ? (cleared ? \"* \" : (pending ? \"! \" : \"\")) : \"\")"
+ "%-34(account)"
" %12(amount)%(comment | \"\")\n%/"
- " %(cleared ? \"* \" : (uncleared ? \"\" : \"! \"))%-34(account)"
+ " %(entry.uncleared ? (cleared ? \"* \" : (pending ? \"! \" : \"\")) : \"\")"
+ "%-34(account)"
" %12(amount)%(comment | \"\")\n%/\n");
HANDLER(balance_format_).on(
@@ -84,7 +86,7 @@ report_t::report_t(session_t& _session) : session(_session)
"%(quoted(payee)),"
"%(quoted(account)),"
"%(quoted(display_amount)),"
- "%(quoted(cleared ? \"*\" : (uncleared ? \"\" : \"!\"))),"
+ "%(quoted((cleared or entry.cleared) ? \"*\" : ((pending or entry.pending) ? \"!\" : \"\"))),"
"%(quoted(code)),"
"%(quoted(join(note)))\n");
}
diff --git a/src/textual.cc b/src/textual.cc
index 08a607fb..e848ebff 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -752,8 +752,8 @@ xact_t * instance_t::parse_xact(char * line,
}
if (entry &&
- ((entry->_state == item_t::CLEARED && xact->state() != item_t::CLEARED) ||
- (entry->_state == item_t::PENDING && xact->state() == item_t::UNCLEARED)))
+ ((entry->_state == item_t::CLEARED && xact->_state != item_t::CLEARED) ||
+ (entry->_state == item_t::PENDING && xact->_state == item_t::UNCLEARED)))
xact->set_state(entry->_state);
// Parse the account name
@@ -1050,15 +1050,14 @@ entry_t * instance_t::parse_entry(char * line,
// Parse the optional cleared flag: *
- item_t::state_t state = item_t::UNCLEARED;
if (next) {
switch (*next) {
case '*':
- state = item_t::CLEARED;
+ curr->_state = item_t::CLEARED;
next = skip_ws(++next);
break;
case '!':
- state = item_t::PENDING;
+ curr->_state = item_t::PENDING;
next = skip_ws(++next);
break;
}
diff --git a/src/xact.cc b/src/xact.cc
index c9f38d56..06f4d465 100644
--- a/src/xact.cc
+++ b/src/xact.cc
@@ -66,6 +66,10 @@ item_t::state_t xact_t::state() const
}
namespace {
+ value_t get_this(xact_t& xact) {
+ return value_t(static_cast<scope_t *>(&xact));
+ }
+
value_t get_entry(xact_t& xact) {
return value_t(static_cast<scope_t *>(xact.entry));
}
@@ -198,6 +202,11 @@ expr_t::ptr_op_t xact_t::lookup(const string& name)
else if (name == "total_cost")
return WRAP_FUNCTOR(get_wrapper<&get_total_cost>);
break;
+
+ case 'x':
+ if (name == "xact")
+ return WRAP_FUNCTOR(get_wrapper<&get_this>);
+ break;
}
return item_t::lookup(name);