GnuCash  4.8a-80-g9825132ea+
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 \********************************************************************/
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 #include "gncBusiness.h"
39 
40 #define GNC_ID_BILLTERM "gncBillTerm"
41 
42 /* --- type macros --- */
43 #define GNC_TYPE_BILLTERM (gnc_billterm_get_type ())
44 #define GNC_BILLTERM(o) \
45  (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_BILLTERM, GncBillTerm))
46 #define GNC_BILLTERM_CLASS(k) \
47  (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_BILLTERM, GncBillTermClass))
48 #define GNC_IS_BILLTERM(o) \
49  (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_BILLTERM))
50 #define GNC_IS_BILLTERM_CLASS(k) \
51  (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_BILLTERM))
52 #define GNC_BILLTERM_GET_CLASS(o) \
53  (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_BILLTERM, GncBillTermClass))
54 GType gnc_billterm_get_type(void);
55 
58 #define GNC_BILLTERM_NAME "name"
59 #define GNC_BILLTERM_DESC "description"
60 #define GNC_BILLTERM_DUEDAYS "number of days due"
61 #define GNC_BILLTERM_DISCDAYS "number of discounted days"
62 #define GNC_BILLTERM_CUTOFF "cut off"
63 #define GNC_BILLTERM_TYPE "bill type"
64 #define GNC_BILLTERM_DISCOUNT "amount of discount"
65 #define GNC_BILLTERM_REFCOUNT "reference count"
66 
74 #ifndef SWIG
75 #define ENUM_TERMS_TYPE(_) \
76  _(GNC_TERM_TYPE_DAYS,=1) \
77  _(GNC_TERM_TYPE_PROXIMO,)
78 
79 DEFINE_ENUM(GncBillTermType, ENUM_TERMS_TYPE)
80 #else
81 typedef enum
82 {
83  GNC_TERM_TYPE_DAYS = 1,
84  GNC_TERM_TYPE_PROXIMO,
85 } GncBillTermType;
86 #endif
87 
90 GncBillTerm * gncBillTermCreate (QofBook *book);
91 void gncBillTermDestroy (GncBillTerm *term);
92 void gncBillTermIncRef (GncBillTerm *term);
93 void gncBillTermDecRef (GncBillTerm *term);
94 
95 void gncBillTermChanged (GncBillTerm *term);
96 void gncBillTermBeginEdit (GncBillTerm *term);
97 void gncBillTermCommitEdit (GncBillTerm *term);
103 void gncBillTermSetName (GncBillTerm *term, const char *name);
104 void gncBillTermSetDescription (GncBillTerm *term, const char *name);
105 void gncBillTermSetType (GncBillTerm *term, GncBillTermType type);
106 void gncBillTermSetDueDays (GncBillTerm *term, gint days);
107 void gncBillTermSetDiscountDays (GncBillTerm *term, gint days);
108 void gncBillTermSetDiscount (GncBillTerm *term, gnc_numeric discount);
109 void gncBillTermSetCutoff (GncBillTerm *term, gint cutoff);
110 
121 static inline GncBillTerm * gncBillTermLookup (const QofBook *book, const GncGUID *guid)
122 {
123  QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_BILLTERM, GncBillTerm);
124 }
125 
126 GncBillTerm *gncBillTermLookupByName (QofBook *book, const char *name);
127 GList * gncBillTermGetTerms (QofBook *book);
128 
129 const char *gncBillTermGetName (const GncBillTerm *term);
130 const char *gncBillTermGetDescription (const GncBillTerm *term);
131 GncBillTermType gncBillTermGetType (const GncBillTerm *term);
132 gint gncBillTermGetDueDays (const GncBillTerm *term);
133 gint gncBillTermGetDiscountDays (const GncBillTerm *term);
134 gnc_numeric gncBillTermGetDiscount (const GncBillTerm *term);
135 gint gncBillTermGetCutoff (const GncBillTerm *term);
136 
137 gboolean gncBillTermIsDirty (const GncBillTerm *term);
138 
139 GncBillTerm *gncBillTermGetParent (const GncBillTerm *term);
140 GncBillTerm *gncBillTermReturnChild (GncBillTerm *term, gboolean make_new);
141 #define gncBillTermGetChild(t) gncBillTermReturnChild((t),FALSE)
142 gint64 gncBillTermGetRefcount (const GncBillTerm *term);
148 int gncBillTermCompare (const GncBillTerm *a, const GncBillTerm *b);
150 gboolean gncBillTermEqual(const GncBillTerm *a, const GncBillTerm *b);
159 gboolean gncBillTermIsFamily (const GncBillTerm *a, const GncBillTerm *b);
162 /********************************************************/
163 /* functions to compute dates from Bill Terms */
164 
165 /* Compute the due date and discount dates from the post date */
166 time64 gncBillTermComputeDueDate (const GncBillTerm *term, time64 post_date);
167 
168 /* deprecated */
169 #define gncBillTermGetGUID(x) qof_instance_get_guid (QOF_INSTANCE(x))
170 
171 #endif /* GNC_BILLTERM_H_ */
172 
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:75
#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
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
Many systems, including Microsoft Windows and BSD-derived Unixes like Darwin, are retaining the int-3...
Definition: gnc-date.h:93
The type used to store guids in C.
Definition: guid.h:75