deprecate xaccAccountCountSplits with include_children = FALSE

whereby xaccAccountCountSplits is called with with_children = FALSE,
test xaccAccountGetSplitList against NULL.
This commit is contained in:
Christopher Lam 2020-09-30 09:49:07 +08:00
parent 1b31c06b29
commit e6486e9d95
3 changed files with 11 additions and 5 deletions

View File

@ -1389,7 +1389,7 @@ gnc_account_window_create(GtkWindow *parent, AccountWindow *aw)
&aw->commodity_mode);
// If the account has transactions, prevent changes by displaying a label and tooltip
if (xaccAccountCountSplits (aw_get_account (aw), FALSE) > 0)
if (xaccAccountGetSplitList (aw_get_account (aw)) != NULL)
{
const gchar *sec_name = gnc_commodity_get_printname (xaccAccountGetCommodity(aw_get_account (aw)));
GtkWidget *label = gtk_label_new (sec_name);
@ -1473,7 +1473,7 @@ gnc_account_window_create(GtkWindow *parent, AccountWindow *aw)
// immutable if gnucash depends on details that would be lost/missing
// if changing from/to such a type. At the time of this writing the
// immutable types are AR, AP and trading types.
if (xaccAccountCountSplits (aw_get_account (aw), FALSE) > 0)
if (xaccAccountGetSplitList (aw_get_account (aw)) != NULL)
{
GNCAccountType atype = xaccAccountGetType (aw_get_account (aw));
compat_types = xaccAccountTypesCompatibleWith (atype);

View File

@ -1643,7 +1643,7 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
}
// If no transaction or children just delete it.
if (!(xaccAccountCountSplits (account, FALSE) ||
if (!(xaccAccountGetSplitList (account) != NULL ||
gnc_account_n_children (account)))
{
do_delete_account (account, NULL, NULL, NULL);

View File

@ -175,6 +175,12 @@ test_invoice_post ( Fixture *fixture, gconstpointer pData )
g_assert(!gncInvoiceIsPosted(fixture->invoice));
}
static gboolean account_has_one_split (const Account *acc)
{
GList *splits = xaccAccountGetSplitList (acc);
return (splits && !(splits->next));
}
static void
test_invoice_posted_trans ( Fixture *fixture, gconstpointer pData )
{
@ -183,8 +189,8 @@ test_invoice_posted_trans ( Fixture *fixture, gconstpointer pData )
gnc_numeric total = gncInvoiceGetTotal(fixture->invoice);
gnc_numeric acct_balance, acct2_balance;
g_assert (1 == xaccAccountCountSplits (fixture->account, FALSE));
g_assert (1 == xaccAccountCountSplits (fixture->account2, FALSE));
g_assert (account_has_one_split (fixture->account));
g_assert (account_has_one_split (fixture->account2));
acct_balance = xaccAccountGetBalance(fixture->account);
acct2_balance = xaccAccountGetBalance(fixture->account2);