parent
d0dfff62a6
commit
966b6fc359
4 changed files with 16 additions and 17 deletions
|
|
@ -121,14 +121,10 @@ value_t convert_command(call_scope_t& args)
|
|||
}
|
||||
else {
|
||||
if (xact->posts.front()->account == NULL) {
|
||||
xacts_iterator xi;
|
||||
xi.xacts_i = current_xacts.begin();
|
||||
xi.xacts_end = current_xacts.end();
|
||||
xi.xacts_uninitialized = false;
|
||||
|
||||
// jww (2010-03-07): Bind this logic to an option: --auto-match
|
||||
if (account_t * acct =
|
||||
lookup_probable_account(xact->payee, xi, bucket).second)
|
||||
lookup_probable_account(xact->payee, current_xacts.rbegin(),
|
||||
current_xacts.rend(), bucket).second)
|
||||
xact->posts.front()->account = acct;
|
||||
else
|
||||
xact->posts.front()->account = unknown;
|
||||
|
|
|
|||
|
|
@ -245,12 +245,12 @@ xact_t * draft_t::insert(journal_t& journal)
|
|||
if (tmpl->payee_mask.empty())
|
||||
throw std::runtime_error(_("'xact' command requires at least a payee"));
|
||||
|
||||
xact_t * matching = NULL;
|
||||
|
||||
xact_t * matching = NULL;
|
||||
std::auto_ptr<xact_t> added(new xact_t);
|
||||
|
||||
xacts_iterator xi(journal);
|
||||
if (xact_t * xact = lookup_probable_account(tmpl->payee_mask.str(), xi).first) {
|
||||
if (xact_t * xact =
|
||||
lookup_probable_account(tmpl->payee_mask.str(), journal.xacts.rbegin(),
|
||||
journal.xacts.rend()).first) {
|
||||
DEBUG("draft.xact", "Found payee by lookup: transaction on line "
|
||||
<< xact->pos->beg_line);
|
||||
matching = xact;
|
||||
|
|
|
|||
|
|
@ -60,9 +60,10 @@ namespace {
|
|||
}
|
||||
|
||||
std::pair<xact_t *, account_t *>
|
||||
lookup_probable_account(const string& ident,
|
||||
xacts_iterator& iter_func,
|
||||
account_t * ref_account)
|
||||
lookup_probable_account(const string& ident,
|
||||
xacts_list::reverse_iterator iter,
|
||||
xacts_list::reverse_iterator end,
|
||||
account_t * ref_account)
|
||||
{
|
||||
scorecard_t scores;
|
||||
|
||||
|
|
@ -83,7 +84,8 @@ lookup_probable_account(const string& ident,
|
|||
" with reference account: " << ref_account->fullname());
|
||||
#endif
|
||||
|
||||
while (xact_t * xact = iter_func()) {
|
||||
xact_t * xact;
|
||||
while (iter != end && (xact = *iter++) != NULL) {
|
||||
#if 0
|
||||
// Only consider transactions from the last two years (jww (2010-03-07):
|
||||
// make this an option)
|
||||
|
|
|
|||
|
|
@ -47,9 +47,10 @@
|
|||
namespace ledger {
|
||||
|
||||
std::pair<xact_t *, account_t *>
|
||||
lookup_probable_account(const string& ident,
|
||||
xacts_iterator& iter_func,
|
||||
account_t * ref_account = NULL);
|
||||
lookup_probable_account(const string& ident,
|
||||
xacts_list::reverse_iterator iter,
|
||||
xacts_list::reverse_iterator end,
|
||||
account_t * ref_account = NULL);
|
||||
|
||||
} // namespace ledger
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue