GnuCash  5.0
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 \********************************************************************/
31 #ifndef GNC_TAXTABLE_H_
32 #define GNC_TAXTABLE_H_
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
55 typedef struct _gncTaxTable GncTaxTable;
56 typedef struct _gncTaxTableClass GncTaxTableClass;
57 
71 typedef enum
72 {
76 
78 typedef enum
79 {
84 
85 typedef struct _gncTaxTableEntry GncTaxTableEntry;
86 
87 typedef struct _gncAccountValue GncAccountValue;
88 
89 #include "Account.h"
90 #include "qof.h"
91 #include "gncBusiness.h"
92 #include "gncOwner.h"
93 
94 #define GNC_ID_TAXTABLE "gncTaxTable"
95 
96 /* --- type macros --- */
97 #define GNC_TYPE_TAXTABLE (gnc_taxtable_get_type ())
98 #define GNC_TAXTABLE(o) \
99  (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_TAXTABLE, GncTaxTable))
100 #define GNC_TAXTABLE_CLASS(k) \
101  (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_TAXTABLE, GncTaxTableClass))
102 #define GNC_IS_TAXTABLE(o) \
103  (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_TAXTABLE))
104 #define GNC_IS_TAXTABLE_CLASS(k) \
105  (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_TAXTABLE))
106 #define GNC_TAXTABLE_GET_CLASS(o) \
107  (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_TAXTABLE, GncTaxTableClass))
108 GType gnc_taxtable_get_type(void);
109 
110 
111 const char * gncAmountTypeToString (GncAmountType type);
112 gboolean gncAmountStringToType (const char *str, GncAmountType *type);
113 
114 const char * gncTaxIncludedTypeToString (GncTaxIncluded type);
115 gboolean gncTaxIncludedStringToType (const char *str, GncTaxIncluded *type);
116 
119 GncTaxTable * gncTaxTableCreate (QofBook *book);
120 void gncTaxTableDestroy (GncTaxTable *table);
121 GncTaxTableEntry * gncTaxTableEntryCreate (void);
122 void gncTaxTableEntryDestroy (GncTaxTableEntry *entry);
127 void gncTaxTableSetName (GncTaxTable *table, const char *name);
128 void gncTaxTableIncRef (GncTaxTable *table);
129 void gncTaxTableDecRef (GncTaxTable *table);
130 
131 void gncTaxTableEntrySetAccount (GncTaxTableEntry *entry, Account *account);
132 void gncTaxTableEntrySetType (GncTaxTableEntry *entry, GncAmountType type);
133 void gncTaxTableEntrySetAmount (GncTaxTableEntry *entry, gnc_numeric amount);
135 void gncTaxTableAddEntry (GncTaxTable *table, GncTaxTableEntry *entry);
136 void gncTaxTableRemoveEntry (GncTaxTable *table, GncTaxTableEntry *entry);
137 
138 void gncTaxTableChanged (GncTaxTable *table);
139 void gncTaxTableBeginEdit (GncTaxTable *table);
140 void gncTaxTableCommitEdit (GncTaxTable *table);
141 gboolean gncTaxTableEqual(const GncTaxTable *a, const GncTaxTable *b);
142 
150 static inline GncTaxTable *gncTaxTableLookup (const QofBook* book, const GncGUID *guid)
151 {
152  QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_TAXTABLE, GncTaxTable);
153 }
154 
155 GncTaxTable *gncTaxTableLookupByName (QofBook *book, const char *name);
156 GncTaxTable *gncTaxTableGetDefault (QofBook *book, GncOwnerType type);
157 
158 typedef GList GncTaxTableList;
159 GncTaxTableList * gncTaxTableGetTables (QofBook *book);
160 
161 const char *gncTaxTableGetName (const GncTaxTable *table);
162 GncTaxTable *gncTaxTableGetParent (const GncTaxTable *table);
163 GncTaxTable *gncTaxTableReturnChild (GncTaxTable *table, gboolean make_new);
164 #define gncTaxTableGetChild(t) gncTaxTableReturnChild((t),FALSE)
165 typedef GList GncTaxTableEntryList;
166 GncTaxTableEntryList* gncTaxTableGetEntries (const GncTaxTable *table);
167 gint64 gncTaxTableGetRefcount (const GncTaxTable *table);
168 time64 gncTaxTableLastModifiedSecs (const GncTaxTable *table);
169 
170 Account * gncTaxTableEntryGetAccount (const GncTaxTableEntry *entry);
171 GncAmountType gncTaxTableEntryGetType (const GncTaxTableEntry *entry);
172 gnc_numeric gncTaxTableEntryGetAmount (const GncTaxTableEntry *entry);
175 int gncTaxTableCompare (const GncTaxTable *a, const GncTaxTable *b);
176 int gncTaxTableEntryCompare (const GncTaxTableEntry *a, const GncTaxTableEntry *b);
177 gboolean gncTaxTableEntryEqual(const GncTaxTableEntry *a, const GncTaxTableEntry *b);
178 
179 /************************************************/
180 
182 {
183  Account * account;
184  gnc_numeric value;
185 };
186 
191 GList *gncAccountValueAdd (GList *list, Account *acc, gnc_numeric value);
192 
194 GList *gncAccountValueAddList (GList *l1, GList *l2);
195 
197 gnc_numeric gncAccountValueTotal (GList *list);
198 
200 void gncAccountValueDestroy (GList *list);
201 
203 #define GNC_TT_NAME "tax table name"
204 #define GNC_TT_REFCOUNT "reference count"
205 
207 #define gncTaxTableGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x))
208 #define gncTaxTableRetGUID(x) (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null()))
209 #define gncTaxTableLookupDirect(G,B) gncTaxTableLookup((B), &(G))
210 
211 #ifdef __cplusplus
212 }
213 #endif
214 
215 #endif /* GNC_TAXTABLE_H_ */
216 
tax is not included
Definition: gncTaxTable.h:81
Business Interface: Object OWNERs.
GncTaxIncluded
How to interpret the TaxIncluded.
Definition: gncTaxTable.h:78
tax is included
Definition: gncTaxTable.h:80
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:82
tax is a number
Definition: gncTaxTable.h:73
Account handling public routines.
tax is a percentage
Definition: gncTaxTable.h:74
– 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
Many systems, including Microsoft Windows and BSD-derived Unixes like Darwin, are retaining the int-3...
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:71
modtime is the internal date of the last modtime See src/doc/business.txt for an explanation of the f...