diff options
author | John Wiegley <johnw@newartisans.com> | 2005-07-12 21:35:15 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 02:41:14 -0400 |
commit | 4e822d213f29b0698b0b6d72286ff77fa37216d8 (patch) | |
tree | 31ddfb32fc75e25fb71a0fe4cd2c0745653b2228 /derive.cc | |
parent | 1e6bfc7796c1dd785845b93c89baaa67a81a8f68 (diff) | |
download | fork-ledger-4e822d213f29b0698b0b6d72286ff77fa37216d8.tar.gz fork-ledger-4e822d213f29b0698b0b6d72286ff77fa37216d8.tar.bz2 fork-ledger-4e822d213f29b0698b0b6d72286ff77fa37216d8.zip |
(derive_new_entry): If no argument were given but the payee, assume
the user wants to see the same transaction as last time.
Diffstat (limited to 'derive.cc')
-rw-r--r-- | derive.cc | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -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)[0] == '-' || std::isdigit((*i)[0])) { + 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; + + 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; |