Add (currently undocumented) function 'clear_commodity'

This commit is contained in:
John Wiegley 2018-02-16 23:03:44 -08:00
parent 7097e1a1e7
commit fbccb7149e
2 changed files with 10 additions and 0 deletions

View file

@ -841,6 +841,13 @@ value_t report_t::fn_commodity(call_scope_t& args)
return string_value(args.get<amount_t>(0).commodity().symbol()); return string_value(args.get<amount_t>(0).commodity().symbol());
} }
value_t report_t::fn_clear_commodity(call_scope_t& args)
{
amount_t amt(args.get<amount_t>(0));
amt.clear_commodity();
return amt;
}
value_t report_t::fn_nail_down(call_scope_t& args) value_t report_t::fn_nail_down(call_scope_t& args)
{ {
value_t arg0(args[0]); 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); return MAKE_FUNCTOR(report_t::fn_commodity);
else if (is_eq(p, "ceiling")) else if (is_eq(p, "ceiling"))
return MAKE_FUNCTOR(report_t::fn_ceiling); return MAKE_FUNCTOR(report_t::fn_ceiling);
else if (is_eq(p, "clear_commodity"))
return MAKE_FUNCTOR(report_t::fn_clear_commodity);
break; break;
case 'd': case 'd':

View file

@ -175,6 +175,7 @@ public:
value_t fn_truncated(call_scope_t& scope); value_t fn_truncated(call_scope_t& scope);
value_t fn_floor(call_scope_t& scope); value_t fn_floor(call_scope_t& scope);
value_t fn_ceiling(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_round(call_scope_t& scope);
value_t fn_roundto(call_scope_t& scope); value_t fn_roundto(call_scope_t& scope);
value_t fn_unround(call_scope_t& scope); value_t fn_unround(call_scope_t& scope);