|
GnuCash 2.4.99
|
00001 /********************************************************************\ 00002 * gncEntry.h -- the Core Business Entry 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 \********************************************************************/ 00031 #ifndef GNC_ENTRY_H_ 00032 #define GNC_ENTRY_H_ 00033 00034 typedef struct _gncEntry GncEntry; 00035 typedef struct _gncEntryClass GncEntryClass; 00036 00037 typedef enum 00038 { 00039 GNC_PAYMENT_CASH = 1, 00040 GNC_PAYMENT_CARD 00041 } GncEntryPaymentType; 00042 00043 typedef enum 00044 { 00045 GNC_DISC_PRETAX = 1, 00046 GNC_DISC_SAMETIME, 00047 GNC_DISC_POSTTAX 00048 } GncDiscountHow; 00049 00050 #ifdef GNUCASH_MAJOR_VERSION 00051 #include "gncBusiness.h" 00052 #endif 00053 #include "gncInvoice.h" 00054 #include "gncOrder.h" 00055 #include "gncTaxTable.h" 00056 #include "gncOwner.h" 00057 00058 #define GNC_ID_ENTRY "gncEntry" 00059 00060 /* --- type macros --- */ 00061 #define GNC_TYPE_ENTRY (gnc_entry_get_type ()) 00062 #define GNC_ENTRY(o) \ 00063 (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_ENTRY, GncEntry)) 00064 #define GNC_ENTRY_CLASS(k) \ 00065 (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_ENTRY, GncEntryClass)) 00066 #define GNC_IS_ENTRY(o) \ 00067 (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_ENTRY)) 00068 #define GNC_IS_ENTRY_CLASS(k) \ 00069 (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_ENTRY)) 00070 #define GNC_ENTRY_GET_CLASS(o) \ 00071 (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_ENTRY, GncEntryClass)) 00072 GType gnc_entry_get_type(void); 00073 00083 const char * gncEntryDiscountHowToString (GncDiscountHow how); 00084 gboolean gncEntryDiscountStringToHow (const char *str, GncDiscountHow *how); 00085 00086 const char * gncEntryPaymentTypeToString (GncEntryPaymentType type); 00087 gboolean gncEntryPaymentStringToType (const char *str, GncEntryPaymentType *type); 00088 00091 GncEntry *gncEntryCreate (QofBook *book); 00092 void gncEntryDestroy (GncEntry *entry); 00095 /* SET FUNCTIONS */ 00096 00100 void gncEntrySetDateGDate (GncEntry *entry, const GDate* date); 00104 void gncEntrySetDate (GncEntry *entry, Timespec date); 00105 void gncEntrySetDateEntered (GncEntry *entry, Timespec date); 00106 void gncEntrySetDescription (GncEntry *entry, const char *desc); 00107 void gncEntrySetAction (GncEntry *entry, const char *action); 00108 void gncEntrySetNotes (GncEntry *entry, const char *notes); 00114 void gncEntrySetQuantity (GncEntry *entry, gnc_numeric quantity); 00121 void gncEntrySetDocQuantity (GncEntry *entry, gnc_numeric quantity, gboolean is_cn); 00126 void gncEntrySetInvAccount (GncEntry *entry, Account *acc); 00127 void gncEntrySetInvPrice (GncEntry *entry, gnc_numeric price); 00128 void gncEntrySetInvTaxable (GncEntry *entry, gboolean taxable); 00129 void gncEntrySetInvTaxIncluded (GncEntry *entry, gboolean tax_included); 00130 void gncEntrySetInvTaxTable (GncEntry *entry, GncTaxTable *table); 00131 void gncEntrySetInvDiscount (GncEntry *entry, gnc_numeric discount); 00132 void gncEntrySetInvDiscountType (GncEntry *entry, GncAmountType type); 00133 void gncEntrySetInvDiscountHow (GncEntry *entry, GncDiscountHow how); 00134 void qofEntrySetInvDiscType (GncEntry *entry, const char *type); 00135 void qofEntrySetInvDiscHow (GncEntry *entry, const char *type); 00140 void gncEntrySetBillAccount (GncEntry *entry, Account *acc); 00141 void gncEntrySetBillPrice (GncEntry *entry, gnc_numeric price); 00142 void gncEntrySetBillTaxable (GncEntry *entry, gboolean taxable); 00143 void gncEntrySetBillTaxIncluded (GncEntry *entry, gboolean tax_included); 00144 void gncEntrySetBillTaxTable (GncEntry *entry, GncTaxTable *table); 00145 void gncEntrySetBillable (GncEntry *entry, gboolean billable); 00146 void gncEntrySetBillTo (GncEntry *entry, GncOwner *billto); 00151 void gncEntrySetBillPayment (GncEntry *entry, GncEntryPaymentType type); 00154 /* GET FUNCTIONS */ 00158 GDate gncEntryGetDateGDate (const GncEntry *entry); 00162 Timespec gncEntryGetDate (const GncEntry *entry); 00163 Timespec gncEntryGetDateEntered (const GncEntry *entry); 00164 const char * gncEntryGetDescription (const GncEntry *entry); 00165 const char * gncEntryGetAction (const GncEntry *entry); 00166 const char * gncEntryGetNotes (const GncEntry *notes); 00172 gnc_numeric gncEntryGetQuantity (const GncEntry *entry); 00178 gnc_numeric gncEntryGetDocQuantity (const GncEntry *entry, gboolean is_cn); 00183 Account * gncEntryGetInvAccount (const GncEntry *entry); 00184 gnc_numeric gncEntryGetInvPrice (const GncEntry *entry); 00185 gnc_numeric gncEntryGetInvDiscount (const GncEntry *entry); 00186 GncAmountType gncEntryGetInvDiscountType (const GncEntry *entry); 00187 GncDiscountHow gncEntryGetInvDiscountHow (const GncEntry *entry); 00188 char* qofEntryGetInvDiscType (const GncEntry *entry); 00189 char* qofEntryGetInvDiscHow (const GncEntry *entry); 00190 gboolean gncEntryGetInvTaxable (const GncEntry *entry); 00191 gboolean gncEntryGetInvTaxIncluded (const GncEntry *entry); 00192 GncTaxTable * gncEntryGetInvTaxTable (const GncEntry *entry); 00197 Account * gncEntryGetBillAccount (const GncEntry *entry); 00198 gnc_numeric gncEntryGetBillPrice (const GncEntry *entry); 00199 gboolean gncEntryGetBillTaxable (const GncEntry *entry); 00200 gboolean gncEntryGetBillTaxIncluded (const GncEntry *entry); 00201 GncTaxTable * gncEntryGetBillTaxTable (const GncEntry *entry); 00202 gboolean gncEntryGetBillable (const GncEntry *entry); 00203 GncOwner *gncEntryGetBillTo (GncEntry *entry); 00204 00205 GncEntryPaymentType gncEntryGetBillPayment (const GncEntry* entry); 00208 void gncEntryCopy (const GncEntry *src, GncEntry *dest); 00209 00245 typedef GList AccountValueList; 00246 gnc_numeric gncEntryGetDocValue (GncEntry *entry, gboolean round, gboolean is_cust_doc, gboolean is_cn); 00247 gnc_numeric gncEntryGetDocTaxValue (GncEntry *entry, gboolean round, gboolean is_cust_doc, gboolean is_cn); 00249 AccountValueList * gncEntryGetDocTaxValues (GncEntry *entry, gboolean is_cust_doc, gboolean is_cn); 00250 gnc_numeric gncEntryGetDocDiscountValue (GncEntry *entry, gboolean round, gboolean is_cust_doc, gboolean is_cn); 00251 00252 gnc_numeric gncEntryGetBalValue (GncEntry *entry, gboolean round, gboolean is_cust_doc); 00253 gnc_numeric gncEntryGetBalTaxValue (GncEntry *entry, gboolean round, gboolean is_cust_doc); 00255 AccountValueList * gncEntryGetBalTaxValues (GncEntry *entry, gboolean is_cust_doc); 00256 gnc_numeric gncEntryGetBalDiscountValue (GncEntry *entry, gboolean round, gboolean is_cust_doc); 00257 00270 void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price, 00271 const GncTaxTable *tax_table, gboolean tax_included, 00272 gnc_numeric discount, GncAmountType discount_type, 00273 GncDiscountHow discount_how, int SCU, 00274 /* return values */ 00275 gnc_numeric *value, gnc_numeric *discount_value, 00276 GList **tax_values); 00277 00280 GncOrder * gncEntryGetOrder (const GncEntry *entry); 00281 GncInvoice * gncEntryGetInvoice (const GncEntry *entry); 00282 GncInvoice * gncEntryGetBill (const GncEntry *entry); 00283 00290 static inline GncEntry * gncEntryLookup (const QofBook *book, const GncGUID *guid) 00291 { 00292 QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_ENTRY, GncEntry); 00293 } 00294 00295 gboolean gncEntryIsOpen (const GncEntry *entry); 00296 void gncEntryBeginEdit (GncEntry *entry); 00297 void gncEntryCommitEdit (GncEntry *entry); 00298 int gncEntryCompare (const GncEntry *a, const GncEntry *b); 00299 00300 #define ENTRY_DATE "date" 00301 #define ENTRY_DATE_ENTERED "date-entered" 00302 #define ENTRY_DESC "desc" 00303 #define ENTRY_ACTION "action" 00304 #define ENTRY_NOTES "notes" 00305 #define ENTRY_QTY "qty" 00306 00307 #define ENTRY_IPRICE "iprice" 00308 #define ENTRY_IACCT "invoice-account" 00309 #define ENTRY_BACCT "bill-account" 00310 #define ENTRY_BPRICE "bprice" 00311 #define ENTRY_BILLABLE "billable?" 00312 #define ENTRY_BILLTO "bill-to" 00313 00314 #define ENTRY_ORDER "order" 00315 #define ENTRY_INVOICE "invoice" 00316 #define ENTRY_BILL "bill" 00317 00318 #define ENTRY_INV_DISC_TYPE "discount-type" 00319 #define ENTRY_INV_DISC_HOW "discount-method" 00320 00321 #define ENTRY_INV_TAXABLE "invoice-taxable" 00322 #define ENTRY_BILL_TAXABLE "bill-taxable" 00323 #define ENTRY_INV_TAX_INC "invoice-tax-included" 00324 #define ENTRY_BILL_TAX_INC "bill-tax-included" 00325 #define ENTRY_INV_DISCOUNT "invoice-discount" 00326 #define ENTRY_BILL_PAY_TYPE "bill-payment-type" 00327 00328 00329 /* deprecated functions, should be removed */ 00330 #define gncEntryGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x)) 00331 00332 #endif /* GNC_ENTRY_H_ */ 00333
1.7.4