From ccfa8ce82c8d41f5bf91a7d4507cb9c1300b8a28 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 5 Nov 2009 04:53:04 -0500 Subject: Fix to how version numbers are generated --- acprep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acprep b/acprep index a73e81f0..302a6368 100755 --- a/acprep +++ b/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") -- cgit v1.2.3 From ab9fc6f9f0e74022d3ab09873a61450b8c0ccd82 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 5 Nov 2009 05:11:01 -0500 Subject: Changed the type being throw of some exceptions --- src/item.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/item.cc b/src/item.cc index acef2e44..f60db226 100644 --- a/src/item.cc +++ b/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; } -- cgit v1.2.3 From 4464ed187b28f9b253431e2b0dde3cb0e875b4d8 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 5 Nov 2009 05:11:15 -0500 Subject: If a posting's amount is null, return 0L --- src/post.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/post.cc b/src/post.cc index d7923866..4f45592f 100644 --- a/src/post.cc +++ b/src/post.cc @@ -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; } -- cgit v1.2.3 From deb674586cced63fc5b048d76eef477b4ae2f3c1 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 5 Nov 2009 05:11:39 -0500 Subject: Added new account_total value expression This is used for accessing an account's current total within one's Ledger file. --- src/report.cc | 27 +++++++++++++++++++++++++++ src/report.h | 1 + 2 files changed, 28 insertions(+) diff --git a/src/report.cc b/src/report.cc index e6f3ccb4..3b570682 100644 --- a/src/report.cc +++ b/src/report.cc @@ -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': diff --git a/src/report.h b/src/report.h index 32648648..431eac3c 100644 --- a/src/report.h +++ b/src/report.h @@ -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); -- cgit v1.2.3 From 09ace752d604d5afce698f7cc240e1a83cee934d Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 5 Nov 2009 05:11:50 -0500 Subject: Added missing call to _dup() in value_t::in_place_cast --- src/value.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/value.cc b/src/value.cc index a3a05b6c..4529300a 100644 --- a/src/value.cc +++ b/src/value.cc @@ -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; -- cgit v1.2.3