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
This commit is contained in:
parent
9557a9d955
commit
b5c9be4d29
2 changed files with 30 additions and 14 deletions
34
src/post.cc
34
src/post.cc
|
|
@ -236,7 +236,7 @@ namespace {
|
||||||
return 1L;
|
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");
|
in_context_t<post_t> env(scope, "&v");
|
||||||
|
|
||||||
|
|
@ -279,16 +279,30 @@ namespace {
|
||||||
} else {
|
} else {
|
||||||
name = env->reported_account()->fullname();
|
name = env->reported_account()->fullname();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (env->has_flags(POST_VIRTUAL)) {
|
|
||||||
if (env->must_balance())
|
|
||||||
name = string("[") + name + "]";
|
|
||||||
else
|
|
||||||
name = string("(") + name + ")";
|
|
||||||
}
|
|
||||||
return string_value(name);
|
return string_value(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 acct;
|
||||||
|
}
|
||||||
|
|
||||||
|
value_t get_account(call_scope_t& scope)
|
||||||
|
{
|
||||||
|
return account_name(scope);
|
||||||
|
}
|
||||||
|
|
||||||
value_t get_account_id(post_t& post) {
|
value_t get_account_id(post_t& post) {
|
||||||
return static_cast<long>(post.account_id());
|
return static_cast<long>(post.account_id());
|
||||||
}
|
}
|
||||||
|
|
@ -398,7 +412,9 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
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>);
|
return WRAP_FUNCTOR(get_wrapper<&get_account_depth>);
|
||||||
else if (name == "datetime")
|
else if (name == "datetime")
|
||||||
return WRAP_FUNCTOR(get_wrapper<&get_datetime>);
|
return WRAP_FUNCTOR(get_wrapper<&get_datetime>);
|
||||||
|
|
|
||||||
10
src/report.h
10
src/report.h
|
|
@ -463,7 +463,7 @@ public:
|
||||||
"%(quoted(date)),"
|
"%(quoted(date)),"
|
||||||
"%(quoted(code)),"
|
"%(quoted(code)),"
|
||||||
"%(quoted(payee)),"
|
"%(quoted(payee)),"
|
||||||
"%(quoted(account)),"
|
"%(quoted(display_account)),"
|
||||||
"%(quoted(commodity)),"
|
"%(quoted(commodity)),"
|
||||||
"%(quoted(quantity(scrub(display_amount)))),"
|
"%(quoted(quantity(scrub(display_amount)))),"
|
||||||
"%(quoted(cleared ? \"*\" : (pending ? \"!\" : \"\"))),"
|
"%(quoted(cleared ? \"*\" : (pending ? \"!\" : \"\"))),"
|
||||||
|
|
@ -752,13 +752,13 @@ public:
|
||||||
|
|
||||||
OPTION__(report_t, prices_format_, CTOR(report_t, prices_format_) {
|
OPTION__(report_t, prices_format_, CTOR(report_t, prices_format_) {
|
||||||
on(none,
|
on(none,
|
||||||
"%(date) %-8(account) %(justify(scrub(display_amount), 12, "
|
"%(date) %-8(display_account) %(justify(scrub(display_amount), 12, "
|
||||||
" 2 + 9 + 8 + 12, true, color))\n");
|
" 2 + 9 + 8 + 12, true, color))\n");
|
||||||
});
|
});
|
||||||
|
|
||||||
OPTION__(report_t, pricedb_format_, CTOR(report_t, pricedb_format_) {
|
OPTION__(report_t, pricedb_format_, CTOR(report_t, pricedb_format_) {
|
||||||
on(none,
|
on(none,
|
||||||
"P %(datetime) %(account) %(scrub(display_amount))\n");
|
"P %(datetime) %(display_account) %(scrub(display_amount))\n");
|
||||||
});
|
});
|
||||||
|
|
||||||
OPTION(report_t, print_virtual);
|
OPTION(report_t, print_virtual);
|
||||||
|
|
@ -785,8 +785,8 @@ public:
|
||||||
" if color & date > today))"
|
" if color & date > today))"
|
||||||
" %(ansify_if(justify(truncated(payee, payee_width), payee_width), "
|
" %(ansify_if(justify(truncated(payee, payee_width), payee_width), "
|
||||||
" bold if color & !cleared & actual))"
|
" bold if color & !cleared & actual))"
|
||||||
" %(ansify_if(justify(truncated(account, account_width, abbrev_len), "
|
" %(ansify_if(justify(truncated(display_account, account_width, "
|
||||||
" account_width), blue if color))"
|
" abbrev_len), account_width), blue if color))"
|
||||||
" %(justify(scrub(display_amount), amount_width, "
|
" %(justify(scrub(display_amount), amount_width, "
|
||||||
" 3 + meta_width + date_width + payee_width + account_width"
|
" 3 + meta_width + date_width + payee_width + account_width"
|
||||||
" + amount_width + prepend_width, true, color))"
|
" + amount_width + prepend_width, true, color))"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue