Skip to content

Commit

Permalink
Bug 476114 - Goto register by date feature req (bis)
Browse files Browse the repository at this point in the history
Addendum to c142416 - ensure the splitlist is sorted before finding
split. This ensures the correct split is found when the register has a
non-default sorting. e.g. sorting by reverse posted-date would find
the most recent split; this commit ensures the split nearest the
desired date is selected.

Also I've confirmed there's no need to clear filter; if the register
has filtered splits, the algorithm will find the nearest *visible*
split on or after the desired date.
  • Loading branch information
christopherlam committed Sep 4, 2020
1 parent 3f8ab26 commit 304e497
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions gnucash/gnome/gnc-plugin-page-register.c
Expand Up @@ -4702,7 +4702,7 @@ gnc_plugin_page_register_cmd_goto_date (GtkAction* action,
GNCSplitReg* gsr;
Query* query;
time64 date = gnc_time (NULL);
Split *split = NULL;
GList *splits;

ENTER ("(action %p, plugin_page %p)", action, page);
g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
Expand All @@ -4716,23 +4716,19 @@ gnc_plugin_page_register_cmd_goto_date (GtkAction* action,

gsr = gnc_plugin_page_register_get_gsr (GNC_PLUGIN_PAGE (page));
query = gnc_plugin_page_register_get_query (GNC_PLUGIN_PAGE (page));
splits = g_list_copy (qof_query_run (query));
splits = g_list_sort (splits, (GCompareFunc)xaccSplitOrder);

for (GList *lp = qof_query_run (query); lp; lp = lp->next)
for (GList *lp = splits; lp; lp = lp->next)
{
if (xaccTransGetDate (xaccSplitGetParent (lp->data)) >= date)
{
split = lp->data;
gnc_split_reg_jump_to_split (gsr, lp->data);
break;
}
}

/* 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(page)); */

if (split)
gnc_split_reg_jump_to_split (gsr, split);

g_list_free (splits);
LEAVE (" ");
}

Expand Down

0 comments on commit 304e497

Please sign in to comment.