GnuCash  4.8a-80-g9825132ea+
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 
51 typedef struct _gncTaxTable GncTaxTable;
52 typedef struct _gncTaxTableClass GncTaxTableClass;
53 
67 typedef enum
68 {
72 
74 typedef enum
75 {
80 
81 typedef struct _gncTaxTableEntry GncTaxTableEntry;
82 
83 typedef struct _gncAccountValue GncAccountValue;
84 
85 #include "Account.h"
86 #include "qof.h"
87 #include "gncBusiness.h"
88 #include "gncOwner.h"
89 
90 #define GNC_ID_TAXTABLE "gncTaxTable"
91 
92 /* --- type macros --- */
93 #define GNC_TYPE_TAXTABLE (gnc_taxtable_get_type ())
94 #define GNC_TAXTABLE(o) \
95  (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_TAXTABLE, GncTaxTable))
96 #define GNC_TAXTABLE_CLASS(k) \
97  (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_TAXTABLE, GncTaxTableClass))
98 #define GNC_IS_TAXTABLE(o) \
99  (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_TAXTABLE))
100 #define GNC_IS_TAXTABLE_CLASS(k) \
101  (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_TAXTABLE))
102 #define GNC_TAXTABLE_GET_CLASS(o) \
103  (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_TAXTABLE, GncTaxTableClass))
104 GType gnc_taxtable_get_type(void);
105 
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 GncTaxTable *gncTaxTableGetDefault (QofBook *book, GncOwnerType type);
155 
156 typedef GList GncTaxTableList;
157 GncTaxTableList * gncTaxTableGetTables (QofBook *book);
158 
159 const char *gncTaxTableGetName (const GncTaxTable *table);
160 GncTaxTable *gncTaxTableGetParent (const GncTaxTable *table);
161 GncTaxTable *gncTaxTableReturnChild (GncTaxTable *table, gboolean make_new);
162 #define gncTaxTableGetChild(t) gncTaxTableReturnChild((t),FALSE)
163 typedef GList GncTaxTableEntryList;
164 GncTaxTableEntryList* gncTaxTableGetEntries (const GncTaxTable *table);
165 gint64 gncTaxTableGetRefcount (const GncTaxTable *table);
166 time64 gncTaxTableLastModifiedSecs (const GncTaxTable *table);
167 
168 Account * gncTaxTableEntryGetAccount (const GncTaxTableEntry *entry);
169 GncAmountType gncTaxTableEntryGetType (const GncTaxTableEntry *entry);
170 gnc_numeric gncTaxTableEntryGetAmount (const GncTaxTableEntry *entry);
173 int gncTaxTableCompare (const GncTaxTable *a, const GncTaxTable *b);
174 int gncTaxTableEntryCompare (const GncTaxTableEntry *a, const GncTaxTableEntry *b);
175 gboolean gncTaxTableEntryEqual(const GncTaxTableEntry *a, const GncTaxTableEntry *b);
176 
177 /************************************************/
178 
180 {
181  Account * account;
182  gnc_numeric value;
183 };
184 
189 GList *gncAccountValueAdd (GList *list, Account *acc, gnc_numeric value);
190 
192 GList *gncAccountValueAddList (GList *l1, GList *l2);
193 
195 gnc_numeric gncAccountValueTotal (GList *list);
196 
198 void gncAccountValueDestroy (GList *list);
199 
201 #define GNC_TT_NAME "tax table name"
202 #define GNC_TT_REFCOUNT "reference count"
203 
205 #define gncTaxTableGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x))
206 #define gncTaxTableRetGUID(x) (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null()))
207 #define gncTaxTableLookupDirect(G,B) gncTaxTableLookup((B), &(G))
208 
209 #endif /* GNC_TAXTABLE_H_ */
210 
tax is not included
Definition: gncTaxTable.h:77
Business Interface: Object OWNERs.
GncTaxIncluded
How to interpret the TaxIncluded.
Definition: gncTaxTable.h:74
tax is included
Definition: gncTaxTable.h:76
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:183
use the global setting
Definition: gncTaxTable.h:78
tax is a number
Definition: gncTaxTable.h:69
Account handling public routines.
tax is a percentage
Definition: gncTaxTable.h:70
– 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:93
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:67
modtime is the internal date of the last modtime See src/doc/business.txt for an explanation of the f...