Bug 797301/2 - Sub-account register not seeing changes to sub accounts.

If you have a sub account register open and you create another account
that is a descendant of the top account the transaction will not be
seen as the query used for the sub account register does not include
the new account. Add a check to 'refresh_handler' to check for the same
number of sub accounts, if different recreate query.
This commit is contained in:
Robert Fewell 2019-07-16 13:30:01 +01:00
parent b56203e06f
commit 69f76c6378

View File

@ -71,6 +71,8 @@ struct gnc_ledger_display
gpointer user_data; gpointer user_data;
gint number_of_subaccounts;
gint component_id; gint component_id;
}; };
@ -87,9 +89,13 @@ gnc_ledger_display_internal (Account *lead_account, Query *q,
SplitRegisterStyle style, SplitRegisterStyle style,
gboolean use_double_line, gboolean use_double_line,
gboolean is_template); gboolean is_template);
static void gnc_ledger_display_refresh_internal (GNCLedgerDisplay *ld, static void gnc_ledger_display_refresh_internal (GNCLedgerDisplay *ld,
GList *splits); GList *splits);
static void gnc_ledger_display_make_query (GNCLedgerDisplay *ld,
gint limit,
SplitRegisterType type);
/** Implementations *************************************************/ /** Implementations *************************************************/
@ -572,6 +578,21 @@ refresh_handler (GHashTable *changes, gpointer user_data)
} }
} }
/* if subaccount ledger, check to see if still the same number
* of subaccounts, if not recreate the query. */
if (ld->ld_type == LD_SUBACCOUNT)
{
Account *leader = gnc_ledger_display_leader (ld);
GList *accounts = gnc_account_get_descendants (leader);
if (g_list_length (accounts) != ld->number_of_subaccounts)
gnc_ledger_display_make_query (ld,
gnc_prefs_get_float(GNC_PREFS_GROUP_GENERAL_REGISTER, GNC_PREF_MAX_TRANS),
gnc_get_reg_type (leader, ld->ld_type));
g_list_free (accounts);
}
/* Its not clear if we should re-run the query, or if we should /* 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 * just use qof_query_last_run(). Its possible that the dates
* changed, requiring a full new query. Similar considerations * changed, requiring a full new query. Similar considerations
@ -647,8 +668,14 @@ gnc_ledger_display_make_query (GNCLedgerDisplay *ld,
leader = gnc_ledger_display_leader (ld); leader = gnc_ledger_display_leader (ld);
/* if this is a subaccount ledger, record the number of
* subaccounts so we can determine if the query needs
* recreating on a refresh. */
if (ld->ld_type == LD_SUBACCOUNT) if (ld->ld_type == LD_SUBACCOUNT)
{
accounts = gnc_account_get_descendants (leader); accounts = gnc_account_get_descendants (leader);
ld->number_of_subaccounts = g_list_length (accounts);
}
else else
accounts = NULL; accounts = NULL;