GnuCash 2.4.99
AccountP.h
Go to the documentation of this file.
00001 /********************************************************************\
00002  * AccountP.h -- Account engine-private data structure              *
00003  * Copyright (C) 1997 Robin D. Clark                                *
00004  * Copyright (C) 1997-2002, Linas Vepstas <linas@linas.org>         *
00005  *                                                                  *
00006  * This program is free software; you can redistribute it and/or    *
00007  * modify it under the terms of the GNU General Public License as   *
00008  * published by the Free Software Foundation; either version 2 of   *
00009  * the License, or (at your option) any later version.              *
00010  *                                                                  *
00011  * This program is distributed in the hope that it will be useful,  *
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00014  * GNU General Public License for more details.                     *
00015  *                                                                  *
00016  * You should have received a copy of the GNU General Public License*
00017  * along with this program; if not, contact:                        *
00018  *                                                                  *
00019  * Free Software Foundation           Voice:  +1-617-542-5942       *
00020  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00021  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
00022  *                                                                  *
00023 \********************************************************************/
00024 
00039 #ifndef XACC_ACCOUNT_P_H
00040 #define XACC_ACCOUNT_P_H
00041 
00042 #include "Account.h"
00043 
00044 #define GNC_ID_ROOT_ACCOUNT        "RootAccount"
00045 
00055 typedef struct AccountPrivate
00056 {
00057     /* The accountName is an arbitrary string assigned by the user.
00058      * It is intended to a short, 5 to 30 character long string that
00059      * is displayed by the GUI as the account mnemonic.
00060      */
00061     char *accountName;
00062 
00063     /* The accountCode is an arbitrary string assigned by the user.
00064      * It is intended to be reporting code that is a synonym for the
00065      * accountName. Typically, it will be a numeric value that follows
00066      * the numbering assignments commonly used by accountants, such
00067      * as 100, 200 or 600 for top-level accounts, and 101, 102..  etc.
00068      * for detail accounts.
00069      */
00070     char *accountCode;
00071 
00072     /* The description is an arbitrary string assigned by the user.
00073      * It is intended to be a longer, 1-5 sentence description of what
00074      * this account is all about.
00075      */
00076     char *description;
00077 
00078     /* The type field is the account type, picked from the enumerated
00079      * list that includes ACCT_TYPE_BANK, ACCT_TYPE_STOCK,
00080      * ACCT_TYPE_CREDIT, ACCT_TYPE_INCOME, etc.  Its intended use is to
00081      * be a hint to the GUI as to how to display and format the
00082      * transaction data.
00083      */
00084     GNCAccountType type;
00085 
00086     /*
00087      * The commodity field denotes the kind of 'stuff' stored
00088      * in this account.  The 'amount' field of a split indicates
00089      * how much of the 'stuff' there is.
00090      */
00091     gnc_commodity * commodity;
00092     int commodity_scu;
00093     gboolean non_standard_scu;
00094 
00095     /* The parent and children pointers are used to implement an account
00096      * hierarchy, of accounts that have sub-accounts ("detail accounts").
00097      */
00098     Account *parent;    /* back-pointer to parent */
00099     GList *children;    /* list of sub-accounts */
00100 
00101     /* protected data - should only be set by backends */
00102     gnc_numeric starting_balance;
00103     gnc_numeric starting_cleared_balance;
00104     gnc_numeric starting_reconciled_balance;
00105 
00106     /* cached parameters */
00107     gnc_numeric balance;
00108     gnc_numeric cleared_balance;
00109     gnc_numeric reconciled_balance;
00110 
00111     gboolean balance_dirty;     /* balances in splits incorrect */
00112 
00113     GList *splits;              /* list of split pointers */
00114     gboolean sort_dirty;        /* sort order of splits is bad */
00115 
00116     LotList   *lots;            /* list of lot pointers */
00117     GNCPolicy *policy;          /* Cached pointer to policy method */
00118 
00119     /* The "mark" flag can be used by the user to mark this account
00120      * in any way desired.  Handy for specialty traversals of the
00121      * account tree. */
00122     short mark;
00123 } AccountPrivate;
00124 
00125 struct account_s
00126 {
00127     QofInstance inst;
00128 };
00129 
00130 /* Set the account's GncGUID. This should only be done when reading
00131  * an account from a datafile, or some other external source. Never
00132  * call this on an existing account! */
00133 void xaccAccountSetGUID (Account *account, const GncGUID *guid);
00134 
00135 /* Register Accounts with the engine */
00136 gboolean xaccAccountRegister (void);
00137 
00138 /* Structure for accessing static functions for testing */
00139 typedef struct
00140 {
00141     AccountPrivate *(*get_private) (Account *acc);
00142     Account *(*coll_get_root_account) (QofCollection *col);
00143     void (*xaccFreeAccountChildren) (Account *acc);
00144     void (*xaccFreeAccount) (Account *acc);
00145     void (*qofAccountSetParent) (Account *acc, QofInstance *parent);
00146     Account *(*gnc_account_lookup_by_full_name_helper) (const Account *acc,
00147             gchar **names);
00148 } AccountTestFunctions;
00149 
00150 AccountTestFunctions* _utest_account_fill_functions(void);
00151 
00152 
00153 #endif /* XACC_ACCOUNT_P_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines