summaryrefslogtreecommitdiff
path: root/src/post.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-26 00:56:47 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-26 03:16:39 -0400
commitd58797e98c82ced16fbc0a213fd104fb72a9de08 (patch)
treececde49eece8edc80e334f74895e0861a56c0fdb /src/post.cc
parent74e569e220bee08d6c9eda59b5e4021748344994 (diff)
downloadfork-ledger-d58797e98c82ced16fbc0a213fd104fb72a9de08.tar.gz
fork-ledger-d58797e98c82ced16fbc0a213fd104fb72a9de08.tar.bz2
fork-ledger-d58797e98c82ced16fbc0a213fd104fb72a9de08.zip
The -B, -G, -V reports now show rounding amounts
This way, if the running total is off by a penny or two due to rounding of one or more commodities in the account, the user will see it. This commit also reorganizes the testing code a bit, which I did after adding the ninth test series (ConfirmTests), to validate the new rounding code.
Diffstat (limited to 'src/post.cc')
-rw-r--r--src/post.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/post.cc b/src/post.cc
index b10ab81a..8293bfe4 100644
--- a/src/post.cc
+++ b/src/post.cc
@@ -158,6 +158,10 @@ namespace {
}
}
+ value_t get_use_direct_amount(post_t& post) {
+ return post.has_xdata() && post.xdata().has_flags(POST_EXT_DIRECT_AMT);
+ }
+
value_t get_commodity(post_t& post) {
return string_value(post.amount.commodity().symbol());
}
@@ -282,6 +286,11 @@ expr_t::ptr_op_t post_t::lookup(const string& name)
return WRAP_FUNCTOR(get_wrapper<&get_total>);
break;
+ case 'u':
+ if (name == "use_direct_amount")
+ return WRAP_FUNCTOR(get_wrapper<&get_use_direct_amount>);
+ break;
+
case 'v':
if (name == "virtual")
return WRAP_FUNCTOR(get_wrapper<&get_virtual>);
@@ -333,8 +342,7 @@ void post_t::add_to_value(value_t& value, expr_t& expr)
{
if (xdata_ && xdata_->has_flags(POST_EXT_COMPOUND)) {
add_or_set_value(value, xdata_->value);
- }
- else if (! xdata_ || ! xdata_->has_flags(POST_EXT_NO_TOTAL)) {
+ } else {
bind_scope_t bound_scope(*expr.get_context(), *this);
add_or_set_value(value, expr.calc(bound_scope));
}