diff options
Diffstat (limited to 'src/post.cc')
-rw-r--r-- | src/post.cc | 26 |
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) { |