diff options
author | John Wiegley <johnw@newartisans.com> | 2009-11-11 01:17:29 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-11-11 01:17:29 -0500 |
commit | eb772893b00119ead26d8662d73460651cafe11d (patch) | |
tree | e901434a5079b09cd67ea46e87c6a0bddc7f7ac4 /src/timelog.cc | |
parent | b62b03335f33a6a0ae422605b8b6271add849aa6 (diff) | |
download | fork-ledger-eb772893b00119ead26d8662d73460651cafe11d.tar.gz fork-ledger-eb772893b00119ead26d8662d73460651cafe11d.tar.bz2 fork-ledger-eb772893b00119ead26d8662d73460651cafe11d.zip |
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.
Diffstat (limited to 'src/timelog.cc')
-rw-r--r-- | src/timelog.cc | 23 |
1 files changed, 17 insertions, 6 deletions
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<xact_t> 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 |