summaryrefslogtreecommitdiff
path: root/src/post.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-02-05 05:35:14 -0500
committerJohn Wiegley <johnw@newartisans.com>2010-02-05 05:35:14 -0500
commit547137096051ab985dca6f8e5c7be191b62ccb0c (patch)
tree2f3a39c4b71b8cb8b232502401e8dd2c8c2247ef /src/post.cc
parentc6873d32aa121289e87be7eb16ff531c6d468d2a (diff)
parent69da18cd303b10f9badd542141ffdfd546009508 (diff)
downloadfork-ledger-547137096051ab985dca6f8e5c7be191b62ccb0c.tar.gz
fork-ledger-547137096051ab985dca6f8e5c7be191b62ccb0c.tar.bz2
fork-ledger-547137096051ab985dca6f8e5c7be191b62ccb0c.zip
Merge branch 'next'
Diffstat (limited to 'src/post.cc')
-rw-r--r--src/post.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/post.cc b/src/post.cc
index 34284e1b..43cfe55f 100644
--- a/src/post.cc
+++ b/src/post.cc
@@ -97,6 +97,18 @@ date_t post_t::date() const
return *_date;
}
+date_t post_t::actual_date() const
+{
+ if (xdata_ && is_valid(xdata_->date))
+ return xdata_->date;
+
+ if (! _date) {
+ assert(xact);
+ return xact->date();
+ }
+ return *_date;
+}
+
optional<date_t> post_t::effective_date() const
{
optional<date_t> date = item_t::effective_date();
@@ -405,6 +417,20 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
return item_t::lookup(kind, name);
}
+amount_t post_t::resolve_expr(scope_t& scope, expr_t& expr)
+{
+ bind_scope_t bound_scope(scope, *this);
+ value_t result(expr.calc(bound_scope));
+ if (result.is_long()) {
+ return result.to_amount();
+ } else {
+ if (! result.is_amount())
+ throw_(amount_error,
+ _("Amount expressions must result in a simple amount"));
+ return result.as_amount();
+ }
+}
+
bool post_t::valid() const
{
if (! xact) {