GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 [email protected] *
20  * *
21 \********************************************************************/
31 #ifndef GNC_ENTRY_H_
32 #define GNC_ENTRY_H_
33 
34 typedef struct _gncEntry GncEntry;
35 typedef struct _gncEntryClass GncEntryClass;
36 
37 typedef enum
38 {
39  GNC_PAYMENT_CASH = 1,
40  GNC_PAYMENT_CARD
41 } GncEntryPaymentType;
42 
43 typedef enum
44 {
45  GNC_DISC_PRETAX = 1,
46  GNC_DISC_SAMETIME,
47  GNC_DISC_POSTTAX
48 } GncDiscountHow;
49 
50 #ifdef GNUCASH_MAJOR_VERSION
51 #include "gncBusiness.h"
52 #endif
53 #include "gncInvoice.h"
54 #include "gncOrder.h"
55 #include "gncTaxTable.h"
56 #include "gncOwner.h"
57 
58 #define GNC_ID_ENTRY "gncEntry"
59 
60 /* --- type macros --- */
61 #define GNC_TYPE_ENTRY (gnc_entry_get_type ())
62 #define GNC_ENTRY(o) \
63  (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_ENTRY, GncEntry))
64 #define GNC_ENTRY_CLASS(k) \
65  (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_ENTRY, GncEntryClass))
66 #define GNC_IS_ENTRY(o) \
67  (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_ENTRY))
68 #define GNC_IS_ENTRY_CLASS(k) \
69  (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_ENTRY))
70 #define GNC_ENTRY_GET_CLASS(o) \
71  (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_ENTRY, GncEntryClass))
72 GType gnc_entry_get_type(void);
73 
83 const char * gncEntryDiscountHowToString (GncDiscountHow how);
84 gboolean gncEntryDiscountStringToHow (const char *str, GncDiscountHow *how);
85 
86 const char * gncEntryPaymentTypeToString (GncEntryPaymentType type);
87 gboolean gncEntryPaymentStringToType (const char *str, GncEntryPaymentType *type);
88 
91 GncEntry *gncEntryCreate (QofBook *book);
92 void gncEntryDestroy (GncEntry *entry);
95 /* SET FUNCTIONS */
96 
100 void gncEntrySetDateGDate (GncEntry *entry, const GDate* date);
104 void gncEntrySetDate (GncEntry *entry, Timespec date);
105 void gncEntrySetDateEntered (GncEntry *entry, Timespec date);
106 void gncEntrySetDescription (GncEntry *entry, const char *desc);
107 void gncEntrySetAction (GncEntry *entry, const char *action);
108 void gncEntrySetNotes (GncEntry *entry, const char *notes);
114 void gncEntrySetQuantity (GncEntry *entry, gnc_numeric quantity);
121 void gncEntrySetDocQuantity (GncEntry *entry, gnc_numeric quantity, gboolean is_cn);
126 void gncEntrySetInvAccount (GncEntry *entry, Account *acc);
127 void gncEntrySetInvPrice (GncEntry *entry, gnc_numeric price);
128 void gncEntrySetInvTaxable (GncEntry *entry, gboolean taxable);
129 void gncEntrySetInvTaxIncluded (GncEntry *entry, gboolean tax_included);
130 void gncEntrySetInvTaxTable (GncEntry *entry, GncTaxTable *table);
131 void gncEntrySetInvDiscount (GncEntry *entry, gnc_numeric discount);
132 void gncEntrySetInvDiscountType (GncEntry *entry, GncAmountType type);
133 void gncEntrySetInvDiscountHow (GncEntry *entry, GncDiscountHow how);
134 void qofEntrySetInvDiscType (GncEntry *entry, const char *type);
135 void qofEntrySetInvDiscHow (GncEntry *entry, const char *type);
140 void gncEntrySetBillAccount (GncEntry *entry, Account *acc);
141 void gncEntrySetBillPrice (GncEntry *entry, gnc_numeric price);
142 void gncEntrySetBillTaxable (GncEntry *entry, gboolean taxable);
143 void gncEntrySetBillTaxIncluded (GncEntry *entry, gboolean tax_included);
144 void gncEntrySetBillTaxTable (GncEntry *entry, GncTaxTable *table);
145 void gncEntrySetBillable (GncEntry *entry, gboolean billable);
146 void gncEntrySetBillTo (GncEntry *entry, GncOwner *billto);
151 void gncEntrySetBillPayment (GncEntry *entry, GncEntryPaymentType type);
154 /* GET FUNCTIONS */
158 GDate gncEntryGetDateGDate (const GncEntry *entry);
162 Timespec gncEntryGetDate (const GncEntry *entry);
163 Timespec gncEntryGetDateEntered (const GncEntry *entry);
164 const char * gncEntryGetDescription (const GncEntry *entry);
165 const char * gncEntryGetAction (const GncEntry *entry);
166 const char * gncEntryGetNotes (const GncEntry *notes);
178 gnc_numeric gncEntryGetDocQuantity (const GncEntry *entry, gboolean is_cn);
183 Account * gncEntryGetInvAccount (const GncEntry *entry);
184 gnc_numeric gncEntryGetInvPrice (const GncEntry *entry);
185 gnc_numeric gncEntryGetInvDiscount (const GncEntry *entry);
186 GncAmountType gncEntryGetInvDiscountType (const GncEntry *entry);
187 GncDiscountHow gncEntryGetInvDiscountHow (const GncEntry *entry);
188 char* qofEntryGetInvDiscType (const GncEntry *entry);
189 char* qofEntryGetInvDiscHow (const GncEntry *entry);
190 gboolean gncEntryGetInvTaxable (const GncEntry *entry);
191 gboolean gncEntryGetInvTaxIncluded (const GncEntry *entry);
192 GncTaxTable * gncEntryGetInvTaxTable (const GncEntry *entry);
197 Account * gncEntryGetBillAccount (const GncEntry *entry);
198 gnc_numeric gncEntryGetBillPrice (const GncEntry *entry);
199 gboolean gncEntryGetBillTaxable (const GncEntry *entry);
200 gboolean gncEntryGetBillTaxIncluded (const GncEntry *entry);
201 GncTaxTable * gncEntryGetBillTaxTable (const GncEntry *entry);
202 gboolean gncEntryGetBillable (const GncEntry *entry);
203 GncOwner *gncEntryGetBillTo (GncEntry *entry);
204 
205 GncEntryPaymentType gncEntryGetBillPayment (const GncEntry* entry);
208 void gncEntryCopy (const GncEntry *src, GncEntry *dest, gboolean add_entry);
209 
245 typedef GList AccountValueList;
246 gnc_numeric gncEntryGetDocValue (GncEntry *entry, gboolean round, gboolean is_cust_doc, gboolean is_cn);
247 gnc_numeric gncEntryGetDocTaxValue (GncEntry *entry, gboolean round, gboolean is_cust_doc, gboolean is_cn);
249 AccountValueList * gncEntryGetDocTaxValues (GncEntry *entry, gboolean is_cust_doc, gboolean is_cn);
250 gnc_numeric gncEntryGetDocDiscountValue (GncEntry *entry, gboolean round, gboolean is_cust_doc, gboolean is_cn);
251 
252 gnc_numeric gncEntryGetBalValue (GncEntry *entry, gboolean round, gboolean is_cust_doc);
253 gnc_numeric gncEntryGetBalTaxValue (GncEntry *entry, gboolean round, gboolean is_cust_doc);
255 AccountValueList * gncEntryGetBalTaxValues (GncEntry *entry, gboolean is_cust_doc);
256 gnc_numeric gncEntryGetBalDiscountValue (GncEntry *entry, gboolean round, gboolean is_cust_doc);
257 
271  const GncTaxTable *tax_table, gboolean tax_included,
272  gnc_numeric discount, GncAmountType discount_type,
273  GncDiscountHow discount_how, int SCU,
274  /* return values */
275  gnc_numeric *value, gnc_numeric *discount_value,
276  GList **tax_values);
277 
280 GncOrder * gncEntryGetOrder (const GncEntry *entry);
281 GncInvoice * gncEntryGetInvoice (const GncEntry *entry);
282 GncInvoice * gncEntryGetBill (const GncEntry *entry);
283 
290 static inline GncEntry * gncEntryLookup (const QofBook *book, const GncGUID *guid)
291 {
292  QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_ENTRY, GncEntry);
293 }
294 
295 gboolean gncEntryIsOpen (const GncEntry *entry);
296 void gncEntryBeginEdit (GncEntry *entry);
297 void gncEntryCommitEdit (GncEntry *entry);
298 int gncEntryCompare (const GncEntry *a, const GncEntry *b);
299 
300 #define ENTRY_DATE "date"
301 #define ENTRY_DATE_ENTERED "date-entered"
302 #define ENTRY_DESC "desc"
303 #define ENTRY_ACTION "action"
304 #define ENTRY_NOTES "notes"
305 #define ENTRY_QTY "qty"
306 
307 #define ENTRY_IPRICE "iprice"
308 #define ENTRY_IACCT "invoice-account"
309 #define ENTRY_BACCT "bill-account"
310 #define ENTRY_BPRICE "bprice"
311 #define ENTRY_BILLABLE "billable?"
312 #define ENTRY_BILLTO "bill-to"
313 
314 #define ENTRY_ORDER "order"
315 #define ENTRY_INVOICE "invoice"
316 #define ENTRY_BILL "bill"
317 
318 #define ENTRY_INV_DISC_TYPE "discount-type"
319 #define ENTRY_INV_DISC_HOW "discount-method"
320 
321 #define ENTRY_INV_TAXABLE "invoice-taxable"
322 #define ENTRY_BILL_TAXABLE "bill-taxable"
323 #define ENTRY_INV_TAX_INC "invoice-tax-included"
324 #define ENTRY_BILL_TAX_INC "bill-tax-included"
325 #define ENTRY_INV_DISCOUNT "invoice-discount"
326 #define ENTRY_BILL_PAY_TYPE "bill-payment-type"
327 
328 
329 /* deprecated functions, should be removed */
330 #define gncEntryGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x))
331 
332 #endif /* GNC_ENTRY_H_ */
333 
Business Interface: Object OWNERs.
void gncEntrySetQuantity(GncEntry *entry, gnc_numeric quantity)
Definition: gncEntry.c:552
void gncEntrySetDate(GncEntry *entry, Timespec date)
Definition: gncEntry.c:481
AccountValueList * gncEntryGetDocTaxValues(GncEntry *entry, gboolean is_cust_doc, gboolean is_cn)
Definition: gncEntry.c:1445
Use a 64-bit unsigned int timespec.
Definition: gnc-date.h:299
Timespec gncEntryGetDate(const GncEntry *entry)
Definition: gncEntry.c:878
#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
void gncEntrySetDocQuantity(GncEntry *entry, gnc_numeric quantity, gboolean is_cn)
Definition: gncEntry.c:563
Definition: guid.h:65
AccountValueList * gncEntryGetBalTaxValues(GncEntry *entry, gboolean is_cust_doc)
Definition: gncEntry.c:1481
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)
Definition: gncEntry.c:1102
GDate gncEntryGetDateGDate(const GncEntry *entry)
Definition: gncEntry.c:887
Tax Table programming interface.
void gncEntrySetDateGDate(GncEntry *entry, const GDate *date)
Definition: gncEntry.c:505
const char * gncEntryDiscountHowToString(GncDiscountHow how)
Definition: gncEntry.c:112
Business Invoice Interface.
gnc_numeric gncEntryGetQuantity(const GncEntry *entry)
Definition: gncEntry.c:919
GncAmountType
Definition: gncTaxTable.h:93
gnc_numeric gncEntryGetDocQuantity(const GncEntry *entry, gboolean is_cn)
Definition: gncEntry.c:925