diff options
Diffstat (limited to 'src/post.cc')
-rw-r--r-- | src/post.cc | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/post.cc b/src/post.cc index 675749fc..4fc34892 100644 --- a/src/post.cc +++ b/src/post.cc @@ -39,40 +39,42 @@ namespace ledger { -bool post_t::has_tag(const string& tag) const +bool post_t::has_tag(const string& tag, bool inherit) const { if (item_t::has_tag(tag)) return true; - if (xact) + if (inherit && xact) return xact->has_tag(tag); return false; } bool post_t::has_tag(const mask_t& tag_mask, - const optional<mask_t>& value_mask) const + const optional<mask_t>& value_mask, + bool inherit) const { if (item_t::has_tag(tag_mask, value_mask)) return true; - if (xact) + if (inherit && xact) return xact->has_tag(tag_mask, value_mask); return false; } -optional<value_t> post_t::get_tag(const string& tag) const +optional<value_t> post_t::get_tag(const string& tag, bool inherit) const { if (optional<value_t> value = item_t::get_tag(tag)) return value; - if (xact) + if (inherit && xact) return xact->get_tag(tag); return none; } optional<value_t> post_t::get_tag(const mask_t& tag_mask, - const optional<mask_t>& value_mask) const + const optional<mask_t>& value_mask, + bool inherit) const { if (optional<value_t> value = item_t::get_tag(tag_mask, value_mask)) return value; - if (xact) + if (inherit && xact) return xact->get_tag(tag_mask, value_mask); return none; } @@ -123,6 +125,14 @@ optional<date_t> post_t::effective_date() const return date; } +string post_t::payee() const +{ + if (optional<value_t> post_payee = get_tag(_("Payee"))) + return post_payee->as_string(); + else + return xact->payee; +} + namespace { value_t get_this(post_t& post) { return scope_value(&post); @@ -160,7 +170,7 @@ namespace { } value_t get_payee(post_t& post) { - return string_value(post.xact->payee); + return string_value(post.payee()); } value_t get_note(post_t& post) { |