summaryrefslogtreecommitdiff
path: root/src/post.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-05-22 21:05:30 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-05-22 21:35:03 -0400
commitb5c9be4d29fab1388e195600d659602ae19b8f4e (patch)
tree51dcdd9e9f15e1df96e34690638e24755608cc90 /src/post.cc
parent9557a9d955f4272ac4ad7b727af18ab388b1f92e (diff)
downloadfork-ledger-b5c9be4d29fab1388e195600d659602ae19b8f4e.tar.gz
fork-ledger-b5c9be4d29fab1388e195600d659602ae19b8f4e.tar.bz2
fork-ledger-b5c9be4d29fab1388e195600d659602ae19b8f4e.zip
Created new valexpr variable display_account
Where display_account might be '(Expenses:Food)', account will always be 'Expenses:Food'. account is now used by all matching and query operations, while display_account is used in the various report outputs (besides balance, which never distinguished virtual accounts). Fixes F2832452-4521-49A3-B854-F4E12CC4D82E
Diffstat (limited to 'src/post.cc')
-rw-r--r--src/post.cc32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/post.cc b/src/post.cc
index 18c566c4..f1f3e96a 100644
--- a/src/post.cc
+++ b/src/post.cc
@@ -236,7 +236,7 @@ namespace {
return 1L;
}
- value_t get_account(call_scope_t& scope)
+ value_t account_name(call_scope_t& scope)
{
in_context_t<post_t> env(scope, "&v");
@@ -279,14 +279,28 @@ namespace {
} else {
name = env->reported_account()->fullname();
}
+ return string_value(name);
+ }
- if (env->has_flags(POST_VIRTUAL)) {
- if (env->must_balance())
- name = string("[") + name + "]";
- else
- name = string("(") + name + ")";
+ value_t get_display_account(call_scope_t& scope)
+ {
+ in_context_t<post_t> env(scope, "&v");
+
+ value_t acct = account_name(scope);
+ if (acct.is_string()) {
+ if (env->has_flags(POST_VIRTUAL)) {
+ if (env->must_balance())
+ acct = string_value(string("[") + acct.as_string() + "]");
+ else
+ acct = string_value(string("(") + acct.as_string() + ")");
+ }
}
- return string_value(name);
+ return acct;
+ }
+
+ value_t get_account(call_scope_t& scope)
+ {
+ return account_name(scope);
}
value_t get_account_id(post_t& post) {
@@ -398,7 +412,9 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
break;
case 'd':
- if (name == "depth")
+ if (name == "display_account")
+ return WRAP_FUNCTOR(get_display_account);
+ else if (name == "depth")
return WRAP_FUNCTOR(get_wrapper<&get_account_depth>);
else if (name == "datetime")
return WRAP_FUNCTOR(get_wrapper<&get_datetime>);