diff options
-rw-r--r-- | src/item.cc | 15 | ||||
-rw-r--r-- | src/report.cc | 2 | ||||
-rw-r--r-- | src/report.h | 11 |
3 files changed, 16 insertions, 12 deletions
diff --git a/src/item.cc b/src/item.cc index 4fcaea21..426a2f1c 100644 --- a/src/item.cc +++ b/src/item.cc @@ -158,11 +158,12 @@ void item_t::parse_tags(const char * p, int current_year) void item_t::append_note(const char * p, int current_year) { - if (note) + if (note) { + *note += '\n'; *note += p; - else + } else { note = p; - *note += '\n'; + } parse_tags(p, current_year); } @@ -251,15 +252,17 @@ namespace { value_t get_comment(item_t& item) { if (! item.note) { - return false; + return string_value(""); } else { + // jww (2009-03-01): If the comment is a short one-liner, put it at the + // end of the post/xact std::ostringstream buf; buf << "\n ;"; bool need_separator = false; for (const char * p = item.note->c_str(); *p; p++) { - if (*p == '\n') + if (*p == '\n') { need_separator = true; - else { + } else { if (need_separator) { buf << "\n ;"; need_separator = false; diff --git a/src/report.cc b/src/report.cc index 1cba0160..0b3d625a 100644 --- a/src/report.cc +++ b/src/report.cc @@ -267,6 +267,8 @@ value_t report_t::fn_join(call_scope_t& args) foreach (const char ch, args[0].to_string()) if (ch != '\n') out << ch; + else + out << "\\n"; return string_value(out.str()); } diff --git a/src/report.h b/src/report.h index 0397e989..951c8873 100644 --- a/src/report.h +++ b/src/report.h @@ -301,10 +301,9 @@ public: "%(quoted(payee))," "%(quoted(account))," "%(quoted(scrub(display_amount)))," - "%(quoted((cleared or xact.cleared) ?" - " \"*\" : ((pending or xact.pending) ? \"!\" : \"\")))," + "%(quoted(cleared ? \"*\" : (pending ? \"!\" : \"\")))," "%(quoted(code))," - "%(quoted(join(note)))\n"); + "%(quoted(join(note | xact.note)))\n"); }); OPTION_(report_t, current, DO() { // -c @@ -521,21 +520,21 @@ public: " \"=\" + format_date(xact.effective_date, \"%Y/%m/%d\") : \"\")" "%(xact.cleared ? \" *\" : (xact.pending ? \" !\" : \"\"))" "%(code ? \" (\" + code + \")\" :" - " \"\") %(payee)%(xact.comment | \"\")\n" + " \"\") %(payee)%(xact.comment)\n" " %(xact.uncleared ?" " (cleared ? \"* \" : (pending ? \"! \" : \"\")) : \"\")" "%-34(account)" " %12(calculated ? \"\" : justify(scrub(amount), 12, -1, true))" "%(has_cost & !cost_calculated ?" " \" @ \" + justify(scrub(abs(cost / amount)), 0) : \"\")" - "%(comment | \"\")\n%/" + "%(comment)\n%/" " %(xact.uncleared ?" " (cleared ? \"* \" : (pending ? \"! \" : \"\")) : \"\")" "%-34(account)" " %12(calculated ? \"\" : justify(scrub(amount), 12, -1, true))" "%(has_cost & !cost_calculated ?" " \" @ \" + justify(scrub(abs(cost / amount)), 0) : \"\")" - "%(comment | \"\")\n%/\n"); + "%(comment)\n%/\n"); }); OPTION_(report_t, quantity, DO() { // -O |