From fbccb7149eae348182bef7ac9dcba756fe72381d Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 16 Feb 2018 23:03:44 -0800 Subject: Add (currently undocumented) function 'clear_commodity' --- src/report.cc | 9 +++++++++ src/report.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/report.cc b/src/report.cc index cb7f09dc..13e6a61f 100644 --- a/src/report.cc +++ b/src/report.cc @@ -841,6 +841,13 @@ value_t report_t::fn_commodity(call_scope_t& args) return string_value(args.get(0).commodity().symbol()); } +value_t report_t::fn_clear_commodity(call_scope_t& args) +{ + amount_t amt(args.get(0)); + amt.clear_commodity(); + return amt; +} + value_t report_t::fn_nail_down(call_scope_t& args) { value_t arg0(args[0]); @@ -1384,6 +1391,8 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind, return MAKE_FUNCTOR(report_t::fn_commodity); else if (is_eq(p, "ceiling")) return MAKE_FUNCTOR(report_t::fn_ceiling); + else if (is_eq(p, "clear_commodity")) + return MAKE_FUNCTOR(report_t::fn_clear_commodity); break; case 'd': diff --git a/src/report.h b/src/report.h index 635c3887..1bda0407 100644 --- a/src/report.h +++ b/src/report.h @@ -175,6 +175,7 @@ public: value_t fn_truncated(call_scope_t& scope); value_t fn_floor(call_scope_t& scope); value_t fn_ceiling(call_scope_t& scope); + value_t fn_clear_commodity(call_scope_t& scope); value_t fn_round(call_scope_t& scope); value_t fn_roundto(call_scope_t& scope); value_t fn_unround(call_scope_t& scope); -- cgit v1.2.3