Added account_id and xact_id valexpr vars for posts
account_id is the "whicheth" number for that posting within its account. The xact_id is within its transaction.
This commit is contained in:
parent
017492ef5e
commit
47bfe58ab3
2 changed files with 39 additions and 0 deletions
36
src/post.cc
36
src/post.cc
|
|
@ -142,6 +142,10 @@ namespace {
|
|||
return value_t(static_cast<scope_t *>(post.xact));
|
||||
}
|
||||
|
||||
value_t get_xact_id(post_t& post) {
|
||||
return static_cast<long>(post.xact_id());
|
||||
}
|
||||
|
||||
value_t get_code(post_t& post) {
|
||||
if (post.xact->code)
|
||||
return string_value(*post.xact->code);
|
||||
|
|
@ -275,6 +279,10 @@ namespace {
|
|||
return string_value(name);
|
||||
}
|
||||
|
||||
value_t get_account_id(post_t& post) {
|
||||
return static_cast<long>(post.account_id());
|
||||
}
|
||||
|
||||
value_t get_account_base(post_t& post) {
|
||||
return string_value(post.reported_account()->name);
|
||||
}
|
||||
|
|
@ -351,6 +359,8 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
|
|||
return WRAP_FUNCTOR(get_account);
|
||||
else if (name == "account_base")
|
||||
return WRAP_FUNCTOR(get_wrapper<&get_account_base>);
|
||||
else if (name == "account_id")
|
||||
return WRAP_FUNCTOR(get_wrapper<&get_account_id>);
|
||||
else if (name == "any")
|
||||
return WRAP_FUNCTOR(&fn_any);
|
||||
else if (name == "all")
|
||||
|
|
@ -444,6 +454,8 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
|
|||
case 'x':
|
||||
if (name == "xact")
|
||||
return WRAP_FUNCTOR(get_wrapper<&get_xact>);
|
||||
else if (name == "xact_id")
|
||||
return WRAP_FUNCTOR(get_wrapper<&get_xact_id>);
|
||||
break;
|
||||
|
||||
case 'N':
|
||||
|
|
@ -479,6 +491,30 @@ amount_t post_t::resolve_expr(scope_t& scope, expr_t& expr)
|
|||
}
|
||||
}
|
||||
|
||||
std::size_t post_t::xact_id() const
|
||||
{
|
||||
std::size_t id = 1;
|
||||
foreach (post_t * p, xact->posts) {
|
||||
if (p == this)
|
||||
return id;
|
||||
id++;
|
||||
}
|
||||
assert(! "Failed to find posting within its transaction");
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::size_t post_t::account_id() const
|
||||
{
|
||||
std::size_t id = 1;
|
||||
foreach (post_t * p, account->posts) {
|
||||
if (p == this)
|
||||
return id;
|
||||
id++;
|
||||
}
|
||||
assert(! "Failed to find posting within its transaction");
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool post_t::valid() const
|
||||
{
|
||||
if (! xact) {
|
||||
|
|
|
|||
|
|
@ -118,6 +118,9 @@ public:
|
|||
|
||||
amount_t resolve_expr(scope_t& scope, expr_t& expr);
|
||||
|
||||
std::size_t xact_id() const;
|
||||
std::size_t account_id() const;
|
||||
|
||||
bool valid() const;
|
||||
|
||||
struct xdata_t : public supports_flags<uint_least16_t>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue