gnucash maint: Bug 476114 - Goto register by date feature req (bis)
Christopher Lam
clam at code.gnucash.org
Thu Sep 3 21:53:59 EDT 2020
Updated via https://github.com/Gnucash/gnucash/commit/304e4972 (commit)
from https://github.com/Gnucash/gnucash/commit/3f8ab268 (commit)
commit 304e4972433aca6a0dd634bdef720b46e18781a1
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Sep 4 00:29:28 2020 +0800
Bug 476114 - Goto register by date feature req (bis)
Addendum to c14241644 - 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.
diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c
index b75bf72af..4bb4d44e0 100644
--- a/gnucash/gnome/gnc-plugin-page-register.c
+++ b/gnucash/gnome/gnc-plugin-page-register.c
@@ -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));
@@ -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 (" ");
}
Summary of changes:
gnucash/gnome/gnc-plugin-page-register.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
More information about the gnucash-changes
mailing list