GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gncBillTerm.h
Go to the documentation of this file.
1 /********************************************************************\
2  * gncBillTerm.h -- the Gnucash Billing Term 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 [email protected] *
20  * *
21 \********************************************************************/
31 #ifndef GNC_BILLTERM_H_
32 #define GNC_BILLTERM_H_
33 
34 typedef struct _gncBillTerm GncBillTerm;
35 typedef struct _gncBillTermClass GncBillTermClass;
36 
37 #include "qof.h"
38 #ifdef GNUCASH_MAJOR_VERSION
39 #include "gncBusiness.h"
40 #endif
41 #define GNC_ID_BILLTERM "gncBillTerm"
42 
43 /* --- type macros --- */
44 #define GNC_TYPE_BILLTERM (gnc_billterm_get_type ())
45 #define GNC_BILLTERM(o) \
46  (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_BILLTERM, GncBillTerm))
47 #define GNC_BILLTERM_CLASS(k) \
48  (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_BILLTERM, GncBillTermClass))
49 #define GNC_IS_BILLTERM(o) \
50  (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_BILLTERM))
51 #define GNC_IS_BILLTERM_CLASS(k) \
52  (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_BILLTERM))
53 #define GNC_BILLTERM_GET_CLASS(o) \
54  (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_BILLTERM, GncBillTermClass))
55 GType gnc_billterm_get_type(void);
56 
59 #define GNC_BILLTERM_NAME "name"
60 #define GNC_BILLTERM_DESC "description"
61 #define GNC_BILLTERM_DUEDAYS "number of days due"
62 #define GNC_BILLTERM_DISCDAYS "number of discounted days"
63 #define GNC_BILLTERM_CUTOFF "cut off"
64 #define GNC_BILLTERM_TYPE "bill type"
65 #define GNC_BILLTERM_DISCOUNT "amount of discount"
66 #define GNC_BILLTERM_REFCOUNT "reference count"
67 
75 #ifndef SWIG
76 #define ENUM_TERMS_TYPE(_) \
77  _(GNC_TERM_TYPE_DAYS,=1) \
78  _(GNC_TERM_TYPE_PROXIMO,)
79 
80 DEFINE_ENUM(GncBillTermType, ENUM_TERMS_TYPE)
81 #else
82 typedef enum
83 {
84  GNC_TERM_TYPE_DAYS = 1,
85  GNC_TERM_TYPE_PROXIMO,
86 } GncBillTermType;
87 #endif
88 
91 GncBillTerm * gncBillTermCreate (QofBook *book);
92 void gncBillTermDestroy (GncBillTerm *term);
93 void gncBillTermIncRef (GncBillTerm *term);
94 void gncBillTermDecRef (GncBillTerm *term);
95 
96 void gncBillTermChanged (GncBillTerm *term);
97 void gncBillTermBeginEdit (GncBillTerm *term);
98 void gncBillTermCommitEdit (GncBillTerm *term);
104 void gncBillTermSetName (GncBillTerm *term, const char *name);
105 void gncBillTermSetDescription (GncBillTerm *term, const char *name);
106 void gncBillTermSetType (GncBillTerm *term, GncBillTermType type);
107 void gncBillTermSetDueDays (GncBillTerm *term, gint days);
108 void gncBillTermSetDiscountDays (GncBillTerm *term, gint days);
109 void gncBillTermSetDiscount (GncBillTerm *term, gnc_numeric discount);
110 void gncBillTermSetCutoff (GncBillTerm *term, gint cutoff);
111 
122 static inline GncBillTerm * gncBillTermLookup (const QofBook *book, const GncGUID *guid)
123 {
124  QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_BILLTERM, GncBillTerm);
125 }
126 
127 GncBillTerm *gncBillTermLookupByName (QofBook *book, const char *name);
128 GList * gncBillTermGetTerms (QofBook *book);
129 
130 const char *gncBillTermGetName (const GncBillTerm *term);
131 const char *gncBillTermGetDescription (const GncBillTerm *term);
132 GncBillTermType gncBillTermGetType (const GncBillTerm *term);
133 gint gncBillTermGetDueDays (const GncBillTerm *term);
134 gint gncBillTermGetDiscountDays (const GncBillTerm *term);
135 gnc_numeric gncBillTermGetDiscount (const GncBillTerm *term);
136 gint gncBillTermGetCutoff (const GncBillTerm *term);
137 
138 gboolean gncBillTermIsDirty (const GncBillTerm *term);
139 
140 GncBillTerm *gncBillTermGetParent (const GncBillTerm *term);
141 GncBillTerm *gncBillTermReturnChild (GncBillTerm *term, gboolean make_new);
142 #define gncBillTermGetChild(t) gncBillTermReturnChild((t),FALSE)
143 gint64 gncBillTermGetRefcount (const GncBillTerm *term);
149 int gncBillTermCompare (const GncBillTerm *a, const GncBillTerm *b);
151 gboolean gncBillTermEqual(const GncBillTerm *a, const GncBillTerm *b);
160 gboolean gncBillTermIsFamily (const GncBillTerm *a, const GncBillTerm *b);
163 /********************************************************/
164 /* functions to compute dates from Bill Terms */
165 
166 /* Compute the due date and discount dates from the post date */
167 Timespec gncBillTermComputeDueDate (const GncBillTerm *term, Timespec post_date);
168 
169 /* deprecated */
170 #define gncBillTermGetGUID(x) qof_instance_get_guid (QOF_INSTANCE(x))
171 
172 #endif /* GNC_BILLTERM_H_ */
173 
int gncBillTermCompare(const GncBillTerm *a, const GncBillTerm *b)
Definition: gncBillTerm.c:633
#define ENUM_TERMS_TYPE(_)
Definition: gncBillTerm.h:76
Use a 64-bit unsigned int timespec.
Definition: gnc-date.h:299
#define QOF_BOOK_RETURN_ENTITY(book, guid, e_type, c_type)
Encapsulates all the information about a dataset manipulated by QOF. This is the top-most structure u...
Definition: qofbook.h:164
gboolean gncBillTermEqual(const GncBillTerm *a, const GncBillTerm *b)
Definition: gncBillTerm.c:647
Definition: guid.h:65
gboolean gncBillTermIsFamily(const GncBillTerm *a, const GncBillTerm *b)
Definition: gncBillTerm.c:711