summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/post.h2
-rw-r--r--src/textual.cc2
-rw-r--r--src/xact.cc34
-rw-r--r--test/regress/25A099C9.test20
4 files changed, 41 insertions, 17 deletions
diff --git a/src/post.h b/src/post.h
index a9a44a79..c9aec6b2 100644
--- a/src/post.h
+++ b/src/post.h
@@ -83,7 +83,7 @@ public:
const optional<string>& _note = none)
: item_t(_flags, _note), xact(NULL), account(_account), amount(_amount)
{
- TRACE_CTOR(post_t, "account_t *, const amount_t&, flags_t, const optional<string>&");
+ TRACE_CTOR(post_t, "account_t *, amount_t, flags_t, optional<string>");
}
post_t(const post_t& post)
: item_t(post),
diff --git a/src/textual.cc b/src/textual.cc
index 8a055251..6106914f 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -575,7 +575,7 @@ void instance_t::automated_xact_directive(char * line)
item = ae.get();
// This is a trailing note, and possibly a metadata info tag
- item->append_note(p + 1, *context.scope, true);
+ ae->append_note(p + 1, *context.scope, true);
item->add_flags(ITEM_NOTE_ON_NEXT_LINE);
item->pos->end_pos = context.curr_pos;
item->pos->end_line++;
diff --git a/src/xact.cc b/src/xact.cc
index ec1d372c..7888dadf 100644
--- a/src/xact.cc
+++ b/src/xact.cc
@@ -36,6 +36,7 @@
#include "account.h"
#include "journal.h"
#include "context.h"
+#include "format.h"
#include "pool.h"
namespace ledger {
@@ -644,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());
@@ -695,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);
}
}
@@ -775,6 +789,14 @@ 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, "%(")) {
+ format_t account_name(fullname);
+ std::ostringstream buf;
+ buf << account_name(bound_scope);
+ while (account->parent)
+ account = account->parent;
+ account = account->find_account(buf.str());
+ }
// Copy over details so that the resulting post is a mirror of
// the automated xact's one.
@@ -795,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);
+ }
}
}
diff --git a/test/regress/25A099C9.test b/test/regress/25A099C9.test
index d4eab662..fb362a4b 100644
--- a/test/regress/25A099C9.test
+++ b/test/regress/25A099C9.test
@@ -20,24 +20,24 @@ While parsing file "$sourcepath/src/amount.h", line 121:
Error: Unexpected whitespace at beginning of line
While parsing file "$sourcepath/src/amount.h", line 132:
Error: Unexpected whitespace at beginning of line
-While parsing file "$sourcepath/src/amount.h", line 702:
+While parsing file "$sourcepath/src/amount.h", line 711:
Error: Unexpected whitespace at beginning of line
-While parsing file "$sourcepath/src/amount.h", line 732:
+While parsing file "$sourcepath/src/amount.h", line 741:
Error: Unexpected whitespace at beginning of line
-While parsing file "$sourcepath/src/amount.h", line 740:
+While parsing file "$sourcepath/src/amount.h", line 749:
Error: Unexpected whitespace at beginning of line
-While parsing file "$sourcepath/src/amount.h", line 743:
+While parsing file "$sourcepath/src/amount.h", line 752:
Error: Invalid date/time: line amount_t amoun
-While parsing file "$sourcepath/src/amount.h", line 749:
+While parsing file "$sourcepath/src/amount.h", line 758:
Error: Invalid date/time: line string amount_
-While parsing file "$sourcepath/src/amount.h", line 755:
+While parsing file "$sourcepath/src/amount.h", line 764:
Error: Invalid date/time: line string amount_
-While parsing file "$sourcepath/src/amount.h", line 761:
+While parsing file "$sourcepath/src/amount.h", line 770:
Error: Invalid date/time: line string amount_
-While parsing file "$sourcepath/src/amount.h", line 767:
+While parsing file "$sourcepath/src/amount.h", line 776:
Error: Invalid date/time: line std::ostream&
-While parsing file "$sourcepath/src/amount.h", line 774:
+While parsing file "$sourcepath/src/amount.h", line 783:
Error: Invalid date/time: line std::istream&
-While parsing file "$sourcepath/src/amount.h", line 780:
+While parsing file "$sourcepath/src/amount.h", line 789:
Error: Unexpected whitespace at beginning of line
end test