1 /********************************************************************\
2  * gncVendor.h -- the Core Vendor 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 \********************************************************************/
22 /** @addtogroup Business
23     @{ */
24 /** @addtogroup Vendor
25     @{ */
26 /** @file gncVendor.h
27     @brief  Vendor Interface
28     @author Copyright (C) 2001,2002 Derek Atkins <warlord@MIT.EDU>
29 */
30 
31 #ifndef GNC_VENDOR_H_
32 #define GNC_VENDOR_H_
33 
34 typedef struct _gncVendor GncVendor;
35 typedef struct _gncVendorClass GncVendorClass;
36 
37 #include "gncAddress.h"
38 #include "gncBillTerm.h"
39 #include "gncTaxTable.h"
40 #include "gncJob.h"
41 
42 #define GNC_ID_VENDOR       "gncVendor"
43 
44 /* --- type macros --- */
45 #define GNC_TYPE_VENDOR            (gnc_vendor_get_type ())
46 #define GNC_VENDOR(o)              \
47      (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_VENDOR, GncVendor))
48 #define GNC_VENDOR_CLASS(k)        \
49      (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_VENDOR, GncVendorClass))
50 #define GNC_IS_VENDOR(o)           \
51      (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_VENDOR))
52 #define GNC_IS_VENDOR_CLASS(k)     \
53      (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_VENDOR))
54 #define GNC_VENDOR_GET_CLASS(o)    \
55      (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_VENDOR, GncVendorClass))
56 GType gnc_vendor_get_type(void);
57 
58 /* Create/Destroy Functions */
59 
60 GncVendor *gncVendorCreate (QofBook *book);
61 void gncVendorDestroy (GncVendor *vendor);
62 
63 /** @name Set Functions
64  @{
65 */
66 
67 void gncVendorSetID (GncVendor *vendor, const char *id);
68 void gncVendorSetName (GncVendor *vendor, const char *name);
69 void gncVendorSetNotes (GncVendor *vendor, const char *notes);
70 void gncVendorSetTerms (GncVendor *vendor, GncBillTerm *terms);
71 void gncVendorSetTaxIncluded (GncVendor *vendor, GncTaxIncluded taxincl);
72 void gncVendorSetCurrency (GncVendor *vendor, gnc_commodity *currency);
73 void gncVendorSetActive (GncVendor *vendor, gboolean active);
74 void gncVendorSetTaxTableOverride (GncVendor *vendor, gboolean override);
75 void gncVendorSetTaxTable (GncVendor *vendor, GncTaxTable *table);
76 
77 /** @} */
78 
79 void gncVendorAddJob (GncVendor *vendor, GncJob *job);
80 void gncVendorRemoveJob (GncVendor *vendor, GncJob *job);
81 
82 void gncVendorBeginEdit (GncVendor *vendor);
83 void gncVendorCommitEdit (GncVendor *vendor);
84 
85 /** @name Get Functions
86 @{
87 */
88 
89 const char * gncVendorGetID (const GncVendor *vendor);
90 const char * gncVendorGetName (const GncVendor *vendor);
91 GncAddress * gncVendorGetAddr (const GncVendor *vendor);
92 const char * gncVendorGetNotes (const GncVendor *vendor);
93 GncBillTerm * gncVendorGetTerms (const GncVendor *vendor);
94 GncTaxIncluded gncVendorGetTaxIncluded (const GncVendor *vendor);
95 gnc_commodity * gncVendorGetCurrency (const GncVendor *vendor);
96 gboolean gncVendorGetActive (const GncVendor *vendor);
97 
98 gboolean gncVendorGetTaxTableOverride (const GncVendor *vendor);
99 GncTaxTable* gncVendorGetTaxTable (const GncVendor *vendor);
100 
101 /** @} */
102 /** XXX should be renamed to RetJobList to be consistent with
103  * other usage, since caller must free the copied list
104  */
105 
106 int gncVendorCompare (const GncVendor *a, const GncVendor *b);
107 
108 /** Return a pointer to the instance gncVendor that is identified
109  *  by the guid, and is residing in the book. Returns NULL if the
110  *  instance can't be found.
111  *  Equivalent function prototype is
112  *  GncVendor * gncVendorLookup (QofBook *book, const GncGUID *guid);
113  */
gncVendorLookup(const QofBook * book,const GncGUID * guid)114 static inline GncVendor * gncVendorLookup (const QofBook *book, const GncGUID *guid)
115 {
116     QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_VENDOR, GncVendor);
117 }
118 
119 #define VENDOR_ID           "id"
120 #define VENDOR_NAME         "name"
121 #define VENDOR_ADDR         "addr"
122 #define VENDOR_NOTES        "vendor_notes"
123 #define VENDOR_TERMS        "vendor_terms"
124 #define VENDOR_TAX_INC      "vendor_tax_included"
125 #define VENDOR_ACTIVE       "vendor_is_active"
126 #define VENDOR_TAX_OVERRIDE "override_tax_table"
127 #define VENDOR_TAX_TABLE    "vendor_tax_table"
128 
129 /** deprecated functions */
130 #define gncVendorGetBook(X) qof_instance_get_book (QOF_INSTANCE(X))
131 #define gncVendorGetGUID(X) qof_instance_get_guid (QOF_INSTANCE(X))
132 #define gncVendorRetGUID(X) (X ? *(qof_instance_get_guid (QOF_INSTANCE(X))) : *(guid_null()))
133 #define gncVendorLookupDirect(G,B) gncVendorLookup((B),&(G))
134 /** Test support function, used by test-dbi-business-stuff.c */
135 gboolean gncVendorEqual(const GncVendor *a, const GncVendor *b);
136 gboolean gncVendorIsDirty (const GncVendor *vendor);
137 #endif /* GNC_VENDOR_H_ */
138 /** @} */
139 /** @} */
140