GnuCash  5.6-150-g038405b370+
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 gnu@gnu.org *
20  * *
21 \********************************************************************/
68 #ifndef GNC_BILLTERM_H_
69 #define GNC_BILLTERM_H_
70 
71 typedef struct _gncBillTerm GncBillTerm;
72 typedef struct _gncBillTermClass GncBillTermClass;
73 
74 #include "qof.h"
75 #include "gncBusiness.h"
76 
77 #ifdef __cplusplus
78 extern "C" {
79 #endif
80 
81 #define GNC_ID_BILLTERM "gncBillTerm"
82 
83 /* --- type macros --- */
84 #define GNC_TYPE_BILLTERM (gnc_billterm_get_type ())
85 #define GNC_BILLTERM(o) \
86  (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_BILLTERM, GncBillTerm))
87 #define GNC_BILLTERM_CLASS(k) \
88  (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_BILLTERM, GncBillTermClass))
89 #define GNC_IS_BILLTERM(o) \
90  (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_BILLTERM))
91 #define GNC_IS_BILLTERM_CLASS(k) \
92  (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_BILLTERM))
93 #define GNC_BILLTERM_GET_CLASS(o) \
94  (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_BILLTERM, GncBillTermClass))
95 GType gnc_billterm_get_type(void);
96 
99 #define GNC_BILLTERM_NAME "name"
100 #define GNC_BILLTERM_DESC "description"
101 #define GNC_BILLTERM_DUEDAYS "number of days due"
102 #define GNC_BILLTERM_DISCDAYS "number of discounted days"
103 #define GNC_BILLTERM_CUTOFF "cut off"
104 #define GNC_BILLTERM_TYPE "bill type"
105 #define GNC_BILLTERM_DISCOUNT "amount of discount"
106 #define GNC_BILLTERM_REFCOUNT "reference count"
107 
115 #ifndef SWIG
116 #define ENUM_TERMS_TYPE(_) \
117  _(GNC_TERM_TYPE_DAYS,=1) \
118  _(GNC_TERM_TYPE_PROXIMO,)
119 
120 DEFINE_ENUM(GncBillTermType, ENUM_TERMS_TYPE)
121 #else
122 typedef enum
123 {
124  GNC_TERM_TYPE_DAYS = 1,
125  GNC_TERM_TYPE_PROXIMO,
126 } GncBillTermType;
127 #endif
128 
131 GncBillTerm * gncBillTermCreate (QofBook *book);
132 void gncBillTermDestroy (GncBillTerm *term);
133 void gncBillTermIncRef (GncBillTerm *term);
134 void gncBillTermDecRef (GncBillTerm *term);
135 
136 void gncBillTermChanged (GncBillTerm *term);
137 void gncBillTermBeginEdit (GncBillTerm *term);
138 void gncBillTermCommitEdit (GncBillTerm *term);
144 void gncBillTermSetName (GncBillTerm *term, const char *name);
145 void gncBillTermSetDescription (GncBillTerm *term, const char *name);
146 void gncBillTermSetType (GncBillTerm *term, GncBillTermType type);
147 void gncBillTermSetDueDays (GncBillTerm *term, gint days);
148 void gncBillTermSetDiscountDays (GncBillTerm *term, gint days);
149 void gncBillTermSetDiscount (GncBillTerm *term, gnc_numeric discount);
150 void gncBillTermSetCutoff (GncBillTerm *term, gint cutoff);
151 
160 static inline GncBillTerm * gncBillTermLookup (const QofBook *book, const GncGUID *guid)
161 {
162  QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_BILLTERM, GncBillTerm);
163 }
164 
165 GncBillTerm *gncBillTermLookupByName (QofBook *book, const char *name);
166 GList * gncBillTermGetTerms (QofBook *book);
167 
168 const char *gncBillTermGetName (const GncBillTerm *term);
169 const char *gncBillTermGetDescription (const GncBillTerm *term);
170 GncBillTermType gncBillTermGetType (const GncBillTerm *term);
171 gint gncBillTermGetDueDays (const GncBillTerm *term);
172 gint gncBillTermGetDiscountDays (const GncBillTerm *term);
173 gnc_numeric gncBillTermGetDiscount (const GncBillTerm *term);
174 gint gncBillTermGetCutoff (const GncBillTerm *term);
175 
176 gboolean gncBillTermIsDirty (const GncBillTerm *term);
177 
178 GncBillTerm *gncBillTermGetParent (const GncBillTerm *term);
179 GncBillTerm *gncBillTermReturnChild (GncBillTerm *term, gboolean make_new);
180 #define gncBillTermGetChild(t) gncBillTermReturnChild((t),FALSE)
181 gint64 gncBillTermGetRefcount (const GncBillTerm *term);
187 int gncBillTermCompare (const GncBillTerm *a, const GncBillTerm *b);
189 gboolean gncBillTermEqual(const GncBillTerm *a, const GncBillTerm *b);
198 gboolean gncBillTermIsFamily (const GncBillTerm *a, const GncBillTerm *b);
201 /********************************************************/
202 /* functions to compute dates from Bill Terms */
203 
204 /* Compute the due date and discount dates from the post date */
205 time64 gncBillTermComputeDueDate (const GncBillTerm *term, time64 post_date);
206 
207 /* deprecated */
208 #define gncBillTermGetGUID(x) qof_instance_get_guid (QOF_INSTANCE(x))
209 
210 #ifdef __cplusplus
211 }
212 #endif
213 
214 #endif /* GNC_BILLTERM_H_ */
215 
int gncBillTermCompare(const GncBillTerm *a, const GncBillTerm *b)
Compare BillTerms on their name for sorting.
Definition: gncBillTerm.c:629
#define ENUM_TERMS_TYPE(_)
How to interpret the amount.
Definition: gncBillTerm.h:116
#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
gboolean gncBillTermEqual(const GncBillTerm *a, const GncBillTerm *b)
Check if all internal fields of a and b match.
Definition: gncBillTerm.c:643
gboolean gncBillTermIsFamily(const GncBillTerm *a, const GncBillTerm *b)
Check only if the bill terms are "family".
Definition: gncBillTerm.c:707
– Business Helper Functions
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition: gnc-date.h:87
The type used to store guids in C.
Definition: guid.h:75