mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add xaccAccountTypesCompatibleWith and change xaccAccountTypesCompatible
to use that. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@14894 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
c77679c601
commit
e15f0d6a7b
@ -2179,49 +2179,52 @@ xaccAccountGetTypeFromStr (const gchar *str)
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
guint32
|
||||
xaccAccountTypesCompatibleWith (GNCAccountType type)
|
||||
{
|
||||
switch (type) {
|
||||
case ACCT_TYPE_BANK:
|
||||
case ACCT_TYPE_CASH:
|
||||
case ACCT_TYPE_ASSET:
|
||||
case ACCT_TYPE_STOCK:
|
||||
case ACCT_TYPE_MUTUAL:
|
||||
case ACCT_TYPE_CURRENCY:
|
||||
case ACCT_TYPE_CREDIT:
|
||||
case ACCT_TYPE_LIABILITY:
|
||||
case ACCT_TYPE_RECEIVABLE:
|
||||
case ACCT_TYPE_PAYABLE:
|
||||
return
|
||||
(1 << ACCT_TYPE_BANK) |
|
||||
(1 << ACCT_TYPE_CASH) |
|
||||
(1 << ACCT_TYPE_ASSET) |
|
||||
(1 << ACCT_TYPE_STOCK) |
|
||||
(1 << ACCT_TYPE_MUTUAL) |
|
||||
(1 << ACCT_TYPE_CURRENCY) |
|
||||
(1 << ACCT_TYPE_CREDIT) |
|
||||
(1 << ACCT_TYPE_LIABILITY) |
|
||||
(1 << ACCT_TYPE_RECEIVABLE) |
|
||||
(1 << ACCT_TYPE_PAYABLE);
|
||||
case ACCT_TYPE_INCOME:
|
||||
case ACCT_TYPE_EXPENSE:
|
||||
return
|
||||
(1 << ACCT_TYPE_INCOME) |
|
||||
(1 << ACCT_TYPE_EXPENSE);
|
||||
case ACCT_TYPE_EQUITY:
|
||||
return
|
||||
(1 << ACCT_TYPE_EQUITY);
|
||||
default:
|
||||
PERR("bad account type: %d", type);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
xaccAccountTypesCompatible (GNCAccountType parent_type,
|
||||
GNCAccountType child_type)
|
||||
{
|
||||
gboolean compatible = FALSE;
|
||||
|
||||
switch(parent_type)
|
||||
{
|
||||
case ACCT_TYPE_BANK:
|
||||
case ACCT_TYPE_CASH:
|
||||
case ACCT_TYPE_ASSET:
|
||||
case ACCT_TYPE_STOCK:
|
||||
case ACCT_TYPE_MUTUAL:
|
||||
case ACCT_TYPE_CURRENCY:
|
||||
case ACCT_TYPE_CREDIT:
|
||||
case ACCT_TYPE_LIABILITY:
|
||||
case ACCT_TYPE_RECEIVABLE:
|
||||
case ACCT_TYPE_PAYABLE:
|
||||
compatible = ((child_type == ACCT_TYPE_BANK) ||
|
||||
(child_type == ACCT_TYPE_CASH) ||
|
||||
(child_type == ACCT_TYPE_ASSET) ||
|
||||
(child_type == ACCT_TYPE_STOCK) ||
|
||||
(child_type == ACCT_TYPE_MUTUAL) ||
|
||||
(child_type == ACCT_TYPE_CURRENCY) ||
|
||||
(child_type == ACCT_TYPE_CREDIT) ||
|
||||
(child_type == ACCT_TYPE_LIABILITY)||
|
||||
(child_type == ACCT_TYPE_RECEIVABLE)||
|
||||
(child_type == ACCT_TYPE_PAYABLE));
|
||||
break;
|
||||
case ACCT_TYPE_INCOME:
|
||||
case ACCT_TYPE_EXPENSE:
|
||||
compatible = ((child_type == ACCT_TYPE_INCOME) ||
|
||||
(child_type == ACCT_TYPE_EXPENSE));
|
||||
break;
|
||||
case ACCT_TYPE_EQUITY:
|
||||
compatible = (child_type == ACCT_TYPE_EQUITY);
|
||||
break;
|
||||
default:
|
||||
PERR("bad account type: %d", parent_type);
|
||||
break;
|
||||
}
|
||||
|
||||
return compatible;
|
||||
return ((xaccAccountTypesCompatibleWith (parent_type) &
|
||||
(1 << child_type))
|
||||
!= 0);
|
||||
}
|
||||
|
||||
guint32
|
||||
|
@ -523,6 +523,9 @@ const char * xaccAccountGetTypeStr (GNCAccountType type);
|
||||
* to the local language. */
|
||||
GNCAccountType xaccAccountGetTypeFromStr (const gchar *str);
|
||||
|
||||
/** Return the bitmask of account types compatible with a given type. */
|
||||
guint32 xaccAccountTypesCompatibleWith (GNCAccountType type);
|
||||
|
||||
/** Return TRUE if accounts of type parent_type can have accounts
|
||||
* of type child_type as children. */
|
||||
gboolean xaccAccountTypesCompatible (GNCAccountType parent_type,
|
||||
|
Loading…
Reference in New Issue
Block a user