GnuCash  5.6-150-g038405b370+
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 gnu@gnu.org *
20  * *
21 \********************************************************************/
38 #ifndef GNC_TAXTABLE_H_
39 #define GNC_TAXTABLE_H_
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
62 typedef struct _gncTaxTable GncTaxTable;
63 typedef struct _gncTaxTableClass GncTaxTableClass;
64 
78 typedef enum
79 {
83 
85 typedef enum
86 {
91 
92 typedef struct _gncTaxTableEntry GncTaxTableEntry;
93 
94 typedef struct _gncAccountValue GncAccountValue;
95 
96 #include "Account.h"
97 #include "qof.h"
98 #include "gncBusiness.h"
99 #include "gncOwner.h"
100 
101 #define GNC_ID_TAXTABLE "gncTaxTable"
102 
103 /* --- type macros --- */
104 #define GNC_TYPE_TAXTABLE (gnc_taxtable_get_type ())
105 #define GNC_TAXTABLE(o) \
106  (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_TAXTABLE, GncTaxTable))
107 #define GNC_TAXTABLE_CLASS(k) \
108  (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_TAXTABLE, GncTaxTableClass))
109 #define GNC_IS_TAXTABLE(o) \
110  (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_TAXTABLE))
111 #define GNC_IS_TAXTABLE_CLASS(k) \
112  (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_TAXTABLE))
113 #define GNC_TAXTABLE_GET_CLASS(o) \
114  (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_TAXTABLE, GncTaxTableClass))
115 GType gnc_taxtable_get_type(void);
116 
117 
118 const char * gncAmountTypeToString (GncAmountType type);
119 gboolean gncAmountStringToType (const char *str, GncAmountType *type);
120 
121 const char * gncTaxIncludedTypeToString (GncTaxIncluded type);
122 gboolean gncTaxIncludedStringToType (const char *str, GncTaxIncluded *type);
123 
126 GncTaxTable * gncTaxTableCreate (QofBook *book);
127 void gncTaxTableDestroy (GncTaxTable *table);
128 GncTaxTableEntry * gncTaxTableEntryCreate (void);
129 void gncTaxTableEntryDestroy (GncTaxTableEntry *entry);
134 void gncTaxTableSetName (GncTaxTable *table, const char *name);
135 void gncTaxTableIncRef (GncTaxTable *table);
136 void gncTaxTableDecRef (GncTaxTable *table);
137 
138 void gncTaxTableEntrySetAccount (GncTaxTableEntry *entry, Account *account);
139 void gncTaxTableEntrySetType (GncTaxTableEntry *entry, GncAmountType type);
140 void gncTaxTableEntrySetAmount (GncTaxTableEntry *entry, gnc_numeric amount);
142 void gncTaxTableAddEntry (GncTaxTable *table, GncTaxTableEntry *entry);
143 void gncTaxTableRemoveEntry (GncTaxTable *table, GncTaxTableEntry *entry);
144 
145 void gncTaxTableChanged (GncTaxTable *table);
146 void gncTaxTableBeginEdit (GncTaxTable *table);
147 void gncTaxTableCommitEdit (GncTaxTable *table);
148 gboolean gncTaxTableEqual(const GncTaxTable *a, const GncTaxTable *b);
149 
157 static inline GncTaxTable *gncTaxTableLookup (const QofBook* book, const GncGUID *guid)
158 {
159  QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_TAXTABLE, GncTaxTable);
160 }
161 
162 GncTaxTable *gncTaxTableLookupByName (QofBook *book, const char *name);
163 GncTaxTable *gncTaxTableGetDefault (QofBook *book, GncOwnerType type);
164 
165 typedef GList GncTaxTableList;
166 GncTaxTableList * gncTaxTableGetTables (QofBook *book);
167 
168 const char *gncTaxTableGetName (const GncTaxTable *table);
169 GncTaxTable *gncTaxTableGetParent (const GncTaxTable *table);
170 GncTaxTable *gncTaxTableReturnChild (GncTaxTable *table, gboolean make_new);
171 #define gncTaxTableGetChild(t) gncTaxTableReturnChild((t),FALSE)
172 typedef GList GncTaxTableEntryList;
173 GncTaxTableEntryList* gncTaxTableGetEntries (const GncTaxTable *table);
174 gint64 gncTaxTableGetRefcount (const GncTaxTable *table);
175 time64 gncTaxTableLastModifiedSecs (const GncTaxTable *table);
176 
177 Account * gncTaxTableEntryGetAccount (const GncTaxTableEntry *entry);
178 GncAmountType gncTaxTableEntryGetType (const GncTaxTableEntry *entry);
179 gnc_numeric gncTaxTableEntryGetAmount (const GncTaxTableEntry *entry);
182 int gncTaxTableCompare (const GncTaxTable *a, const GncTaxTable *b);
183 int gncTaxTableEntryCompare (const GncTaxTableEntry *a, const GncTaxTableEntry *b);
184 gboolean gncTaxTableEntryEqual(const GncTaxTableEntry *a, const GncTaxTableEntry *b);
185 
186 /************************************************/
187 
189 {
190  Account * account;
191  gnc_numeric value;
192 };
193 
198 GList *gncAccountValueAdd (GList *list, Account *acc, gnc_numeric value);
199 
201 GList *gncAccountValueAddList (GList *l1, GList *l2);
202 
204 gnc_numeric gncAccountValueTotal (GList *list);
205 
207 void gncAccountValueDestroy (GList *list);
208 
210 #define GNC_TT_NAME "tax table name"
211 #define GNC_TT_REFCOUNT "reference count"
212 
214 #define gncTaxTableGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x))
215 #define gncTaxTableRetGUID(x) (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null()))
216 #define gncTaxTableLookupDirect(G,B) gncTaxTableLookup((B), &(G))
217 
218 #ifdef __cplusplus
219 }
220 #endif
221 
222 #endif /* GNC_TAXTABLE_H_ */
223 
tax is not included
Definition: gncTaxTable.h:88
Business Interface: Object OWNERs.
GncTaxIncluded
How to interpret the TaxIncluded.
Definition: gncTaxTable.h:85
STRUCTS.
tax is included
Definition: gncTaxTable.h:87
gnc_numeric gncAccountValueTotal(GList *list)
return the total for this list
Definition: gncTaxTable.c:984
#define QOF_BOOK_RETURN_ENTITY(book, guid, e_type, c_type)
Encapsulates all the information about a dataset manipulated by QOF.
Definition: qofbook.h:186
use the global setting
Definition: gncTaxTable.h:89
tax is a number
Definition: gncTaxTable.h:80
Account handling public routines.
tax is a percentage
Definition: gncTaxTable.h:81
– Business Helper Functions
void gncAccountValueDestroy(GList *list)
Destroy a list of accountvalues.
Definition: gncTaxTable.c:997
GList * gncAccountValueAddList(GList *l1, GList *l2)
Merge l2 into l1.
Definition: gncTaxTable.c:970
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition: gnc-date.h:87
GList * gncAccountValueAdd(GList *list, Account *acc, gnc_numeric value)
This will add value to the account-value for acc, creating a new list object if necessary.
Definition: gncTaxTable.c:942
The type used to store guids in C.
Definition: guid.h:75
GncAmountType
How to interpret the amount.
Definition: gncTaxTable.h:78
modtime is the internal date of the last modtime See libgnucash/engine/TaxTableBillTermImmutability.txt for an explanation of the following Code that handles refcount, parent, child, invisible and children is identical to that in ::GncBillTerm