GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gncInvoice.h
Go to the documentation of this file.
1 /********************************************************************\
2  * gncInvoice.h -- the Core Business Invoice 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 \********************************************************************/
36 #ifndef GNC_INVOICE_H_
37 #define GNC_INVOICE_H_
38 
39 struct _gncInvoice;
40 typedef struct _gncInvoice GncInvoice;
41 typedef struct _gncInvoiceClass GncInvoiceClass;
42 typedef GList GncInvoiceList;
43 
44 #include <glib.h>
45 #include "gncBillTerm.h"
46 #include "gncEntry.h"
47 #include "gncOwner.h"
48 #include "gnc-lot.h"
49 #include "qofbook.h"
50 #include "qofbook.h"
51 #include "gnc-pricedb.h"
52 
53 #define GNC_ID_INVOICE "gncInvoice"
54 
55 typedef enum
56 {
57  GNC_INVOICE_UNDEFINED ,
58  GNC_INVOICE_CUST_INVOICE , /* Invoice */
59  GNC_INVOICE_VEND_INVOICE , /* Bill */
60  GNC_INVOICE_EMPL_INVOICE , /* Voucher */
61  GNC_INVOICE_CUST_CREDIT_NOTE , /* Credit Note for a customer */
62  GNC_INVOICE_VEND_CREDIT_NOTE , /* Credit Note from a vendor */
63  GNC_INVOICE_EMPL_CREDIT_NOTE , /* Credit Note from an employee,
64  not sure this makes sense,
65  but all code is symmetrical
66  so I've added it to prevent unexpected errors */
67  GNC_INVOICE_NUM_TYPES
68 } GncInvoiceType;
69 
70 /* --- type macros --- */
71 #define GNC_TYPE_INVOICE (gnc_invoice_get_type ())
72 #define GNC_INVOICE(o) \
73  (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_INVOICE, GncInvoice))
74 #define GNC_INVOICE_CLASS(k) \
75  (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_INVOICE, GncInvoiceClass))
76 #define GNC_IS_INVOICE(o) \
77  (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_INVOICE))
78 #define GNC_IS_INVOICE_CLASS(k) \
79  (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_INVOICE))
80 #define GNC_INVOICE_GET_CLASS(o) \
81  (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_INVOICE, GncInvoiceClass))
82 GType gnc_invoice_get_type(void);
83 
86 GncInvoice *gncInvoiceCreate (QofBook *book);
87 
88 void gncInvoiceDestroy (GncInvoice *invoice);
89 
96 GncInvoice *gncInvoiceCopy (const GncInvoice *other_invoice);
101 void gncInvoiceSetID (GncInvoice *invoice, const char *id);
102 void gncInvoiceSetOwner (GncInvoice *invoice, GncOwner *owner);
105 void gncInvoiceSetDateOpenedGDate (GncInvoice *invoice, const GDate *date);
106 void gncInvoiceSetDateOpened (GncInvoice *invoice, Timespec date);
107 void gncInvoiceSetDatePosted (GncInvoice *invoice, Timespec date);
108 void gncInvoiceSetTerms (GncInvoice *invoice, GncBillTerm *terms);
109 void gncInvoiceSetBillingID (GncInvoice *invoice, const char *billing_id);
110 void gncInvoiceSetNotes (GncInvoice *invoice, const char *notes);
111 void gncInvoiceSetCurrency (GncInvoice *invoice, gnc_commodity *currency);
112 void gncInvoiceSetActive (GncInvoice *invoice, gboolean active);
113 void gncInvoiceSetIsCreditNote (GncInvoice *invoice, gboolean credit_note);
114 void gncInvoiceSetBillTo (GncInvoice *invoice, GncOwner *billto);
115 void gncInvoiceSetToChargeAmount (GncInvoice *invoice, gnc_numeric amount);
118 void gncInvoiceAddEntry (GncInvoice *invoice, GncEntry *entry);
119 void gncInvoiceRemoveEntry (GncInvoice *invoice, GncEntry *entry);
120 void gncInvoiceAddPrice (GncInvoice *invoice, GNCPrice *price);
121 
123 void gncBillAddEntry (GncInvoice *bill, GncEntry *entry);
124 void gncBillRemoveEntry (GncInvoice *bill, GncEntry *entry);
125 
129 void gncInvoiceSortEntries (GncInvoice *invoice);
130 
134 void gncInvoiceRemoveEntries (GncInvoice *invoice);
135 
138 const char * gncInvoiceGetID (const GncInvoice *invoice);
139 const GncOwner * gncInvoiceGetOwner (const GncInvoice *invoice);
140 Timespec gncInvoiceGetDateOpened (const GncInvoice *invoice);
141 Timespec gncInvoiceGetDatePosted (const GncInvoice *invoice);
142 Timespec gncInvoiceGetDateDue (const GncInvoice *invoice);
143 GncBillTerm * gncInvoiceGetTerms (const GncInvoice *invoice);
144 const char * gncInvoiceGetBillingID (const GncInvoice *invoice);
145 const char * gncInvoiceGetNotes (const GncInvoice *invoice);
146 GncOwnerType gncInvoiceGetOwnerType (const GncInvoice *invoice);
147 GList * gncInvoiceGetTypeListForOwnerType (const GncOwnerType type);
148 GncInvoiceType gncInvoiceGetType (const GncInvoice *invoice);
149 const char * gncInvoiceGetTypeString (const GncInvoice *invoice);
150 gnc_commodity * gncInvoiceGetCurrency (const GncInvoice *invoice);
151 GncOwner * gncInvoiceGetBillTo (GncInvoice *invoice);
152 gnc_numeric gncInvoiceGetToChargeAmount (const GncInvoice *invoice);
153 gboolean gncInvoiceGetActive (const GncInvoice *invoice);
154 gboolean gncInvoiceGetIsCreditNote (const GncInvoice *invoice);
155 
156 GNCLot * gncInvoiceGetPostedLot (const GncInvoice *invoice);
157 Transaction * gncInvoiceGetPostedTxn (const GncInvoice *invoice);
158 Account * gncInvoiceGetPostedAcc (const GncInvoice *invoice);
164 gnc_numeric gncInvoiceGetTotalOf (GncInvoice *invoice, GncEntryPaymentType type);
165 gnc_numeric gncInvoiceGetTotalSubtotal (GncInvoice *invoice);
166 gnc_numeric gncInvoiceGetTotalTax (GncInvoice *invoice);
167 
168 typedef GList EntryList;
169 EntryList * gncInvoiceGetEntries (GncInvoice *invoice);
170 GNCPrice * gncInvoiceGetPrice(GncInvoice *invoice, gnc_commodity* commodity);
171 
180 gboolean gncInvoiceAmountPositive (const GncInvoice *invoice);
181 
191 GHashTable *gncInvoiceGetForeignCurrencies (const GncInvoice *invoice);
192 
210 Transaction *
212  Timespec *posted_date, Timespec *due_date,
213  const char *memo, gboolean accumulatesplits,
214  gboolean autopay);
215 
226 gboolean
227 gncInvoiceUnpost (GncInvoice *invoice, gboolean reset_tax_tables);
228 
234 void
236 
250 void
251 gncInvoiceApplyPayment (const GncInvoice *invoice, Transaction *txn,
252  Account *xfer_acc, gnc_numeric amount,
253  gnc_numeric exch, Timespec date,
254  const char *memo, const char *num);
255 
256 
259 
262 
269 static inline GncInvoice * gncInvoiceLookup (const QofBook *book, const GncGUID *guid)
270 {
271  if (book == NULL || guid == NULL) return NULL;
272  QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_INVOICE, GncInvoice);
273 }
274 
275 void gncInvoiceBeginEdit (GncInvoice *invoice);
276 void gncInvoiceCommitEdit (GncInvoice *invoice);
277 int gncInvoiceCompare (const GncInvoice *a, const GncInvoice *b);
278 gboolean gncInvoiceIsPosted (const GncInvoice *invoice);
279 gboolean gncInvoiceIsPaid (const GncInvoice *invoice);
280 
281 #define INVOICE_ID "id"
282 #define INVOICE_OWNER "owner"
283 #define INVOICE_OPENED "date_opened"
284 #define INVOICE_POSTED "date_posted"
285 #define INVOICE_DUE "date_due"
286 #define INVOICE_IS_POSTED "is_posted?"
287 #define INVOICE_IS_PAID "is_paid?"
288 #define INVOICE_TERMS "terms"
289 #define INVOICE_BILLINGID "billing_id"
290 #define INVOICE_NOTES "notes"
291 #define INVOICE_ACC "account"
292 #define INVOICE_POST_TXN "posted_txn"
293 #define INVOICE_POST_LOT "posted_lot"
294 #define INVOICE_IS_CN "credit_note"
295 #define INVOICE_TYPE "type"
296 #define INVOICE_TYPE_STRING "type_string"
297 #define INVOICE_BILLTO "bill-to"
298 #define INVOICE_ENTRIES "list_of_entries"
299 #define INVOICE_JOB "invoice_job"
300 
301 #define INVOICE_FROM_LOT "invoice-from-lot"
302 #define INVOICE_FROM_TXN "invoice-from-txn"
303 
304 QofBook *gncInvoiceGetBook(GncInvoice *x);
305 
307 #define gncInvoiceGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x))
308 #define gncInvoiceRetGUID(x) (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null()))
309 
311 gboolean gncInvoiceEqual(const GncInvoice *a, const GncInvoice *b);
312 
313 #endif /* GNC_INVOICE_H_ */
314 
Business Interface: Object OWNERs.
a simple price database for gnucash
Use a 64-bit unsigned int timespec.
Definition: gnc-date.h:299
void gncInvoiceRemoveEntries(GncInvoice *invoice)
Definition: gncInvoice.c:727
#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
GHashTable * gncInvoiceGetForeignCurrencies(const GncInvoice *invoice)
Definition: gncInvoice.c:1236
void gncInvoiceSortEntries(GncInvoice *invoice)
Definition: gncInvoice.c:717
gnc_numeric gncInvoiceGetTotal(GncInvoice *invoice)
Definition: gncInvoice.c:908
Definition: guid.h:65
void gncInvoiceAutoApplyPayments(GncInvoice *invoice)
Definition: gncInvoice.c:1786
GncInvoice * gncInvoiceGetInvoiceFromTxn(const Transaction *txn)
Definition: gncInvoice.c:1203
void gncInvoiceApplyPayment(const GncInvoice *invoice, Transaction *txn, Account *xfer_acc, gnc_numeric amount, gnc_numeric exch, Timespec date, const char *memo, const char *num)
Definition: gncInvoice.c:1830
void gncBillAddEntry(GncInvoice *bill, GncEntry *entry)
Definition: gncInvoice.c:686
Transaction * gncInvoicePostToAccount(GncInvoice *invoice, Account *acc, Timespec *posted_date, Timespec *due_date, const char *memo, gboolean accumulatesplits, gboolean autopay)
Definition: gncInvoice.c:1363
Encapsulate all the information about a dataset.
void gncInvoiceSetDateOpenedGDate(GncInvoice *invoice, const GDate *date)
Definition: gncInvoice.c:480
GncInvoice * gncInvoiceGetInvoiceFromLot(GNCLot *lot)
Definition: gncInvoice.c:1174
gboolean gncInvoiceUnpost(GncInvoice *invoice, gboolean reset_tax_tables)
Definition: gncInvoice.c:1621
Business Entry Interface.
gboolean gncInvoiceEqual(const GncInvoice *a, const GncInvoice *b)
Definition: gncInvoice.c:1926
GncInvoice * gncInvoiceCopy(const GncInvoice *other_invoice)
Definition: gncInvoice.c:336
Billing Term interface.
gboolean gncInvoiceAmountPositive(const GncInvoice *invoice)
Definition: gncInvoice.c:1215