summaryrefslogtreecommitdiff
path: root/src/report.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-06-26 17:09:34 +0100
committerJohn Wiegley <johnw@newartisans.com>2009-06-26 17:15:35 +0100
commit2ef1934bb0dbcd08dfe8d4dc68bfd1509c8f51ce (patch)
tree5225fc7f164feed6a0af36f552b9fa713a3d8840 /src/report.cc
parent4574c30fcfd3b03bab9a368a6ff2928af7e11e28 (diff)
downloadfork-ledger-2ef1934bb0dbcd08dfe8d4dc68bfd1509c8f51ce.tar.gz
fork-ledger-2ef1934bb0dbcd08dfe8d4dc68bfd1509c8f51ce.tar.bz2
fork-ledger-2ef1934bb0dbcd08dfe8d4dc68bfd1509c8f51ce.zip
Restored --price option, added baseline test
This option reports only in terms of the annotated price of the commodities involved, otherwise it reports the amounts themselves. It can be used in conjunction with other reports, as it applies to the displayed amounts, not the actual amounts being calculated.
Diffstat (limited to 'src/report.cc')
-rw-r--r--src/report.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/report.cc b/src/report.cc
index 3e38aef2..4c8a40e6 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -246,16 +246,18 @@ value_t report_t::fn_quoted(call_scope_t& args)
return string_value(out.str());
}
-value_t report_t::fn_join(call_scope_t& args)
+value_t report_t::fn_join(call_scope_t& scope)
{
+ interactive_t args(scope, "s");
+
std::ostringstream out;
- foreach (const char ch, args[0].to_string())
+ foreach (const char ch, args.get<string>(0)) {
if (ch != '\n')
out << ch;
else
out << "\\n";
-
+ }
return string_value(out.str());
}
@@ -299,6 +301,12 @@ value_t report_t::fn_percent(call_scope_t& scope)
(args.get<amount_t>(0) / args.get<amount_t>(1)).number());
}
+value_t report_t::fn_price(call_scope_t& scope)
+{
+ interactive_t args(scope, "v");
+ return args.value_at(0).price();
+}
+
namespace {
value_t fn_black(call_scope_t&) {
return string_value("black");
@@ -846,6 +854,8 @@ expr_t::ptr_op_t report_t::lookup(const string& name)
return WRAP_FUNCTOR(fn_false);
else if (is_eq(p, "percent"))
return MAKE_FUNCTOR(report_t::fn_percent);
+ else if (is_eq(p, "price"))
+ return MAKE_FUNCTOR(report_t::fn_price);
break;
case 'q':