summaryrefslogtreecommitdiff
path: root/src/report.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-03-09 07:02:53 -0600
committerJohn Wiegley <johnw@newartisans.com>2012-03-09 07:02:53 -0600
commit318b5f49ff07bdd906eb7c976b5c36c2eeb45872 (patch)
tree301736288a11361914b6a8b787fb9b45d4827999 /src/report.cc
parent929a734a30fd9c2dc593a99cbce119e365ea1d7b (diff)
downloadfork-ledger-318b5f49ff07bdd906eb7c976b5c36c2eeb45872.tar.gz
fork-ledger-318b5f49ff07bdd906eb7c976b5c36c2eeb45872.tar.bz2
fork-ledger-318b5f49ff07bdd906eb7c976b5c36c2eeb45872.zip
Fixed the behavior of fn_nail_down
Diffstat (limited to 'src/report.cc')
-rw-r--r--src/report.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/report.cc b/src/report.cc
index 110d33ee..27d8bb2a 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -743,12 +743,20 @@ value_t report_t::fn_commodity(call_scope_t& args)
value_t report_t::fn_nail_down(call_scope_t& args)
{
value_t arg0(args[0]);
+ value_t arg1(args[1]);
+
switch (arg0.type()) {
case value_t::AMOUNT: {
amount_t tmp(arg0.as_amount());
- if (tmp.has_commodity())
- tmp.set_commodity(tmp.commodity()
- .nail_down(args[1].as_any<expr_t::ptr_op_t>()));
+ if (tmp.has_commodity() && ! arg1.is_null()) {
+ expr_t value_expr(is_expr(arg1) ?
+ as_expr(arg1) : expr_t::op_t::wrap_value(arg1 / arg0));
+ std::ostringstream buf;
+ value_expr.print(buf);
+ value_expr.set_text(buf.str());
+
+ tmp.set_commodity(tmp.commodity().nail_down(value_expr));
+ }
return tmp;
}