Bug 741674 - Newly created Scheduled Transactions appear in existing search windows

When a search is done from the 'find' on the accounts page, the search
is across all accounts and is displayed in SEARCH_LEDGER. If one of
these transactions is used for the basis of a scheduled transaction,
the created scheduled transaction is displayed with today's date in the
existing search results and also the general ledger with the transfer
accounts being displayed with GUID's of the template accounts.

Fixed by excluding template accounts from the SEARCH_LEDGER and the GL.
This commit is contained in:
Robert Fewell 2022-01-25 16:46:35 +00:00
parent 85be581e97
commit 8a0d4af128
2 changed files with 28 additions and 43 deletions

View File

@ -193,35 +193,7 @@ gnc_ui_find_transactions_dialog_create(GtkWindow *parent, GNCLedgerDisplay * ori
{
start_q = qof_query_create ();
qof_query_set_book (start_q, gnc_get_current_book ());
/* In lieu of not "mis-using" some portion of the infrastructure by writing
* a bunch of new code, we just filter out the accounts of the template
* transactions. While these are in a separate Account trees just for this
* reason, the query engine makes no distinction between Account trees.
* See Gnome Bug 86302.
* -- jsled
*
* copied from gnc-ledger-display.c:gnc_ledger_display_gl() -- warlord
*
* <jsled> Alternatively, you could look for a GNC_SX_ACCOUNT [SchedAction.h]
* key in the KVP frame of the split.
*/
{
Account *tRoot;
GList *al;
tRoot = gnc_book_get_template_root( gnc_get_current_book() );
al = gnc_account_get_descendants( tRoot );
if (g_list_length(al) != 0)
xaccQueryAddAccountMatch( start_q, al, QOF_GUID_MATCH_NONE, QOF_QUERY_AND );
g_list_free (al);
al = NULL;
tRoot = NULL;
}
ftd->q = start_q; /* save this to destroy it later */
ftd->q = start_q; // save this to destroy it later
}
ftd->parent = parent;

View File

@ -167,6 +167,23 @@ gnc_ledger_display_get_query (GNCLedgerDisplay* ld)
return ld->query;
}
static void
exclude_template_accounts (Query* q)
{
Account* tRoot;
GList* al;
tRoot = gnc_book_get_template_root (gnc_get_current_book());
al = gnc_account_get_descendants (tRoot);
if (gnc_list_length_cmp (al, 0))
xaccQueryAddAccountMatch (q, al, QOF_GUID_MATCH_NONE, QOF_QUERY_AND);
g_list_free (al);
al = NULL;
tRoot = NULL;
}
static gboolean
find_by_leader (gpointer find_data, gpointer user_data)
{
@ -423,20 +440,8 @@ gnc_ledger_display_gl (void)
* reason, the query engine makes no distinction between Account trees.
* See Gnome Bug 86302.
* -- jsled */
{
Account* tRoot;
GList* al;
tRoot = gnc_book_get_template_root (gnc_get_current_book());
al = gnc_account_get_descendants (tRoot);
if (gnc_list_length_cmp (al, 0))
xaccQueryAddAccountMatch (query, al, QOF_GUID_MATCH_NONE, QOF_QUERY_AND);
g_list_free (al);
al = NULL;
tRoot = NULL;
}
// Exclude any template accounts for search register and gl
exclude_template_accounts (query);
gnc_tm_get_today_start (&tm);
tm.tm_mon--; /* Default the register to the last month's worth of transactions. */
@ -604,6 +609,10 @@ refresh_handler (GHashTable* changes, gpointer user_data)
g_list_free (accounts);
}
// Exclude any template accounts for search register and gl
if (!ld->reg->is_template && (ld->reg->type == SEARCH_LEDGER || ld->ld_type == LD_GL))
exclude_template_accounts (ld->query);
/* Its not clear if we should re-run the query, or if we should
* just use qof_query_last_run(). Its possible that the dates
* changed, requiring a full new query. Similar considerations
@ -895,6 +904,10 @@ gnc_ledger_display_refresh (GNCLedgerDisplay* ld)
return;
}
// Exclude any template accounts for search register and gl
if (!ld->reg->is_template && (ld->reg->type == SEARCH_LEDGER || ld->ld_type == LD_GL))
exclude_template_accounts (ld->query);
gnc_ledger_display_refresh_internal (ld, qof_query_run (ld->query));
LEAVE (" ");
}