GnuCash  5.6-150-g038405b370+
gncEntry.h
Go to the documentation of this file.
1 /********************************************************************\
2  * gncEntry.h -- the Core Business Entry 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_ENTRY_H_
32 #define GNC_ENTRY_H_
33 
34 #include <glib.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 typedef struct _gncEntry GncEntry;
41 typedef struct _gncEntryClass GncEntryClass;
42 
43 typedef enum
44 {
45  GNC_PAYMENT_CASH = 1,
46  GNC_PAYMENT_CARD
47 } GncEntryPaymentType;
48 
49 typedef enum
50 {
51  GNC_DISC_PRETAX = 1,
52  GNC_DISC_SAMETIME,
53  GNC_DISC_POSTTAX
54 } GncDiscountHow;
55 
56 typedef GList AccountValueList;
57 
58 #include "gncBusiness.h"
59 #include "gncInvoice.h"
60 #include "gncOrder.h"
61 #include "gncTaxTable.h"
62 #include "gncOwner.h"
63 
64 #define GNC_ID_ENTRY "gncEntry"
65 
66 /* --- type macros --- */
67 #define GNC_TYPE_ENTRY (gnc_entry_get_type ())
68 #define GNC_ENTRY(o) \
69  (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_ENTRY, GncEntry))
70 #define GNC_ENTRY_CLASS(k) \
71  (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_ENTRY, GncEntryClass))
72 #define GNC_IS_ENTRY(o) \
73  (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_ENTRY))
74 #define GNC_IS_ENTRY_CLASS(k) \
75  (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_ENTRY))
76 #define GNC_ENTRY_GET_CLASS(o) \
77  (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_ENTRY, GncEntryClass))
78 GType gnc_entry_get_type(void);
79 
89 const char * gncEntryDiscountHowToString (GncDiscountHow how);
90 gboolean gncEntryDiscountStringToHow (const char *str, GncDiscountHow *how);
91 
92 const char * gncEntryPaymentTypeToString (GncEntryPaymentType type);
93 gboolean gncEntryPaymentStringToType (const char *str, GncEntryPaymentType *type);
94 
97 GncEntry *gncEntryCreate (QofBook *book);
98 void gncEntryDestroy (GncEntry *entry);
101 /* SET FUNCTIONS */
102 
106 void gncEntrySetDateGDate (GncEntry *entry, const GDate* date);
110 void gncEntrySetDate (GncEntry *entry, time64 date);
111 void gncEntrySetDateEntered (GncEntry *entry, time64 date);
112 void gncEntrySetDescription (GncEntry *entry, const char *desc);
113 void gncEntrySetAction (GncEntry *entry, const char *action);
114 void gncEntrySetNotes (GncEntry *entry, const char *notes);
120 void gncEntrySetQuantity (GncEntry *entry, gnc_numeric quantity);
127 void gncEntrySetDocQuantity (GncEntry *entry, gnc_numeric quantity, gboolean is_cn);
132 void gncEntrySetInvAccount (GncEntry *entry, Account *acc);
133 void gncEntrySetInvPrice (GncEntry *entry, gnc_numeric price);
134 void gncEntrySetInvTaxable (GncEntry *entry, gboolean taxable);
135 void gncEntrySetInvTaxIncluded (GncEntry *entry, gboolean tax_included);
136 void gncEntrySetInvTaxTable (GncEntry *entry, GncTaxTable *table);
137 void gncEntrySetInvDiscount (GncEntry *entry, gnc_numeric discount);
138 void gncEntrySetInvDiscountType (GncEntry *entry, GncAmountType type);
139 void gncEntrySetInvDiscountHow (GncEntry *entry, GncDiscountHow how);
140 void qofEntrySetInvDiscType (GncEntry *entry, const char *type);
141 void qofEntrySetInvDiscHow (GncEntry *entry, const char *type);
146 void gncEntrySetBillAccount (GncEntry *entry, Account *acc);
147 void gncEntrySetBillPrice (GncEntry *entry, gnc_numeric price);
148 void gncEntrySetBillTaxable (GncEntry *entry, gboolean taxable);
149 void gncEntrySetBillTaxIncluded (GncEntry *entry, gboolean tax_included);
150 void gncEntrySetBillTaxTable (GncEntry *entry, GncTaxTable *table);
151 void gncEntrySetBillable (GncEntry *entry, gboolean billable);
152 void gncEntrySetBillTo (GncEntry *entry, GncOwner *billto);
157 void gncEntrySetBillPayment (GncEntry *entry, GncEntryPaymentType type);
160 /* GET FUNCTIONS */
164 GDate gncEntryGetDateGDate (const GncEntry *entry);
168 time64 gncEntryGetDate (const GncEntry *entry);
169 time64 gncEntryGetDateEntered (const GncEntry *entry);
170 const char * gncEntryGetDescription (const GncEntry *entry);
171 const char * gncEntryGetAction (const GncEntry *entry);
172 const char * gncEntryGetNotes (const GncEntry *notes);
178 gnc_numeric gncEntryGetQuantity (const GncEntry *entry);
184 gnc_numeric gncEntryGetDocQuantity (const GncEntry *entry, gboolean is_cn);
189 Account * gncEntryGetInvAccount (const GncEntry *entry);
190 gnc_numeric gncEntryGetInvPrice (const GncEntry *entry);
191 gnc_numeric gncEntryGetPrice (const GncEntry *entry, const gboolean cust_doc, const gboolean net);
192 gnc_numeric gncEntryGetInvDiscount (const GncEntry *entry);
193 GncAmountType gncEntryGetInvDiscountType (const GncEntry *entry);
194 GncDiscountHow gncEntryGetInvDiscountHow (const GncEntry *entry);
195 char* qofEntryGetInvDiscType (const GncEntry *entry);
196 char* qofEntryGetInvDiscHow (const GncEntry *entry);
197 gboolean gncEntryGetInvTaxable (const GncEntry *entry);
198 gboolean gncEntryGetInvTaxIncluded (const GncEntry *entry);
199 GncTaxTable * gncEntryGetInvTaxTable (const GncEntry *entry);
204 Account * gncEntryGetBillAccount (const GncEntry *entry);
205 gnc_numeric gncEntryGetBillPrice (const GncEntry *entry);
206 gboolean gncEntryGetBillTaxable (const GncEntry *entry);
207 gboolean gncEntryGetBillTaxIncluded (const GncEntry *entry);
208 GncTaxTable * gncEntryGetBillTaxTable (const GncEntry *entry);
209 gboolean gncEntryGetBillable (const GncEntry *entry);
210 GncOwner *gncEntryGetBillTo (GncEntry *entry);
211 
212 GncEntryPaymentType gncEntryGetBillPayment (const GncEntry* entry);
215 void gncEntryCopy (const GncEntry *src, GncEntry *dest, gboolean add_entry);
216 
252 gnc_numeric gncEntryGetDocValue (GncEntry *entry, gboolean round, gboolean is_cust_doc, gboolean is_cn);
253 gnc_numeric gncEntryGetDocTaxValue (GncEntry *entry, gboolean round, gboolean is_cust_doc, gboolean is_cn);
255 AccountValueList * gncEntryGetDocTaxValues (GncEntry *entry, gboolean is_cust_doc, gboolean is_cn);
256 gnc_numeric gncEntryGetDocDiscountValue (GncEntry *entry, gboolean round, gboolean is_cust_doc, gboolean is_cn);
257 
258 gnc_numeric gncEntryGetBalValue (GncEntry *entry, gboolean round, gboolean is_cust_doc);
259 gnc_numeric gncEntryGetBalTaxValue (GncEntry *entry, gboolean round, gboolean is_cust_doc);
261 AccountValueList * gncEntryGetBalTaxValues (GncEntry *entry, gboolean is_cust_doc);
262 gnc_numeric gncEntryGetBalDiscountValue (GncEntry *entry, gboolean round, gboolean is_cust_doc);
263 
276 void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price,
277  const GncTaxTable *tax_table, gboolean tax_included,
278  gnc_numeric discount, GncAmountType discount_type,
279  GncDiscountHow discount_how, int SCU,
280  /* return values */
281  gnc_numeric *value, gnc_numeric *discount_value,
282  GList **tax_values);
283 
286 GncOrder * gncEntryGetOrder (const GncEntry *entry);
287 GncInvoice * gncEntryGetInvoice (const GncEntry *entry);
288 GncInvoice * gncEntryGetBill (const GncEntry *entry);
289 
294 static inline GncEntry * gncEntryLookup (const QofBook *book, const GncGUID *guid)
295 {
296  QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_ENTRY, GncEntry);
297 }
298 
299 gboolean gncEntryIsOpen (const GncEntry *entry);
300 void gncEntryBeginEdit (GncEntry *entry);
301 void gncEntryCommitEdit (GncEntry *entry);
302 int gncEntryCompare (const GncEntry *a, const GncEntry *b);
303 
304 #define ENTRY_DATE "date"
305 #define ENTRY_DATE_ENTERED "date-entered"
306 #define ENTRY_DESC "desc"
307 #define ENTRY_ACTION "action"
308 #define ENTRY_NOTES "notes"
309 #define ENTRY_QTY "qty"
310 
311 #define ENTRY_IPRICE "iprice"
312 #define ENTRY_IACCT "invoice-account"
313 #define ENTRY_BACCT "bill-account"
314 #define ENTRY_BPRICE "bprice"
315 #define ENTRY_BILLABLE "billable?"
316 #define ENTRY_BILLTO "bill-to"
317 
318 #define ENTRY_ORDER "order"
319 #define ENTRY_INVOICE "invoice"
320 #define ENTRY_BILL "bill"
321 
322 #define ENTRY_INV_DISC_TYPE "discount-type"
323 #define ENTRY_INV_DISC_HOW "discount-method"
324 
325 #define ENTRY_INV_TAXABLE "invoice-taxable"
326 #define ENTRY_BILL_TAXABLE "bill-taxable"
327 #define ENTRY_INV_TAX_INC "invoice-tax-included"
328 #define ENTRY_BILL_TAX_INC "bill-tax-included"
329 #define ENTRY_INV_DISCOUNT "invoice-discount"
330 #define ENTRY_BILL_PAY_TYPE "bill-payment-type"
331 
332 
333 /* deprecated functions, should be removed */
334 #define gncEntryGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x))
335 
336 #ifdef __cplusplus
337 }
338 #endif
339 
340 #endif /* GNC_ENTRY_H_ */
341 
Business Interface: Object OWNERs.
void gncEntrySetQuantity(GncEntry *entry, gnc_numeric quantity)
Set the internal quantity without any conversion.
Definition: gncEntry.c:551
STRUCTS.
AccountValueList * gncEntryGetDocTaxValues(GncEntry *entry, gboolean is_cust_doc, gboolean is_cn)
Careful: the returned list is NOT owned by the entry and should be freed by the caller.
Definition: gncEntry.c:1548
#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
void gncEntrySetDocQuantity(GncEntry *entry, gnc_numeric quantity, gboolean is_cn)
Set the internal quantity converting from the quantity as visible on the physical document...
Definition: gncEntry.c:562
time64 gncEntryGetDate(const GncEntry *entry)
DEPRECATED - use gncEntryGetDateGDate() instead! (Because the time-of-day is a misleading extra infor...
Definition: gncEntry.c:913
AccountValueList * gncEntryGetBalTaxValues(GncEntry *entry, gboolean is_cust_doc)
Careful: the returned list is NOT owned by the entry and should be freed by the caller.
Definition: gncEntry.c:1584
void gncEntryComputeValue(gnc_numeric qty, gnc_numeric price, const GncTaxTable *tax_table, gboolean tax_included, gnc_numeric discount, GncAmountType discount_type, GncDiscountHow discount_how, int SCU, gnc_numeric *value, gnc_numeric *discount_value, GList **tax_values)
Compute the Entry value, tax_value, and discount_value, based on the quantity, price, discount, tax_-table, and types.
GDate gncEntryGetDateGDate(const GncEntry *entry)
Returns the day of this entry.
Definition: gncEntry.c:918
Tax Table programming interface.
– Business Helper Functions
void gncEntrySetDateGDate(GncEntry *entry, const GDate *date)
Set the date of this entry.
Definition: gncEntry.c:504
const char * gncEntryDiscountHowToString(GncDiscountHow how)
How to apply the discount and taxes.
Definition: gncEntry.c:113
Business Invoice Interface.
gnc_numeric gncEntryGetQuantity(const GncEntry *entry)
Get the quantity as stored internally.
Definition: gncEntry.c:946
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition: gnc-date.h:87
void gncEntrySetDate(GncEntry *entry, time64 date)
DEPRECATED - use gncEntrySetDateGDate() instead! (Because the time-of-day is a misleading extra infor...
Definition: gncEntry.c:482
The type used to store guids in C.
Definition: guid.h:75
GncAmountType
How to interpret the amount.
Definition: gncTaxTable.h:78
gnc_numeric gncEntryGetDocQuantity(const GncEntry *entry, gboolean is_cn)
Get the quantity as on the physical document.
Definition: gncEntry.c:952
modtime is the internal date of the last modtime See libgnucash/engine/TaxTableBillTermImmutability.txt for an explanation of the following Code that handles refcount, parent, child, invisible and children is identical to that in ::GncBillTerm