Bug 799298 - Shortcut Ctrl-G does not work in the General Journal register for the default date value

The split list in the General Journal register contains the blank
splits of other open registers which the GUI hides in
split-register-load.c. As they are not entered, the entered date value
is 0 and they will be listed before any split with the default date
value. If such a split is used, nothing will happen.

To fix this use the same test to ignore these blank splits.
This commit is contained in:
Robert Fewell
2024-05-15 10:46:06 +01:00
parent 48185684ea
commit bc5cac4aa2

View File

@@ -4674,6 +4674,15 @@ gnc_plugin_page_register_cmd_blank_transaction (GSimpleAction *simple,
LEAVE (" ");
}
static bool
find_after_date (Split *split, time64* find_date)
{
auto trans = xaccSplitGetParent (split);
return !(xaccSplitGetAccount (split) != nullptr &&
xaccTransGetDate (trans) >= *find_date &&
xaccTransCountSplits (trans) != 1);
}
static void
gnc_plugin_page_register_cmd_goto_date (GSimpleAction *simple,
GVariant *paramter,
@@ -4689,6 +4698,7 @@ gnc_plugin_page_register_cmd_goto_date (GSimpleAction *simple,
g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
auto date = input_date (window, _("Go to Date"), _("Go to Date"));
if (!date)
{
LEAVE ("goto_date cancelled");
@@ -4700,14 +4710,14 @@ gnc_plugin_page_register_cmd_goto_date (GSimpleAction *simple,
splits = g_list_copy (qof_query_run (query));
splits = g_list_sort (splits, (GCompareFunc)xaccSplitOrder);
for (GList *lp = splits; lp; lp = lp->next)
{
if (xaccTransGetDate (xaccSplitGetParent (GNC_SPLIT(lp->data))) >= date.value())
{
gnc_split_reg_jump_to_split (gsr, GNC_SPLIT(lp->data));
break;
}
}
// if gl register, there could be blank splits from other open registers
// included in split list so check for and ignore them
auto it = g_list_find_custom (splits, &date.value(), (GCompareFunc)find_after_date);
if (it)
gnc_split_reg_jump_to_split (gsr, GNC_SPLIT(it->data));
else
gnc_split_reg_jump_to_blank (gsr);
g_list_free (splits);
LEAVE (" ");