mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
xaccAccountTypes was backwards
vs. the documentation. The unit tests and dialog-account were similarly backwards, but the use in gnucash/import-export/ofx followed the docs.
This commit is contained in:
parent
2e7fcad833
commit
2258e7a44e
@ -589,7 +589,7 @@ make_children_compatible (AccountWindow *aw)
|
||||
account = aw_get_account (aw);
|
||||
g_return_if_fail (account);
|
||||
|
||||
if (xaccAccountTypesCompatible (xaccAccountGetType (account), aw->type))
|
||||
if (xaccAccountTypesCompatible (aw->type, xaccAccountGetType (account)))
|
||||
return;
|
||||
|
||||
set_children_types (account, aw->type);
|
||||
@ -709,7 +709,7 @@ verify_children_compatible (AccountWindow *aw)
|
||||
if (!account)
|
||||
return FALSE;
|
||||
|
||||
if (xaccAccountTypesCompatible (xaccAccountGetType (account), aw->type))
|
||||
if (xaccAccountTypesCompatible (aw->type, xaccAccountGetType (account)))
|
||||
return TRUE;
|
||||
|
||||
if (gnc_account_n_children(account) == 0)
|
||||
|
@ -4509,8 +4509,17 @@ gboolean
|
||||
xaccAccountTypesCompatible (GNCAccountType parent_type,
|
||||
GNCAccountType child_type)
|
||||
{
|
||||
return ((xaccParentAccountTypesCompatibleWith (parent_type) &
|
||||
(1 << child_type))
|
||||
/* ACCT_TYPE_NONE isn't compatible with anything, even ACCT_TYPE_NONE. */
|
||||
if (parent_type == ACCT_TYPE_NONE || child_type == ACCT_TYPE_NONE)
|
||||
return FALSE;
|
||||
|
||||
/* ACCT_TYPE_ROOT can't have a parent account, and asking will raise
|
||||
* an error. */
|
||||
if (child_type == ACCT_TYPE_ROOT)
|
||||
return FALSE;
|
||||
|
||||
return ((xaccParentAccountTypesCompatibleWith (child_type) &
|
||||
(1 << parent_type))
|
||||
!= 0);
|
||||
}
|
||||
|
||||
|
@ -2251,9 +2251,8 @@ test_xaccAccountType_Compatibility (void)
|
||||
auto check2 = test_error_struct_new(logdomain, loglevel, msg2);
|
||||
gint loghandler;
|
||||
|
||||
for (type = ACCT_TYPE_BANK; type < NUM_ACCOUNT_TYPES; type = ++type)
|
||||
for (type = ACCT_TYPE_BANK; type < NUM_ACCOUNT_TYPES; ++type)
|
||||
{
|
||||
GNCAccountType child;
|
||||
if (type == ACCT_TYPE_ROOT)
|
||||
{
|
||||
loghandler = g_log_set_handler (logdomain, loglevel,
|
||||
@ -2278,11 +2277,11 @@ test_xaccAccountType_Compatibility (void)
|
||||
g_assert_cmpint (compat, == , equity_compat);
|
||||
else if (type == ACCT_TYPE_TRADING)
|
||||
g_assert_cmpint (compat, == , trading_compat);
|
||||
for (child = ACCT_TYPE_NONE; child < ACCT_TYPE_LAST; child = ++child)
|
||||
if (1 << child & compat)
|
||||
g_assert (xaccAccountTypesCompatible (type, child));
|
||||
for (auto parent = ACCT_TYPE_NONE; parent < ACCT_TYPE_LAST; ++parent)
|
||||
if (1 << parent & compat)
|
||||
g_assert (xaccAccountTypesCompatible (parent, type));
|
||||
else
|
||||
g_assert (!xaccAccountTypesCompatible (type, child));
|
||||
g_assert (!xaccAccountTypesCompatible (parent, type));
|
||||
|
||||
compat = xaccAccountTypesCompatibleWith (type);
|
||||
if (type <= ACCT_TYPE_LIABILITY ||
|
||||
|
Loading…
Reference in New Issue
Block a user