GnuCash c935c2f+
Loading...
Searching...
No Matches
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
71typedef struct _gncBillTerm GncBillTerm;
72typedef struct _gncBillTermClass GncBillTermClass;
73
74#include "qof.h"
75#include "gncBusiness.h"
76
77#ifdef __cplusplus
78extern "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))
95GType 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"
115#ifndef SWIG
116#define ENUM_TERMS_TYPE(_) \
117 _(GNC_TERM_TYPE_DAYS,=1) \
118 _(GNC_TERM_TYPE_PROXIMO,)
119
120DEFINE_ENUM(GncBillTermType, ENUM_TERMS_TYPE)
121#else
122typedef enum
123{
124 GNC_TERM_TYPE_DAYS = 1,
125 GNC_TERM_TYPE_PROXIMO,
126} GncBillTermType;
127#endif
128
131GncBillTerm * gncBillTermCreate (QofBook *book);
132void gncBillTermDestroy (GncBillTerm *term);
133void gncBillTermIncRef (GncBillTerm *term);
134void gncBillTermDecRef (GncBillTerm *term);
135
136void gncBillTermChanged (GncBillTerm *term);
137void gncBillTermBeginEdit (GncBillTerm *term);
138void gncBillTermCommitEdit (GncBillTerm *term);
144void gncBillTermSetName (GncBillTerm *term, const char *name);
145void gncBillTermSetDescription (GncBillTerm *term, const char *name);
146void gncBillTermSetType (GncBillTerm *term, GncBillTermType type);
147void gncBillTermSetDueDays (GncBillTerm *term, gint days);
148void gncBillTermSetDiscountDays (GncBillTerm *term, gint days);
149void gncBillTermSetDiscount (GncBillTerm *term, gnc_numeric discount);
150void gncBillTermSetCutoff (GncBillTerm *term, gint cutoff);
151
160static inline GncBillTerm * gncBillTermLookup (const QofBook *book, const GncGUID *guid)
161{
162 QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_BILLTERM, GncBillTerm);
163}
164
165GncBillTerm *gncBillTermLookupByName (QofBook *book, const char *name);
166GList * gncBillTermGetTerms (QofBook *book);
167
168const char *gncBillTermGetName (const GncBillTerm *term);
169const char *gncBillTermGetDescription (const GncBillTerm *term);
170GncBillTermType gncBillTermGetType (const GncBillTerm *term);
171gint gncBillTermGetDueDays (const GncBillTerm *term);
172gint gncBillTermGetDiscountDays (const GncBillTerm *term);
173gnc_numeric gncBillTermGetDiscount (const GncBillTerm *term);
174gint gncBillTermGetCutoff (const GncBillTerm *term);
175
176gboolean gncBillTermIsDirty (const GncBillTerm *term);
177
178GncBillTerm *gncBillTermGetParent (const GncBillTerm *term);
179GncBillTerm *gncBillTermReturnChild (GncBillTerm *term, gboolean make_new);
180#define gncBillTermGetChild(t) gncBillTermReturnChild((t),FALSE)
181gint64 gncBillTermGetRefcount (const GncBillTerm *term);
187int gncBillTermCompare (const GncBillTerm *a, const GncBillTerm *b);
189gboolean gncBillTermEqual(const GncBillTerm *a, const GncBillTerm *b);
198gboolean 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 */
205time64 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_ */
-- Business Helper Functions
gboolean gncBillTermEqual(const GncBillTerm *a, const GncBillTerm *b)
Check if all internal fields of a and b match.
int gncBillTermCompare(const GncBillTerm *a, const GncBillTerm *b)
Compare BillTerms on their name for sorting.
#define ENUM_TERMS_TYPE(_)
How to interpret the amount.
gboolean gncBillTermIsFamily(const GncBillTerm *a, const GncBillTerm *b)
Check only if the bill terms are "family".
#define QOF_BOOK_RETURN_ENTITY(book, guid, e_type, c_type)
Encapsulates all the information about a dataset manipulated by QOF.
Definition qofbook.h:101
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
QofBook reference.
Definition qofbook-p.hpp:47