GnuCash 2.4.99
gncTaxTable.h
Go to the documentation of this file.
00001 /********************************************************************\
00002  * gncTaxTable.h -- the Gnucash Tax Table interface                 *
00003  *                                                                  *
00004  * This program is free software; you can redistribute it and/or    *
00005  * modify it under the terms of the GNU General Public License as   *
00006  * published by the Free Software Foundation; either version 2 of   *
00007  * the License, or (at your option) any later version.              *
00008  *                                                                  *
00009  * This program is distributed in the hope that it will be useful,  *
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00012  * GNU General Public License for more details.                     *
00013  *                                                                  *
00014  * You should have received a copy of the GNU General Public License*
00015  * along with this program; if not, contact:                        *
00016  *                                                                  *
00017  * Free Software Foundation           Voice:  +1-617-542-5942       *
00018  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00019  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
00020  *                                                                  *
00021 \********************************************************************/
00031 #ifndef GNC_TAXTABLE_H_
00032 #define GNC_TAXTABLE_H_
00033 
00051 typedef struct _gncTaxTable GncTaxTable;
00052 typedef struct _gncTaxTableClass GncTaxTableClass;
00053 
00063 typedef struct _gncTaxTableEntry GncTaxTableEntry;
00064 
00065 typedef struct _gncAccountValue GncAccountValue;
00066 
00067 #include "Account.h"
00068 #include "qof.h"
00069 #ifdef GNUCASH_MAJOR_VERSION
00070 #include "gncBusiness.h"
00071 #endif
00072 
00073 #define GNC_ID_TAXTABLE       "gncTaxTable"
00074 
00075 /* --- type macros --- */
00076 #define GNC_TYPE_TAXTABLE            (gnc_taxtable_get_type ())
00077 #define GNC_TAXTABLE(o)              \
00078      (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_TAXTABLE, GncTaxTable))
00079 #define GNC_TAXTABLE_CLASS(k)        \
00080      (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_TAXTABLE, GncTaxTableClass))
00081 #define GNC_IS_TAXTABLE(o)           \
00082      (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_TAXTABLE))
00083 #define GNC_IS_TAXTABLE_CLASS(k)     \
00084      (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_TAXTABLE))
00085 #define GNC_TAXTABLE_GET_CLASS(o)    \
00086      (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_TAXTABLE, GncTaxTableClass))
00087 GType gnc_taxtable_get_type(void);
00088 
00093 typedef enum
00094 {
00095     GNC_AMT_TYPE_VALUE = 1,     
00096     GNC_AMT_TYPE_PERCENT                
00097 } GncAmountType;
00098 
00100 typedef enum
00101 {
00102     GNC_TAXINCLUDED_YES = 1,  
00103     GNC_TAXINCLUDED_NO,         
00104     GNC_TAXINCLUDED_USEGLOBAL, 
00105 } GncTaxIncluded;
00106 
00107 const char * gncAmountTypeToString (GncAmountType type);
00108 gboolean gncAmountStringToType (const char *str, GncAmountType *type);
00109 
00110 const char * gncTaxIncludedTypeToString (GncTaxIncluded type);
00111 gboolean gncTaxIncludedStringToType (const char *str, GncTaxIncluded *type);
00112 
00115 GncTaxTable * gncTaxTableCreate (QofBook *book);
00116 void gncTaxTableDestroy (GncTaxTable *table);
00117 GncTaxTableEntry * gncTaxTableEntryCreate (void);
00118 void gncTaxTableEntryDestroy (GncTaxTableEntry *entry);
00123 void gncTaxTableSetName (GncTaxTable *table, const char *name);
00124 void gncTaxTableIncRef (GncTaxTable *table);
00125 void gncTaxTableDecRef (GncTaxTable *table);
00126 
00127 void gncTaxTableEntrySetAccount (GncTaxTableEntry *entry, Account *account);
00128 void gncTaxTableEntrySetType (GncTaxTableEntry *entry, GncAmountType type);
00129 void gncTaxTableEntrySetAmount (GncTaxTableEntry *entry, gnc_numeric amount);
00131 void gncTaxTableAddEntry (GncTaxTable *table, GncTaxTableEntry *entry);
00132 void gncTaxTableRemoveEntry (GncTaxTable *table, GncTaxTableEntry *entry);
00133 
00134 void gncTaxTableChanged (GncTaxTable *table);
00135 void gncTaxTableBeginEdit (GncTaxTable *table);
00136 void gncTaxTableCommitEdit (GncTaxTable *table);
00137 gboolean gncTaxTableEqual(const GncTaxTable *a, const GncTaxTable *b);
00138 
00148 static inline GncTaxTable *gncTaxTableLookup (const QofBook* book, const GncGUID *guid)
00149 {
00150     QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_TAXTABLE, GncTaxTable);
00151 }
00152 
00153 GncTaxTable *gncTaxTableLookupByName (QofBook *book, const char *name);
00154 
00155 GList * gncTaxTableGetTables (QofBook *book);
00156 
00157 const char *gncTaxTableGetName (const GncTaxTable *table);
00158 GncTaxTable *gncTaxTableGetParent (const GncTaxTable *table);
00159 GncTaxTable *gncTaxTableReturnChild (GncTaxTable *table, gboolean make_new);
00160 #define gncTaxTableGetChild(t) gncTaxTableReturnChild((t),FALSE)
00161 typedef GList GncTaxTableEntryList;
00162 GncTaxTableEntryList* gncTaxTableGetEntries (const GncTaxTable *table);
00163 gint64 gncTaxTableGetRefcount (const GncTaxTable *table);
00164 Timespec gncTaxTableLastModified (const GncTaxTable *table);
00165 
00166 Account * gncTaxTableEntryGetAccount (const GncTaxTableEntry *entry);
00167 GncAmountType gncTaxTableEntryGetType (const GncTaxTableEntry *entry);
00168 gnc_numeric gncTaxTableEntryGetAmount (const GncTaxTableEntry *entry);
00171 int gncTaxTableCompare (const GncTaxTable *a, const GncTaxTable *b);
00172 int gncTaxTableEntryCompare (const GncTaxTableEntry *a, const GncTaxTableEntry *b);
00173 gboolean gncTaxTableEntryEqual(const GncTaxTableEntry *a, const GncTaxTableEntry *b);
00174 
00175 /************************************************/
00176 
00177 struct _gncAccountValue
00178 {
00179     Account *   account;
00180     gnc_numeric value;
00181 };
00182 
00187 GList *gncAccountValueAdd (GList *list, Account *acc, gnc_numeric value);
00188 
00190 GList *gncAccountValueAddList (GList *l1, GList *l2);
00191 
00193 gnc_numeric gncAccountValueTotal (GList *list);
00194 
00196 void gncAccountValueDestroy (GList *list);
00197 
00199 #define GNC_TT_NAME "tax table name"
00200 #define GNC_TT_REFCOUNT "reference count"
00201 
00203 #define gncTaxTableGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x))
00204 #define gncTaxTableRetGUID(x) (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null()))
00205 #define gncTaxTableLookupDirect(G,B) gncTaxTableLookup((B), &(G))
00206 
00207 #endif /* GNC_TAXTABLE_H_ */
00208 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines