Skip to content

Commit

Permalink
When using "Jump" with more than two splits, expand the transaction
Browse files Browse the repository at this point in the history
If there are more than two splits it may not be obvious why a transaction
has been selected in the basic register mode, so expand the transaction to
show the split that's in this register and also to indicate which split was
followed to reach this transaction.
  • Loading branch information
nomis committed Feb 5, 2025
1 parent bdf7c36 commit c23d8cd
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions gnucash/gnome/gnc-plugin-page-register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4985,6 +4985,8 @@ gnc_plugin_page_register_cmd_jump (GSimpleAction *simple,
Account* account;
Account* leader;
Split* split;
Split* other_split;
gboolean multiple_splits;

ENTER ("(action %p, page %p)", simple, page);

Expand Down Expand Up @@ -5013,6 +5015,9 @@ gnc_plugin_page_register_cmd_jump (GSimpleAction *simple,
return;
}

other_split = xaccSplitGetOtherSplit (split);
multiple_splits = other_split == NULL;

leader = gnc_ledger_display_leader (priv->ledger);
if (account == leader)
{
Expand Down Expand Up @@ -5040,8 +5045,7 @@ gnc_plugin_page_register_cmd_jump (GSimpleAction *simple,
return;
}

Split* other_split = xaccSplitGetOtherSplit (split);
if (other_split == NULL)
if (multiple_splits)
{
other_split = jump_multiple_splits (account, split);
}
Expand Down Expand Up @@ -5105,11 +5109,30 @@ gnc_plugin_page_register_cmd_jump (GSimpleAction *simple,
gnc_main_window_open_page (GNC_MAIN_WINDOW (window), new_page);
gsr = gnc_plugin_page_register_get_gsr (new_page);

SplitRegister *new_page_reg = gnc_ledger_display_get_split_register (gsr->ledger);
gboolean jump_twice = FALSE;

/* Selecting the split (instead of just the transaction to open the "other"
* account) requires jumping a second time after expanding the transaction,
* in the basic and auto ledger modes.
*/
if (new_page_reg->style != REG_STYLE_JOURNAL)
jump_twice = TRUE;

/* Test for visibility of split */
if (gnc_split_reg_clear_filter_for_split (gsr, split))
gnc_plugin_page_register_clear_current_filter (GNC_PLUGIN_PAGE(new_page));

gnc_split_reg_jump_to_split (gsr, split);

if (multiple_splits && jump_twice)
{
/* Expand the transaction for the basic and auto ledger to identify the
* split in this register, but only if there are more than two splits.
*/
gnc_split_register_expand_current_trans (new_page_reg, TRUE);
gnc_split_reg_jump_to_split (gsr, split);
}
LEAVE (" ");
}

Expand Down

0 comments on commit c23d8cd

Please sign in to comment.