GnuCash  5.6-139-g03622b03d0+
AccountP.hpp
Go to the documentation of this file.
1 /********************************************************************\
2  * AccountP.hpp -- 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 <vector>
43 #include <optional>
44 
45 #include "Account.h"
46 
47 #define GNC_ID_ROOT_ACCOUNT "RootAccount"
48 
58 typedef struct AccountPrivate
59 {
60  /* The accountName is an arbitrary string assigned by the user.
61  * It is intended to be a short, 5 to 30 character long string that
62  * is displayed by the GUI as the account mnemonic.
63  */
64  const char *accountName;
65 
66  /* The accountCode is an arbitrary string assigned by the user.
67  * It is intended to be reporting code that is a synonym for the
68  * accountName. Typically, it will be a numeric value that follows
69  * the numbering assignments commonly used by accountants, such
70  * as 100, 200 or 600 for top-level accounts, and 101, 102.. etc.
71  * for detail accounts.
72  */
73  const char *accountCode;
74 
75  /* The description is an arbitrary string assigned by the user.
76  * It is intended to be a longer, 1-5 sentence description of what
77  * this account is all about.
78  */
79  const char *description;
80 
81  /* The type field is the account type, picked from the enumerated
82  * list that includes ACCT_TYPE_BANK, ACCT_TYPE_STOCK,
83  * ACCT_TYPE_CREDIT, ACCT_TYPE_INCOME, etc. Its intended use is to
84  * be a hint to the GUI as to how to display and format the
85  * transaction data.
86  */
87  GNCAccountType type;
88 
89  /*
90  * The commodity field denotes the kind of 'stuff' stored
91  * in this account. The 'amount' field of a split indicates
92  * how much of the 'stuff' there is.
93  */
94  gnc_commodity * commodity;
95  int commodity_scu;
96  gboolean non_standard_scu;
97 
98  /* The parent and children pointers are used to implement an account
99  * hierarchy, of accounts that have sub-accounts ("detail accounts").
100  */
101  Account *parent; /* back-pointer to parent */
102  GList *children; /* list of sub-accounts */
103 
104  /* protected data - should only be set by backends */
105  gnc_numeric starting_balance;
106  gnc_numeric starting_noclosing_balance;
107  gnc_numeric starting_cleared_balance;
108  gnc_numeric starting_reconciled_balance;
109 
110  /* cached parameters */
111  gnc_numeric balance;
112  gnc_numeric noclosing_balance;
113  gnc_numeric cleared_balance;
114  gnc_numeric reconciled_balance;
115 
116  std::optional<gnc_numeric> higher_balance_limit;
117  std::optional<gnc_numeric> lower_balance_limit;
118  std::optional<bool> include_sub_account_balances;
119 
120  gboolean balance_dirty; /* balances in splits incorrect */
121 
122  std::vector<Split*> splits; /* list of split pointers */
123  GHashTable* splits_hash;
124  gboolean sort_dirty; /* sort order of splits is bad */
125 
126  LotList *lots; /* list of lot pointers */
127  GNCPolicy *policy; /* Cached pointer to policy method */
128 
129  char *notes;
130  char *color;
131  char *tax_us_code;
132  char *tax_us_pns;
133  char *last_num;
134  char *sort_order;
135  char *filter;
136 
137  /* The "mark" flag can be used by the user to mark this account
138  * in any way desired. Handy for specialty traversals of the
139  * account tree. */
140  short mark;
141  gboolean defer_bal_computation;
143 
144 struct account_s
145 {
146  QofInstance inst;
147 };
148 
149 /* Set the account's GncGUID. This should only be done when reading
150  * an account from a datafile, or some other external source. Never
151  * call this on an existing account! */
152 void xaccAccountSetGUID (Account *account, const GncGUID *guid);
153 
154 /* Register Accounts with the engine */
155 gboolean xaccAccountRegister (void);
156 
157 /* Structure for accessing static functions for testing */
158 typedef struct
159 {
160  AccountPrivate *(*get_private) (Account *acc);
161  Account *(*coll_get_root_account) (QofCollection *col);
162  void (*xaccFreeAccountChildren) (Account *acc);
163  void (*xaccFreeAccount) (Account *acc);
164  void (*qofAccountSetParent) (Account *acc, QofInstance *parent);
165  Account *(*gnc_account_lookup_by_full_name_helper) (const Account *acc,
166  gchar **names);
168 
169 AccountTestFunctions* _utest_account_fill_functions(void);
170 
171 #endif /* XACC_ACCOUNT_P_H */
GList LotList
GList of GNCLots.
Definition: gnc-engine.h:205
STRUCTS.
Account handling public routines.
GNCAccountType
The account types are used to determine how the transaction data in the account is displayed...
Definition: Account.h:101
Account in Gnucash.
Definition: AccountP.hpp:144
The type used to store guids in C.
Definition: guid.h:75