From eb772893b00119ead26d8662d73460651cafe11d Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 11 Nov 2009 01:17:29 -0500 Subject: Timeclock entries can now have notes Example of a tagged entry: i 2009/11/01 12:00:00 Account Payee ; :Foo: o 2009/11/01 13:00:00 Two spaces or a tab must separate account from payee, and payee from note. --- src/timelog.cc | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src/timelog.cc') diff --git a/src/timelog.cc b/src/timelog.cc index f7b79b9a..dc3d3496 100644 --- a/src/timelog.cc +++ b/src/timelog.cc @@ -44,6 +44,7 @@ namespace { const datetime_t& when, account_t * account, const char * desc, + const char * note, journal_t& journal) { time_xact_t event; @@ -82,11 +83,19 @@ namespace { desc = NULL; } + if (note && event.note.empty()) { + event.note = note; + note = NULL; + } + std::auto_ptr curr(new xact_t); curr->_date = when.date(); curr->code = desc ? desc : ""; curr->payee = event.desc; + if (! event.note.empty()) + curr->append_note(event.note.c_str()); + if (when < event.checkin) throw parse_error (_("Timelog check-out date less than corresponding check-in")); @@ -119,8 +128,8 @@ time_log_t::~time_log_t() accounts.push_back(time_xact.account); foreach (account_t * account, accounts) - clock_out_from_timelog(time_xacts, CURRENT_TIME(), account, NULL, - journal); + clock_out_from_timelog(time_xacts, CURRENT_TIME(), account, + NULL, NULL, journal); assert(time_xacts.empty()); } @@ -128,9 +137,10 @@ time_log_t::~time_log_t() void time_log_t::clock_in(const datetime_t& checkin, account_t * account, - const string& desc) + const string& desc, + const string& note) { - time_xact_t event(checkin, account, desc); + time_xact_t event(checkin, account, desc, note); if (! time_xacts.empty()) { foreach (time_xact_t& time_xact, time_xacts) { @@ -144,13 +154,14 @@ void time_log_t::clock_in(const datetime_t& checkin, void time_log_t::clock_out(const datetime_t& checkin, account_t * account, - const string& desc) + const string& desc, + const string& note) { if (time_xacts.empty()) throw std::logic_error(_("Timelog check-out event without a check-in")); clock_out_from_timelog(time_xacts, checkin, account, desc.c_str(), - journal); + note.c_str(), journal); } } // namespace ledger -- cgit v1.2.3