mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[Scrub.c] 8628ca8715 rewritten to avoid QofQuery
because QofQuery will include the blank transaction which must not be scrubbed.
This commit is contained in:
@@ -53,8 +53,6 @@
|
|||||||
#include "gnc-commodity.h"
|
#include "gnc-commodity.h"
|
||||||
#include "qofinstance-p.h"
|
#include "qofinstance-p.h"
|
||||||
#include "gnc-session.h"
|
#include "gnc-session.h"
|
||||||
#include "qofquery.h"
|
|
||||||
#include "Query.h"
|
|
||||||
|
|
||||||
#undef G_LOG_DOMAIN
|
#undef G_LOG_DOMAIN
|
||||||
#define G_LOG_DOMAIN "gnc.engine.scrub"
|
#define G_LOG_DOMAIN "gnc.engine.scrub"
|
||||||
@@ -91,18 +89,22 @@ gnc_get_ongoing_scrub (void)
|
|||||||
|
|
||||||
/* ================================================================ */
|
/* ================================================================ */
|
||||||
|
|
||||||
|
static void add_transactions (const Account *account, GHashTable **ht)
|
||||||
|
{
|
||||||
|
for (GList *m = xaccAccountGetSplitList (account); m; m = g_list_next (m))
|
||||||
|
g_hash_table_add (*ht, xaccSplitGetParent (m->data));
|
||||||
|
}
|
||||||
|
|
||||||
static GList*
|
static GList*
|
||||||
get_all_transactions (Account *account, bool descendants)
|
get_all_transactions (Account *account, bool descendants)
|
||||||
{
|
{
|
||||||
GList *accounts = descendants ? gnc_account_get_descendants (account) : NULL;
|
GHashTable *ht = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||||
accounts = g_list_prepend (accounts, account);
|
add_transactions (account, &ht);
|
||||||
QofQuery *q = qof_query_create_for (GNC_ID_TRANS);
|
if (descendants)
|
||||||
QofBook *book = qof_session_get_book (gnc_get_current_session ());
|
gnc_account_foreach_descendant (account, (AccountCb)add_transactions, &ht);
|
||||||
qof_query_set_book (q, book);
|
GList *rv = g_hash_table_get_keys (ht);
|
||||||
xaccQueryAddAccountMatch (q, accounts, QOF_GUID_MATCH_ANY, QOF_QUERY_AND);
|
g_hash_table_destroy (ht);
|
||||||
GList *transactions = g_list_copy (qof_query_run (q));
|
return rv;
|
||||||
qof_query_destroy (q);
|
|
||||||
return transactions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================================ */
|
/* ================================================================ */
|
||||||
|
|||||||
Reference in New Issue
Block a user