diff --git a/src/engine/AccInfo.c b/src/engine/AccInfo.c index d0b2f3115e..6bbeb30c11 100644 --- a/src/engine/AccInfo.c +++ b/src/engine/AccInfo.c @@ -25,6 +25,11 @@ #include "messages.h" #include "util.h" + +/* This static indicates the debugging module that this .o belongs to. */ +static short module = MOD_ENGINE; + + /* =========================================================== */ #define GNC_RETURN_ENUM_AS_STRING(x) case x: return #x; @@ -85,6 +90,48 @@ char * xaccAccountGetTypeStr (int type) return (account_type_name [type]); } +/* =========================================================== */ +gncBoolean +xaccAccountTypesCompatible (int parent_type, int child_type) +{ + gncBoolean compatible = GNC_F; + + switch(parent_type) + { + case BANK: + case CASH: + case ASSET: + case STOCK: + case MUTUAL: + case CURRENCY: + compatible = ((child_type == BANK) || + (child_type == CASH) || + (child_type == ASSET) || + (child_type == STOCK) || + (child_type == MUTUAL) || + (child_type == CURRENCY)); + break; + case CREDIT: + case LIABILITY: + compatible = ((child_type == CREDIT) || (child_type == LIABILITY)); + break; + case INCOME: + compatible = (child_type == INCOME); + break; + case EXPENSE: + compatible = (child_type == EXPENSE); + break; + case EQUITY: + compatible = (child_type == EQUITY); + break; + default: + PERR("xaccAccountTypesCompatible: bad account type: %d", parent_type); + break; + } + + return compatible; +} + /* =========================================================== */ AccInfo * diff --git a/src/engine/AccInfo.h b/src/engine/AccInfo.h index add8481336..a36fbe1a24 100644 --- a/src/engine/AccInfo.h +++ b/src/engine/AccInfo.h @@ -27,6 +27,8 @@ #define __ACCINFO_H__ #include "config.h" +#include "gnc-common.h" + /* * The account types are used to determine how the transaction data @@ -41,6 +43,9 @@ enum { + BAD_TYPE = -1, + /* Not a type */ + BANK = 0, /* The bank account type denotes a savings or checking account * held at a bank. Often interest bearing. @@ -102,6 +107,9 @@ char * xaccAccountGetTypeStr (int type); /* GUI names */ Used for text exports */ char * xaccAccountTypeEnumAsString (int type); +gncBoolean xaccAccountTypesCompatible (int parent_type, int child_type); + + typedef struct _BankAcct BankAcct; typedef struct _InvAcct InvAcct; typedef union _AccInfo AccInfo;