GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gncTaxTable.h
Go to the documentation of this file.
1 /********************************************************************\
2  * gncTaxTable.h -- the Gnucash Tax Table interface *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License as *
6  * published by the Free Software Foundation; either version 2 of *
7  * the License, or (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License*
15  * along with this program; if not, contact: *
16  * *
17  * Free Software Foundation Voice: +1-617-542-5942 *
18  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
19  * Boston, MA 02110-1301, USA [email protected] *
20  * *
21 \********************************************************************/
31 #ifndef GNC_TAXTABLE_H_
32 #define GNC_TAXTABLE_H_
33 
51 typedef struct _gncTaxTable GncTaxTable;
52 typedef struct _gncTaxTableClass GncTaxTableClass;
53 
63 typedef struct _gncTaxTableEntry GncTaxTableEntry;
64 
65 typedef struct _gncAccountValue GncAccountValue;
66 
67 #include "Account.h"
68 #include "qof.h"
69 #ifdef GNUCASH_MAJOR_VERSION
70 #include "gncBusiness.h"
71 #endif
72 
73 #define GNC_ID_TAXTABLE "gncTaxTable"
74 
75 /* --- type macros --- */
76 #define GNC_TYPE_TAXTABLE (gnc_taxtable_get_type ())
77 #define GNC_TAXTABLE(o) \
78  (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_TAXTABLE, GncTaxTable))
79 #define GNC_TAXTABLE_CLASS(k) \
80  (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_TAXTABLE, GncTaxTableClass))
81 #define GNC_IS_TAXTABLE(o) \
82  (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_TAXTABLE))
83 #define GNC_IS_TAXTABLE_CLASS(k) \
84  (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_TAXTABLE))
85 #define GNC_TAXTABLE_GET_CLASS(o) \
86  (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_TAXTABLE, GncTaxTableClass))
87 GType gnc_taxtable_get_type(void);
88 
93 typedef enum
94 {
98 
100 typedef enum
101 {
106 
107 const char * gncAmountTypeToString (GncAmountType type);
108 gboolean gncAmountStringToType (const char *str, GncAmountType *type);
109 
110 const char * gncTaxIncludedTypeToString (GncTaxIncluded type);
111 gboolean gncTaxIncludedStringToType (const char *str, GncTaxIncluded *type);
112 
115 GncTaxTable * gncTaxTableCreate (QofBook *book);
116 void gncTaxTableDestroy (GncTaxTable *table);
117 GncTaxTableEntry * gncTaxTableEntryCreate (void);
118 void gncTaxTableEntryDestroy (GncTaxTableEntry *entry);
123 void gncTaxTableSetName (GncTaxTable *table, const char *name);
124 void gncTaxTableIncRef (GncTaxTable *table);
125 void gncTaxTableDecRef (GncTaxTable *table);
126 
127 void gncTaxTableEntrySetAccount (GncTaxTableEntry *entry, Account *account);
128 void gncTaxTableEntrySetType (GncTaxTableEntry *entry, GncAmountType type);
129 void gncTaxTableEntrySetAmount (GncTaxTableEntry *entry, gnc_numeric amount);
131 void gncTaxTableAddEntry (GncTaxTable *table, GncTaxTableEntry *entry);
132 void gncTaxTableRemoveEntry (GncTaxTable *table, GncTaxTableEntry *entry);
133 
134 void gncTaxTableChanged (GncTaxTable *table);
135 void gncTaxTableBeginEdit (GncTaxTable *table);
136 void gncTaxTableCommitEdit (GncTaxTable *table);
137 gboolean gncTaxTableEqual(const GncTaxTable *a, const GncTaxTable *b);
138 
148 static inline GncTaxTable *gncTaxTableLookup (const QofBook* book, const GncGUID *guid)
149 {
150  QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_TAXTABLE, GncTaxTable);
151 }
152 
153 GncTaxTable *gncTaxTableLookupByName (QofBook *book, const char *name);
154 
155 GList * gncTaxTableGetTables (QofBook *book);
156 
157 const char *gncTaxTableGetName (const GncTaxTable *table);
158 GncTaxTable *gncTaxTableGetParent (const GncTaxTable *table);
159 GncTaxTable *gncTaxTableReturnChild (GncTaxTable *table, gboolean make_new);
160 #define gncTaxTableGetChild(t) gncTaxTableReturnChild((t),FALSE)
161 typedef GList GncTaxTableEntryList;
162 GncTaxTableEntryList* gncTaxTableGetEntries (const GncTaxTable *table);
163 gint64 gncTaxTableGetRefcount (const GncTaxTable *table);
164 Timespec gncTaxTableLastModified (const GncTaxTable *table);
165 
166 Account * gncTaxTableEntryGetAccount (const GncTaxTableEntry *entry);
167 GncAmountType gncTaxTableEntryGetType (const GncTaxTableEntry *entry);
168 gnc_numeric gncTaxTableEntryGetAmount (const GncTaxTableEntry *entry);
171 int gncTaxTableCompare (const GncTaxTable *a, const GncTaxTable *b);
172 int gncTaxTableEntryCompare (const GncTaxTableEntry *a, const GncTaxTableEntry *b);
173 gboolean gncTaxTableEntryEqual(const GncTaxTableEntry *a, const GncTaxTableEntry *b);
174 
175 /************************************************/
176 
178 {
179  Account * account;
180  gnc_numeric value;
181 };
182 
187 GList *gncAccountValueAdd (GList *list, Account *acc, gnc_numeric value);
188 
190 GList *gncAccountValueAddList (GList *l1, GList *l2);
191 
193 gnc_numeric gncAccountValueTotal (GList *list);
194 
196 void gncAccountValueDestroy (GList *list);
197 
199 #define GNC_TT_NAME "tax table name"
200 #define GNC_TT_REFCOUNT "reference count"
201 
203 #define gncTaxTableGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x))
204 #define gncTaxTableRetGUID(x) (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null()))
205 #define gncTaxTableLookupDirect(G,B) gncTaxTableLookup((B), &(G))
206 
207 #endif /* GNC_TAXTABLE_H_ */
208 
GncTaxIncluded
Definition: gncTaxTable.h:100
Use a 64-bit unsigned int timespec.
Definition: gnc-date.h:299
gnc_numeric gncAccountValueTotal(GList *list)
Definition: gncTaxTable.c:965
#define QOF_BOOK_RETURN_ENTITY(book, guid, e_type, c_type)
Encapsulates all the information about a dataset manipulated by QOF. This is the top-most structure u...
Definition: qofbook.h:164
Definition: guid.h:65
Account handling public routines.
void gncAccountValueDestroy(GList *list)
Definition: gncTaxTable.c:978
GList * gncAccountValueAddList(GList *l1, GList *l2)
Definition: gncTaxTable.c:951
GList * gncAccountValueAdd(GList *list, Account *acc, gnc_numeric value)
Definition: gncTaxTable.c:923
GncAmountType
Definition: gncTaxTable.h:93