Merge branch 'next'
This commit is contained in:
commit
67ce33430c
6 changed files with 42 additions and 6 deletions
2
acprep
2
acprep
|
|
@ -385,7 +385,7 @@ class PrepareBuild(CommandLineApp):
|
|||
def current_version(self):
|
||||
if not self.current_ver:
|
||||
if exists('.git') and isdir('.git'):
|
||||
date = self.get_stdout('git', 'log', '--format=%ci', 'HEAD^..HEAD')
|
||||
date = self.get_stdout('git', 'log', '--format=%ci', '-1', 'HEAD')
|
||||
date = re.sub(" [-+][0-9][0-9][0-9][0-9]$", "", date)
|
||||
when = datetime.datetime.strptime(date, "%Y-%m-%d %H:%M:%S")
|
||||
self.current_ver = when.strftime("%Y%m%d_%H%M%S")
|
||||
|
|
|
|||
10
src/item.cc
10
src/item.cc
|
|
@ -212,23 +212,23 @@ namespace {
|
|||
else if (args[0].is_mask())
|
||||
return item.has_tag(args[0].as_mask());
|
||||
else
|
||||
throw_(std::logic_error,
|
||||
_("Expected string for argument 1, but received %1")
|
||||
throw_(std::runtime_error,
|
||||
_("Expected string or mask for argument 1, but received %1")
|
||||
<< args[0].label());
|
||||
}
|
||||
else if (args.size() == 2) {
|
||||
if (args[0].is_mask() && args[1].is_mask())
|
||||
return item.has_tag(args[0].to_mask(), args[1].to_mask());
|
||||
else
|
||||
throw_(std::logic_error,
|
||||
throw_(std::runtime_error,
|
||||
_("Expected masks for arguments 1 and 2, but received %1 and %2")
|
||||
<< args[0].label() << args[1].label());
|
||||
}
|
||||
else if (args.size() == 0) {
|
||||
throw_(std::logic_error, _("Too few arguments to function"));
|
||||
throw_(std::runtime_error, _("Too few arguments to function"));
|
||||
}
|
||||
else {
|
||||
throw_(std::logic_error, _("Too many arguments to function"));
|
||||
throw_(std::runtime_error, _("Too many arguments to function"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,6 +160,8 @@ namespace {
|
|||
value_t get_amount(post_t& post) {
|
||||
if (post.has_xdata() && post.xdata().has_flags(POST_EXT_COMPOUND))
|
||||
return post.xdata().compound_value;
|
||||
else if (post.amount.is_null())
|
||||
return 0L;
|
||||
else
|
||||
return post.amount;
|
||||
}
|
||||
|
|
@ -186,6 +188,8 @@ namespace {
|
|||
else if (post.has_xdata() &&
|
||||
post.xdata().has_flags(POST_EXT_COMPOUND))
|
||||
return post.xdata().compound_value;
|
||||
else if (post.amount.is_null())
|
||||
return 0L;
|
||||
else
|
||||
return post.amount;
|
||||
}
|
||||
|
|
@ -193,6 +197,8 @@ namespace {
|
|||
value_t get_total(post_t& post) {
|
||||
if (post.xdata_ && ! post.xdata_->total.is_null())
|
||||
return post.xdata_->total;
|
||||
else if (post.amount.is_null())
|
||||
return 0L;
|
||||
else
|
||||
return post.amount;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -313,6 +313,31 @@ value_t report_t::fn_price(call_scope_t& scope)
|
|||
return args.value_at(0).price();
|
||||
}
|
||||
|
||||
value_t report_t::fn_account_total(call_scope_t& args)
|
||||
{
|
||||
account_t * acct = NULL;
|
||||
string name;
|
||||
if (args[0].is_string()) {
|
||||
name = args[0].as_string();
|
||||
acct = session.journal->find_account(name, false);
|
||||
}
|
||||
else if (args[0].is_mask()) {
|
||||
name = args[0].as_mask().expr.str();
|
||||
acct = session.journal->find_account_re(name);
|
||||
}
|
||||
else {
|
||||
throw_(std::runtime_error,
|
||||
_("Expected string or mask for argument 1, but received %1")
|
||||
<< args[0].label());
|
||||
}
|
||||
|
||||
if (! acct)
|
||||
throw_(std::runtime_error,
|
||||
_("Could not find an account matching ") << name);
|
||||
|
||||
return acct->amount();
|
||||
}
|
||||
|
||||
value_t report_t::fn_lot_date(call_scope_t& scope)
|
||||
{
|
||||
interactive_t args(scope, "v");
|
||||
|
|
@ -730,6 +755,8 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind,
|
|||
return MAKE_FUNCTOR(report_t::fn_ansify_if);
|
||||
else if (is_eq(p, "abs"))
|
||||
return MAKE_FUNCTOR(report_t::fn_abs);
|
||||
else if (is_eq(p, "account_total"))
|
||||
return MAKE_FUNCTOR(report_t::fn_account_total);
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@ public:
|
|||
value_t fn_ansify_if(call_scope_t& scope);
|
||||
value_t fn_percent(call_scope_t& scope);
|
||||
value_t fn_price(call_scope_t& scope);
|
||||
value_t fn_account_total(call_scope_t& scope);
|
||||
value_t fn_lot_date(call_scope_t& scope);
|
||||
value_t fn_lot_price(call_scope_t& scope);
|
||||
value_t fn_lot_tag(call_scope_t& scope);
|
||||
|
|
|
|||
|
|
@ -983,6 +983,8 @@ void value_t::in_place_cast(type_t cast_type)
|
|||
if (type() == cast_type)
|
||||
return;
|
||||
|
||||
_dup();
|
||||
|
||||
if (cast_type == BOOLEAN) {
|
||||
set_boolean(bool(*this));
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue