diff options
author | John Wiegley <johnw@newartisans.com> | 2012-11-12 02:29:10 -0600 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-11-12 02:30:04 -0600 |
commit | 63712728e1e39557aa8ec35e1a4cf4e56c83e121 (patch) | |
tree | cadd507ab12e6eca27a238e4673c29e461ad284c /src/xact.cc | |
parent | 484e54c2b38e373adfa2c7956f804ca1f7414a0e (diff) | |
download | fork-ledger-63712728e1e39557aa8ec35e1a4cf4e56c83e121.tar.gz fork-ledger-63712728e1e39557aa8ec35e1a4cf4e56c83e121.tar.bz2 fork-ledger-63712728e1e39557aa8ec35e1a4cf4e56c83e121.zip |
Properly handle metadata tags on auto-postings
Diffstat (limited to 'src/xact.cc')
-rw-r--r-- | src/xact.cc | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/xact.cc b/src/xact.cc index cac19a02..7888dadf 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -645,6 +645,18 @@ namespace { } } +static string apply_format(const string& str, scope_t& scope) +{ + if (contains(str, "%(")) { + format_t str_format(str); + std::ostringstream buf; + buf << str_format(scope); + return buf.str(); + } else { + return str; + } +} + void auto_xact_t::extend_xact(xact_base_t& xact, parse_context_t& context) { posts_list initial_posts(xact.posts.begin(), xact.posts.end()); @@ -696,8 +708,9 @@ void auto_xact_t::extend_xact(xact_base_t& xact, parse_context_t& context) if (deferred_notes) { foreach (deferred_tag_data_t& data, *deferred_notes) { if (data.apply_to_post == NULL) - initial_post->parse_tags(data.tag_data.c_str(), bound_scope, - data.overwrite_existing); + initial_post->append_note( + apply_format(data.tag_data, bound_scope).c_str(), + bound_scope, data.overwrite_existing); } } @@ -776,7 +789,7 @@ void auto_xact_t::extend_xact(xact_base_t& xact, parse_context_t& context) account = account->parent; account = account->find_account(fullname); } - else if (contains(fullname, "%")) { + else if (contains(fullname, "%(")) { format_t account_name(fullname); std::ostringstream buf; buf << account_name(bound_scope); @@ -804,9 +817,11 @@ void auto_xact_t::extend_xact(xact_base_t& xact, parse_context_t& context) if (deferred_notes) { foreach (deferred_tag_data_t& data, *deferred_notes) { - if (! data.apply_to_post || data.apply_to_post == post) - new_post->parse_tags(data.tag_data.c_str(), bound_scope, - data.overwrite_existing); + if (! data.apply_to_post || data.apply_to_post == post) { + new_post->append_note( + apply_format(data.tag_data, bound_scope).c_str(), + bound_scope, data.overwrite_existing); + } } } |