GnuCash  4.8a-176-g88ecf8dd1
AccountP.h
Go to the documentation of this file.
1 /********************************************************************\
2  * AccountP.h -- Account engine-private data structure *
3  * Copyright (C) 1997 Robin D. Clark *
4  * Copyright (C) 1997-2002, Linas Vepstas <linas@linas.org> *
5  * *
6  * This program is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU General Public License as *
8  * published by the Free Software Foundation; either version 2 of *
9  * the License, or (at your option) any later version. *
10  * *
11  * This program is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License*
17  * along with this program; if not, contact: *
18  * *
19  * Free Software Foundation Voice: +1-617-542-5942 *
20  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
21  * Boston, MA 02110-1301, USA gnu@gnu.org *
22  * *
23 \********************************************************************/
24 
39 #ifndef XACC_ACCOUNT_P_H
40 #define XACC_ACCOUNT_P_H
41 
42 #include "Account.h"
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 #define GNC_ID_ROOT_ACCOUNT "RootAccount"
49 
58 typedef enum
59 {
60  Unset = -1,
61  False,
62  True
63 } TriState;
64 
66 typedef struct AccountPrivate
67 {
68  /* The accountName is an arbitrary string assigned by the user.
69  * It is intended to a short, 5 to 30 character long string that
70  * is displayed by the GUI as the account mnemonic.
71  */
72  const char *accountName;
73 
74  /* The accountCode is an arbitrary string assigned by the user.
75  * It is intended to be reporting code that is a synonym for the
76  * accountName. Typically, it will be a numeric value that follows
77  * the numbering assignments commonly used by accountants, such
78  * as 100, 200 or 600 for top-level accounts, and 101, 102.. etc.
79  * for detail accounts.
80  */
81  const char *accountCode;
82 
83  /* The description is an arbitrary string assigned by the user.
84  * It is intended to be a longer, 1-5 sentence description of what
85  * this account is all about.
86  */
87  const char *description;
88 
89  /* The type field is the account type, picked from the enumerated
90  * list that includes ACCT_TYPE_BANK, ACCT_TYPE_STOCK,
91  * ACCT_TYPE_CREDIT, ACCT_TYPE_INCOME, etc. Its intended use is to
92  * be a hint to the GUI as to how to display and format the
93  * transaction data.
94  */
95  GNCAccountType type;
96 
97  /*
98  * The commodity field denotes the kind of 'stuff' stored
99  * in this account. The 'amount' field of a split indicates
100  * how much of the 'stuff' there is.
101  */
102  gnc_commodity * commodity;
103  int commodity_scu;
104  gboolean non_standard_scu;
105 
106  /* The parent and children pointers are used to implement an account
107  * hierarchy, of accounts that have sub-accounts ("detail accounts").
108  */
109  Account *parent; /* back-pointer to parent */
110  GList *children; /* list of sub-accounts */
111 
112  /* protected data - should only be set by backends */
113  gnc_numeric starting_balance;
114  gnc_numeric starting_noclosing_balance;
115  gnc_numeric starting_cleared_balance;
116  gnc_numeric starting_reconciled_balance;
117 
118  /* cached parameters */
119  gnc_numeric balance;
120  gnc_numeric noclosing_balance;
121  gnc_numeric cleared_balance;
122  gnc_numeric reconciled_balance;
123 
124  gboolean balance_dirty; /* balances in splits incorrect */
125 
126  GList *splits; /* list of split pointers */
127  gboolean sort_dirty; /* sort order of splits is bad */
128 
129  LotList *lots; /* list of lot pointers */
130  GNCPolicy *policy; /* Cached pointer to policy method */
131 
132  TriState sort_reversed;
133  TriState equity_type;
134  char *notes;
135  char *color;
136  char *tax_us_code;
137  char *tax_us_pns;
138  char *last_num;
139  char *sort_order;
140  char *filter;
141 
142  /* The "mark" flag can be used by the user to mark this account
143  * in any way desired. Handy for specialty traversals of the
144  * account tree. */
145  short mark;
146  gboolean defer_bal_computation;
148 
149 struct account_s
150 {
151  QofInstance inst;
152 };
153 
154 /* Set the account's GncGUID. This should only be done when reading
155  * an account from a datafile, or some other external source. Never
156  * call this on an existing account! */
157 void xaccAccountSetGUID (Account *account, const GncGUID *guid);
158 
159 /* Register Accounts with the engine */
160 gboolean xaccAccountRegister (void);
161 
162 /* Structure for accessing static functions for testing */
163 typedef struct
164 {
165  AccountPrivate *(*get_private) (Account *acc);
166  Account *(*coll_get_root_account) (QofCollection *col);
167  void (*xaccFreeAccountChildren) (Account *acc);
168  void (*xaccFreeAccount) (Account *acc);
169  void (*qofAccountSetParent) (Account *acc, QofInstance *parent);
170  Account *(*gnc_account_lookup_by_full_name_helper) (const Account *acc,
171  gchar **names);
173 
174 AccountTestFunctions* _utest_account_fill_functions(void);
175 
176 #ifdef __cplusplus
177 } /* extern "C" */
178 #endif
179 
180 #endif /* XACC_ACCOUNT_P_H */
GList LotList
GList of GNCLots.
Definition: gnc-engine.h:209
Account handling public routines.
GNCAccountType
The account types are used to determine how the transaction data in the account is displayed...
Definition: Account.h:105
Account in Gnucash.
Definition: AccountP.h:149
TriState
STRUCTS.
Definition: AccountP.h:58
The type used to store guids in C.
Definition: guid.h:75