diff options
author | John Wiegley <johnw@newartisans.com> | 2009-03-06 02:52:14 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-03-06 02:52:14 -0400 |
commit | 4a0f5f9034dc24c7ae5f0464d407f4cf2279558b (patch) | |
tree | b7a4fa4659d366b34e8ecb25267ec2ea9c11f93c /src/post.cc | |
parent | 80c51bf0a524ed80c0c248374a75e7fc392e1a3d (diff) | |
parent | aff490534a8e7826d89bbc75c6885b4a6bff4d17 (diff) | |
download | fork-ledger-4a0f5f9034dc24c7ae5f0464d407f4cf2279558b.tar.gz fork-ledger-4a0f5f9034dc24c7ae5f0464d407f4cf2279558b.tar.bz2 fork-ledger-4a0f5f9034dc24c7ae5f0464d407f4cf2279558b.zip |
Merge branch 'next'
Diffstat (limited to 'src/post.cc')
-rw-r--r-- | src/post.cc | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/src/post.cc b/src/post.cc index 4289433e..2c303a87 100644 --- a/src/post.cc +++ b/src/post.cc @@ -140,12 +140,10 @@ namespace { } value_t get_amount(post_t& post) { - if (post.has_xdata() && - post.xdata().has_flags(POST_EXT_COMPOUND)) { - return post.xdata().value; - } else { + if (post.has_xdata() && post.xdata().has_flags(POST_EXT_COMPOUND)) + return post.xdata().compound_value; + else return post.amount; - } } value_t get_use_direct_amount(post_t& post) { @@ -169,7 +167,7 @@ namespace { return *post.cost; else if (post.has_xdata() && post.xdata().has_flags(POST_EXT_COMPOUND)) - return post.xdata().value; + return post.xdata().compound_value; else return post.amount; } @@ -233,10 +231,11 @@ namespace { DEBUG("post.account_amount", "Found account: " << account->fullname()); - if (account->xdata().self_details.total.is_null()) + value_t total = account->self_total(); + if (total.is_null()) return 0L; else - return account->xdata().self_details.total.simplified(); + return total.simplified(); } value_t get_account_depth(post_t& post) { @@ -365,13 +364,31 @@ bool post_t::valid() const return true; } -void post_t::add_to_value(value_t& value, expr_t& expr) +void post_t::add_to_value(value_t& value, const optional<expr_t&>& expr) const { if (xdata_ && xdata_->has_flags(POST_EXT_COMPOUND)) { + add_or_set_value(value, xdata_->compound_value); + } + else if (expr) { + bind_scope_t bound_scope(*expr->get_context(), + const_cast<post_t&>(*this)); +#if 1 + value_t temp(expr->calc(bound_scope)); + add_or_set_value(value, temp); +#else + if (! xdata_) xdata_ = xdata_t(); + xdata_->value = expr->calc(bound_scope); + xdata_->add_flags(POST_EXT_COMPOUND); + add_or_set_value(value, xdata_->value); - } else { - bind_scope_t bound_scope(*expr.get_context(), *this); - add_or_set_value(value, expr.calc(bound_scope)); +#endif + } + else if (xdata_ && xdata_->has_flags(POST_EXT_VISITED) && + ! xdata_->visited_value.is_null()) { + add_or_set_value(value, xdata_->visited_value); + } + else { + add_or_set_value(value, amount); } } |