mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fallback register "Jump" operation to the only other account
There may be multiple splits but only one other account. In this scenario we can jump to the first split for that account.
This commit is contained in:
parent
d924e3f624
commit
ac2511bd5a
@ -4862,6 +4862,44 @@ gnc_plugin_page_register_cmd_exchange_rate (GSimpleAction *simple,
|
||||
LEAVE (" ");
|
||||
}
|
||||
|
||||
static Split*
|
||||
jump_multiple_splits_by_single_account (Account *account, Split *split)
|
||||
{
|
||||
Transaction *trans;
|
||||
SplitList *splits;
|
||||
Account *other_account = NULL;
|
||||
Split *other_split = NULL;
|
||||
|
||||
trans = xaccSplitGetParent(split);
|
||||
if (!trans)
|
||||
return NULL;
|
||||
|
||||
for (splits = xaccTransGetSplitList(trans); splits; splits = splits->next)
|
||||
{
|
||||
Split *s = (Split*)splits->data;
|
||||
Account *a = xaccSplitGetAccount(s);
|
||||
|
||||
if (!xaccTransStillHasSplit(trans, s))
|
||||
continue;
|
||||
|
||||
if (a == account)
|
||||
continue;
|
||||
|
||||
if (other_split)
|
||||
{
|
||||
if (other_account != a)
|
||||
return NULL;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
other_account = a;
|
||||
other_split = s;
|
||||
}
|
||||
|
||||
return other_split;
|
||||
}
|
||||
|
||||
static Split*
|
||||
jump_multiple_splits_by_value (Account *account, Split *split, gboolean largest)
|
||||
{
|
||||
@ -4921,7 +4959,8 @@ jump_multiple_splits (Account* account, Split *split)
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
// If there's only one other account, use that one
|
||||
return jump_multiple_splits_by_single_account (account, split);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user