diff --git a/src/item.cc b/src/item.cc index 135fa18f..8d1ba34f 100644 --- a/src/item.cc +++ b/src/item.cc @@ -199,6 +199,9 @@ namespace { value_t get_date(item_t& item) { return item.date(); } + value_t get_actual_date(item_t& item) { + return item.actual_date(); + } value_t get_effective_date(item_t& item) { if (optional effective = item.effective_date()) return *effective; @@ -351,6 +354,8 @@ expr_t::ptr_op_t item_t::lookup(const symbol_t::kind_t kind, case 'a': if (name == "actual") return WRAP_FUNCTOR(get_wrapper<&get_actual>); + else if (name == "actual_date") + return WRAP_FUNCTOR(get_wrapper<&get_actual_date>); break; case 'b': diff --git a/src/item.h b/src/item.h index 8250ab6e..f23350fc 100644 --- a/src/item.h +++ b/src/item.h @@ -173,6 +173,10 @@ public: return *effective; return *_date; } + virtual date_t actual_date() const { + assert(_date); + return *_date; + } virtual optional effective_date() const { return _date_eff; } diff --git a/src/post.cc b/src/post.cc index 34284e1b..5b9d2bb3 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 post_t::effective_date() const { optional date = item_t::effective_date(); diff --git a/src/post.h b/src/post.h index a0ab5ffd..cea1aca1 100644 --- a/src/post.h +++ b/src/post.h @@ -105,6 +105,7 @@ public: const optional& value_mask = none) const; virtual date_t date() const; + virtual date_t actual_date() const; virtual optional effective_date() const; bool must_balance() const {