From 4e822d213f29b0698b0b6d72286ff77fa37216d8 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 12 Jul 2005 21:35:15 +0000 Subject: [PATCH] (derive_new_entry): If no argument were given but the payee, assume the user wants to see the same transaction as last time. --- derive.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/derive.cc b/derive.cc index 3b82ddd5..bb029630 100644 --- a/derive.cc +++ b/derive.cc @@ -33,10 +33,18 @@ entry_t * derive_new_entry(journal_t& journal, added->payee = matching ? matching->payee : regexp.pattern; - if (i == end) - throw error("Too few arguments to 'entry'"); + if (i == end) { + // If no argument were given but the payee, assume the user wants + // to see the same transaction as last time. + added->state = matching->state; + added->code = matching->code; - if ((*i)[0] == '-' || std::isdigit((*i)[0])) { + for (transactions_list::iterator j = matching->transactions.begin(); + j != matching->transactions.end(); + j++) + added->add_transaction(new transaction_t(**j)); + } + else if ((*i)[0] == '-' || std::isdigit((*i)[0])) { if (! matching) throw error("Could not determine the account to draw from"); @@ -61,7 +69,8 @@ entry_t * derive_new_entry(journal_t& journal, if (acct) added->transactions.back()->account = acct; } - } else { + } + else { while (i != end) { std::string& re_pat(*i++); account_t * acct = NULL;