summaryrefslogtreecommitdiff
path: root/src/report.cc
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2013-01-30 15:35:31 -0700
committerCraig Earls <enderw88@gmail.com>2013-01-30 15:35:31 -0700
commit0df13661686dfec66aa0d5a8dd88920e1e104fbc (patch)
treecbf9270fc8fe85d0ae67c1c1f3ab8d42296c232b /src/report.cc
parent383c341d885e1a69fc63aca2ae7db4a2ff5ff1a8 (diff)
downloadfork-ledger-0df13661686dfec66aa0d5a8dd88920e1e104fbc.tar.gz
fork-ledger-0df13661686dfec66aa0d5a8dd88920e1e104fbc.tar.bz2
fork-ledger-0df13661686dfec66aa0d5a8dd88920e1e104fbc.zip
Bug 634 Added roundto function, optimized floor and ceiling
Fixes Bug634 by adding roundto(amount, places).
Diffstat (limited to 'src/report.cc')
-rw-r--r--src/report.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/report.cc b/src/report.cc
index 80993515..d90d22e4 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -691,6 +691,12 @@ value_t report_t::fn_round(call_scope_t& args)
return args[0].rounded();
}
+value_t report_t::fn_roundto(call_scope_t& args)
+{
+ if(args.has<int>(1))
+ return args[0].roundto(args.get<int>(1));
+}
+
value_t report_t::fn_unround(call_scope_t& args)
{
return args[0].unrounded();
@@ -1435,6 +1441,8 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind,
return WRAP_FUNCTOR(fn_red);
else if (is_eq(p, "round"))
return MAKE_FUNCTOR(report_t::fn_round);
+ else if (is_eq(p, "roundto"))
+ return MAKE_FUNCTOR(report_t::fn_roundto);
break;
case 's':