diff options
author | John Wiegley <johnw@newartisans.com> | 2010-02-04 19:47:16 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-02-05 00:00:29 -0500 |
commit | 9d61d3d621606f0158a048628c866a692465d886 (patch) | |
tree | 797067970e5b81543ece809d03bf5c7170b4a052 /src | |
parent | b78e22d52b75cafd63678ee786b1653afffa49e6 (diff) | |
download | fork-ledger-9d61d3d621606f0158a048628c866a692465d886.tar.gz fork-ledger-9d61d3d621606f0158a048628c866a692465d886.tar.bz2 fork-ledger-9d61d3d621606f0158a048628c866a692465d886.zip |
Added actual_date() methods for items
Diffstat (limited to 'src')
-rw-r--r-- | src/item.cc | 5 | ||||
-rw-r--r-- | src/item.h | 4 | ||||
-rw-r--r-- | src/post.cc | 12 | ||||
-rw-r--r-- | src/post.h | 1 |
4 files changed, 22 insertions, 0 deletions
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<date_t> 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': @@ -173,6 +173,10 @@ public: return *effective; return *_date; } + virtual date_t actual_date() const { + assert(_date); + return *_date; + } virtual optional<date_t> 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<date_t> post_t::effective_date() const { optional<date_t> date = item_t::effective_date(); @@ -105,6 +105,7 @@ public: const optional<mask_t>& value_mask = none) const; virtual date_t date() const; + virtual date_t actual_date() const; virtual optional<date_t> effective_date() const; bool must_balance() const { |