|
GnuCash 2.4.99
|
00001 /********************************************************************\ 00002 * gncInvoice.h -- the Core Business Invoice Interface * 00003 * * 00004 * This program is free software; you can redistribute it and/or * 00005 * modify it under the terms of the GNU General Public License as * 00006 * published by the Free Software Foundation; either version 2 of * 00007 * the License, or (at your option) any later version. * 00008 * * 00009 * This program is distributed in the hope that it will be useful, * 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00012 * GNU General Public License for more details. * 00013 * * 00014 * You should have received a copy of the GNU General Public License* 00015 * along with this program; if not, contact: * 00016 * * 00017 * Free Software Foundation Voice: +1-617-542-5942 * 00018 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * 00019 * Boston, MA 02110-1301, USA gnu@gnu.org * 00020 * * 00021 \********************************************************************/ 00036 #ifndef GNC_INVOICE_H_ 00037 #define GNC_INVOICE_H_ 00038 00039 struct _gncInvoice; 00040 typedef struct _gncInvoice GncInvoice; 00041 typedef struct _gncInvoiceClass GncInvoiceClass; 00042 typedef GList GncInvoiceList; 00043 00044 #include "gncBillTerm.h" 00045 #include "gncEntry.h" 00046 #include "gncOwner.h" 00047 #include "gnc-lot.h" 00048 #include "qofbook.h" 00049 #include "qofbook.h" 00050 #include "gnc-pricedb.h" 00051 00052 #define GNC_ID_INVOICE "gncInvoice" 00053 00054 typedef enum 00055 { 00056 GNC_INVOICE_UNDEFINED , 00057 GNC_INVOICE_CUST_INVOICE , /* Invoice */ 00058 GNC_INVOICE_VEND_INVOICE , /* Bill */ 00059 GNC_INVOICE_EMPL_INVOICE , /* Voucher */ 00060 GNC_INVOICE_CUST_CREDIT_NOTE , /* Credit Note for a customer */ 00061 GNC_INVOICE_VEND_CREDIT_NOTE , /* Credit Note from a vendor */ 00062 GNC_INVOICE_EMPL_CREDIT_NOTE , /* Credit Note from an employee, 00063 not sure this makes sense, 00064 but all code is symmetrical 00065 so I've added it to prevent unexpected errors */ 00066 GNC_INVOICE_NUM_TYPES 00067 } GncInvoiceType; 00068 00069 /* --- type macros --- */ 00070 #define GNC_TYPE_INVOICE (gnc_invoice_get_type ()) 00071 #define GNC_INVOICE(o) \ 00072 (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_INVOICE, GncInvoice)) 00073 #define GNC_INVOICE_CLASS(k) \ 00074 (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_INVOICE, GncInvoiceClass)) 00075 #define GNC_IS_INVOICE(o) \ 00076 (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_INVOICE)) 00077 #define GNC_IS_INVOICE_CLASS(k) \ 00078 (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_INVOICE)) 00079 #define GNC_INVOICE_GET_CLASS(o) \ 00080 (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_INVOICE, GncInvoiceClass)) 00081 GType gnc_invoice_get_type(void); 00082 00085 GncInvoice *gncInvoiceCreate (QofBook *book); 00086 00087 void gncInvoiceDestroy (GncInvoice *invoice); 00088 00095 GncInvoice *gncInvoiceCopy (const GncInvoice *other_invoice); 00100 void gncInvoiceSetID (GncInvoice *invoice, const char *id); 00101 void gncInvoiceSetOwner (GncInvoice *invoice, GncOwner *owner); 00104 void gncInvoiceSetDateOpenedGDate (GncInvoice *invoice, const GDate *date); 00105 void gncInvoiceSetDateOpened (GncInvoice *invoice, Timespec date); 00106 void gncInvoiceSetDatePosted (GncInvoice *invoice, Timespec date); 00107 void gncInvoiceSetTerms (GncInvoice *invoice, GncBillTerm *terms); 00108 void gncInvoiceSetBillingID (GncInvoice *invoice, const char *billing_id); 00109 void gncInvoiceSetNotes (GncInvoice *invoice, const char *notes); 00110 void gncInvoiceSetCurrency (GncInvoice *invoice, gnc_commodity *currency); 00111 void gncInvoiceSetActive (GncInvoice *invoice, gboolean active); 00112 void gncInvoiceSetIsCreditNote (GncInvoice *invoice, gboolean credit_note); 00113 void gncInvoiceSetBillTo (GncInvoice *invoice, GncOwner *billto); 00114 void gncInvoiceSetToChargeAmount (GncInvoice *invoice, gnc_numeric amount); 00117 void gncInvoiceAddEntry (GncInvoice *invoice, GncEntry *entry); 00118 void gncInvoiceRemoveEntry (GncInvoice *invoice, GncEntry *entry); 00119 void gncInvoiceAddPrice (GncInvoice *invoice, GNCPrice *price); 00120 00122 void gncBillAddEntry (GncInvoice *bill, GncEntry *entry); 00123 void gncBillRemoveEntry (GncInvoice *bill, GncEntry *entry); 00124 00128 void gncInvoiceSortEntries (GncInvoice *invoice); 00129 00132 const char * gncInvoiceGetID (const GncInvoice *invoice); 00133 const GncOwner * gncInvoiceGetOwner (const GncInvoice *invoice); 00134 Timespec gncInvoiceGetDateOpened (const GncInvoice *invoice); 00135 Timespec gncInvoiceGetDatePosted (const GncInvoice *invoice); 00136 Timespec gncInvoiceGetDateDue (const GncInvoice *invoice); 00137 GncBillTerm * gncInvoiceGetTerms (const GncInvoice *invoice); 00138 const char * gncInvoiceGetBillingID (const GncInvoice *invoice); 00139 const char * gncInvoiceGetNotes (const GncInvoice *invoice); 00140 GncOwnerType gncInvoiceGetOwnerType (const GncInvoice *invoice); 00141 GList * gncInvoiceGetTypeListForOwnerType (const GncOwnerType type); 00142 GncInvoiceType gncInvoiceGetType (const GncInvoice *invoice); 00143 const char * gncInvoiceGetTypeString (const GncInvoice *invoice); 00144 gnc_commodity * gncInvoiceGetCurrency (const GncInvoice *invoice); 00145 GncOwner * gncInvoiceGetBillTo (GncInvoice *invoice); 00146 gnc_numeric gncInvoiceGetToChargeAmount (const GncInvoice *invoice); 00147 gboolean gncInvoiceGetActive (const GncInvoice *invoice); 00148 gboolean gncInvoiceGetIsCreditNote (const GncInvoice *invoice); 00149 00150 GNCLot * gncInvoiceGetPostedLot (const GncInvoice *invoice); 00151 Transaction * gncInvoiceGetPostedTxn (const GncInvoice *invoice); 00152 Account * gncInvoiceGetPostedAcc (const GncInvoice *invoice); 00157 gnc_numeric gncInvoiceGetTotal (GncInvoice *invoice); 00158 gnc_numeric gncInvoiceGetTotalOf (GncInvoice *invoice, GncEntryPaymentType type); 00159 gnc_numeric gncInvoiceGetTotalSubtotal (GncInvoice *invoice); 00160 gnc_numeric gncInvoiceGetTotalTax (GncInvoice *invoice); 00161 00162 typedef GList EntryList; 00163 EntryList * gncInvoiceGetEntries (GncInvoice *invoice); 00164 GNCPrice * gncInvoiceGetPrice(GncInvoice *invoice, gnc_commodity* commodity); 00165 00174 gboolean gncInvoiceAmountPositive (const GncInvoice *invoice); 00175 00181 Transaction * 00182 gncInvoicePostToAccount (GncInvoice *invoice, Account *acc, 00183 Timespec *posted_date, Timespec *due_date, 00184 const char *memo, gboolean accumulatesplits); 00185 00196 gboolean 00197 gncInvoiceUnpost (GncInvoice *invoice, gboolean reset_tax_tables); 00198 00204 void 00205 gncInvoiceAutoApplyPayments (GncInvoice *invoice); 00206 00220 void 00221 gncInvoiceApplyPayment (const GncInvoice *invoice, Transaction *txn, 00222 Account *xfer_acc, gnc_numeric amount, 00223 gnc_numeric exch, Timespec date, 00224 const char *memo, const char *num); 00225 00226 00228 GncInvoice * gncInvoiceGetInvoiceFromTxn (const Transaction *txn); 00229 00231 GncInvoice * gncInvoiceGetInvoiceFromLot (GNCLot *lot); 00232 00239 static inline GncInvoice * gncInvoiceLookup (const QofBook *book, const GncGUID *guid) 00240 { 00241 QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_INVOICE, GncInvoice); 00242 } 00243 00244 void gncInvoiceBeginEdit (GncInvoice *invoice); 00245 void gncInvoiceCommitEdit (GncInvoice *invoice); 00246 int gncInvoiceCompare (const GncInvoice *a, const GncInvoice *b); 00247 gboolean gncInvoiceIsPosted (const GncInvoice *invoice); 00248 gboolean gncInvoiceIsPaid (const GncInvoice *invoice); 00249 00250 #define INVOICE_ID "id" 00251 #define INVOICE_OWNER "owner" 00252 #define INVOICE_OPENED "date_opened" 00253 #define INVOICE_POSTED "date_posted" 00254 #define INVOICE_DUE "date_due" 00255 #define INVOICE_IS_POSTED "is_posted?" 00256 #define INVOICE_IS_PAID "is_paid?" 00257 #define INVOICE_TERMS "terms" 00258 #define INVOICE_BILLINGID "billing_id" 00259 #define INVOICE_NOTES "notes" 00260 #define INVOICE_ACC "account" 00261 #define INVOICE_POST_TXN "posted_txn" 00262 #define INVOICE_POST_LOT "posted_lot" 00263 #define INVOICE_IS_CN "credit_note" 00264 #define INVOICE_TYPE "type" 00265 #define INVOICE_TYPE_STRING "type_string" 00266 #define INVOICE_BILLTO "bill-to" 00267 #define INVOICE_ENTRIES "list_of_entries" 00268 #define INVOICE_JOB "invoice_job" 00269 00270 #define INVOICE_FROM_LOT "invoice-from-lot" 00271 #define INVOICE_FROM_TXN "invoice-from-txn" 00272 00273 QofBook *gncInvoiceGetBook(GncInvoice *x); 00274 00276 #define gncInvoiceGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x)) 00277 #define gncInvoiceRetGUID(x) (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null())) 00278 #define gncInvoiceLookupDirect(G,B) gncInvoiceLookup((B),&(G)) 00279 00281 gboolean gncInvoiceEqual(const GncInvoice *a, const GncInvoice *b); 00282 00283 #endif /* GNC_INVOICE_H_ */ 00284
1.7.4