2003-10-17 00:15:56 -05:00
|
|
|
/********************************************************************\
|
|
|
|
* gncEntry.h -- the Core Business Entry Interface *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License as *
|
|
|
|
* published by the Free Software Foundation; either version 2 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License*
|
|
|
|
* along with this program; if not, contact: *
|
|
|
|
* *
|
|
|
|
* Free Software Foundation Voice: +1-617-542-5942 *
|
|
|
|
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
|
|
|
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
|
|
|
* *
|
|
|
|
\********************************************************************/
|
|
|
|
|
2001-11-21 19:23:07 -06:00
|
|
|
/*
|
2002-01-20 20:27:02 -06:00
|
|
|
* Copyright (C) 2001,2002 Derek Atkins
|
2001-11-21 19:23:07 -06:00
|
|
|
* Author: Derek Atkins <warlord@MIT.EDU>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GNC_ENTRY_H_
|
|
|
|
#define GNC_ENTRY_H_
|
|
|
|
|
|
|
|
typedef struct _gncEntry GncEntry;
|
|
|
|
|
2003-04-01 15:15:22 -06:00
|
|
|
typedef enum {
|
|
|
|
GNC_PAYMENT_CASH = 1,
|
|
|
|
GNC_PAYMENT_CARD
|
|
|
|
} GncEntryPaymentType;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
GNC_DISC_PRETAX = 1,
|
|
|
|
GNC_DISC_SAMETIME,
|
|
|
|
GNC_DISC_POSTTAX
|
|
|
|
} GncDiscountHow;
|
|
|
|
|
2003-06-10 15:02:04 -05:00
|
|
|
#include "gnc-date.h"
|
2002-06-16 00:11:33 -05:00
|
|
|
#include "gncTaxTable.h"
|
2001-11-21 19:23:07 -06:00
|
|
|
#include "gncOrder.h"
|
|
|
|
#include "gncInvoice.h"
|
|
|
|
|
2003-10-17 00:15:56 -05:00
|
|
|
#include "qofbook.h"
|
|
|
|
#include "qofinstance.h"
|
|
|
|
|
2001-11-21 19:23:07 -06:00
|
|
|
#define GNC_ENTRY_MODULE_NAME "gncEntry"
|
|
|
|
|
2002-06-16 00:11:33 -05:00
|
|
|
/* How to apply the discount and taxes. There are three distinct ways to
|
|
|
|
* apply them:
|
|
|
|
*
|
|
|
|
* Type: discount tax
|
|
|
|
* PRETAX pretax pretax-discount
|
|
|
|
* SAMETIME pretax pretax
|
|
|
|
* POSTTAX pretax+tax pretax
|
|
|
|
*/
|
2003-03-02 22:58:55 -06:00
|
|
|
|
2002-07-01 13:31:48 -05:00
|
|
|
const char * gncEntryDiscountHowToString (GncDiscountHow how);
|
|
|
|
gboolean gncEntryDiscountStringToHow (const char *str, GncDiscountHow *how);
|
|
|
|
|
2003-03-02 22:58:55 -06:00
|
|
|
const char * gncEntryPaymentTypeToString (GncEntryPaymentType type);
|
|
|
|
gboolean gncEntryPaymentStringToType (const char *str, GncEntryPaymentType *type);
|
|
|
|
|
2001-11-21 19:23:07 -06:00
|
|
|
/* Create/Destroy Functions */
|
|
|
|
|
2003-06-26 22:05:25 -05:00
|
|
|
GncEntry *gncEntryCreate (QofBook *book);
|
2001-11-21 19:23:07 -06:00
|
|
|
void gncEntryDestroy (GncEntry *entry);
|
|
|
|
|
2002-09-14 00:32:37 -05:00
|
|
|
/* SET FUNCTIONS */
|
2001-11-21 19:23:07 -06:00
|
|
|
|
2002-09-14 00:32:37 -05:00
|
|
|
/* Generic (shared) data */
|
2002-02-27 23:10:07 -06:00
|
|
|
void gncEntrySetDate (GncEntry *entry, Timespec date);
|
|
|
|
void gncEntrySetDateEntered (GncEntry *entry, Timespec date);
|
2001-11-21 19:23:07 -06:00
|
|
|
void gncEntrySetDescription (GncEntry *entry, const char *desc);
|
|
|
|
void gncEntrySetAction (GncEntry *entry, const char *action);
|
2002-06-16 23:04:05 -05:00
|
|
|
void gncEntrySetNotes (GncEntry *entry, const char *notes);
|
2001-11-21 19:23:07 -06:00
|
|
|
void gncEntrySetQuantity (GncEntry *entry, gnc_numeric quantity);
|
|
|
|
|
2002-09-14 00:32:37 -05:00
|
|
|
/* Customer Invoices */
|
2002-07-11 10:11:33 -05:00
|
|
|
void gncEntrySetInvAccount (GncEntry *entry, Account *acc);
|
2002-09-14 00:32:37 -05:00
|
|
|
void gncEntrySetInvPrice (GncEntry *entry, gnc_numeric price);
|
|
|
|
void gncEntrySetInvTaxable (GncEntry *entry, gboolean taxable);
|
|
|
|
void gncEntrySetInvTaxIncluded (GncEntry *entry, gboolean tax_included);
|
|
|
|
void gncEntrySetInvTaxTable (GncEntry *entry, GncTaxTable *table);
|
|
|
|
void gncEntrySetInvDiscount (GncEntry *entry, gnc_numeric discount);
|
|
|
|
void gncEntrySetInvDiscountType (GncEntry *entry, GncAmountType type);
|
|
|
|
void gncEntrySetInvDiscountHow (GncEntry *entry, GncDiscountHow how);
|
|
|
|
|
|
|
|
/* Vendor Bills (and Employee Expenses) */
|
2002-07-11 10:11:33 -05:00
|
|
|
void gncEntrySetBillAccount (GncEntry *entry, Account *acc);
|
2002-09-14 00:32:37 -05:00
|
|
|
void gncEntrySetBillPrice (GncEntry *entry, gnc_numeric price);
|
|
|
|
void gncEntrySetBillTaxable (GncEntry *entry, gboolean taxable);
|
|
|
|
void gncEntrySetBillTaxIncluded (GncEntry *entry, gboolean tax_included);
|
|
|
|
void gncEntrySetBillTaxTable (GncEntry *entry, GncTaxTable *table);
|
|
|
|
void gncEntrySetBillable (GncEntry *entry, gboolean billable);
|
|
|
|
void gncEntrySetBillTo (GncEntry *entry, GncOwner *billto);
|
2001-11-21 19:23:07 -06:00
|
|
|
|
2003-03-02 22:58:55 -06:00
|
|
|
/* employee-stuff */
|
|
|
|
void gncEntrySetBillPayment (GncEntry *entry, GncEntryPaymentType type);
|
|
|
|
|
2002-09-14 00:32:37 -05:00
|
|
|
/* GET FUNCTIONS */
|
|
|
|
/* Generic (shared) data */
|
2001-11-21 19:23:07 -06:00
|
|
|
Timespec gncEntryGetDate (GncEntry *entry);
|
2002-02-27 23:10:07 -06:00
|
|
|
Timespec gncEntryGetDateEntered (GncEntry *entry);
|
2001-11-21 19:23:07 -06:00
|
|
|
const char * gncEntryGetDescription (GncEntry *entry);
|
|
|
|
const char * gncEntryGetAction (GncEntry *entry);
|
2002-06-16 23:04:05 -05:00
|
|
|
const char * gncEntryGetNotes (GncEntry *notes);
|
2001-11-21 19:23:07 -06:00
|
|
|
gnc_numeric gncEntryGetQuantity (GncEntry *entry);
|
2002-09-14 00:32:37 -05:00
|
|
|
|
|
|
|
/* Customer Invoices */
|
|
|
|
Account * gncEntryGetInvAccount (GncEntry *entry);
|
|
|
|
gnc_numeric gncEntryGetInvPrice (GncEntry *entry);
|
|
|
|
gnc_numeric gncEntryGetInvDiscount (GncEntry *entry);
|
|
|
|
GncAmountType gncEntryGetInvDiscountType (GncEntry *entry);
|
|
|
|
GncDiscountHow gncEntryGetInvDiscountHow (GncEntry *entry);
|
|
|
|
gboolean gncEntryGetInvTaxable (GncEntry *entry);
|
|
|
|
gboolean gncEntryGetInvTaxIncluded (GncEntry *entry);
|
|
|
|
GncTaxTable * gncEntryGetInvTaxTable (GncEntry *entry);
|
|
|
|
|
|
|
|
/* Vendor Bills (and Employee Expenses) */
|
|
|
|
Account * gncEntryGetBillAccount (GncEntry *entry);
|
|
|
|
gnc_numeric gncEntryGetBillPrice (GncEntry *entry);
|
|
|
|
gboolean gncEntryGetBillTaxable (GncEntry *entry);
|
|
|
|
gboolean gncEntryGetBillTaxIncluded (GncEntry *entry);
|
|
|
|
GncTaxTable * gncEntryGetBillTaxTable (GncEntry *entry);
|
2002-07-10 12:32:59 -05:00
|
|
|
gboolean gncEntryGetBillable (GncEntry *entry);
|
|
|
|
GncOwner *gncEntryGetBillTo (GncEntry *entry);
|
2001-11-23 23:35:08 -06:00
|
|
|
|
2003-03-02 22:58:55 -06:00
|
|
|
GncEntryPaymentType gncEntryGetBillPayment (GncEntry* entry);
|
2002-09-14 00:32:37 -05:00
|
|
|
|
2002-05-18 15:10:27 -05:00
|
|
|
void gncEntryCopy (const GncEntry *src, GncEntry *dest);
|
|
|
|
|
2002-06-16 00:11:33 -05:00
|
|
|
/* The first three return the rounded values -- the last returns the
|
|
|
|
* list of unrounded account-values. The list belongs to the entry
|
|
|
|
* and will be destroyed, so use it quickly.
|
|
|
|
*/
|
2002-09-14 00:32:37 -05:00
|
|
|
gnc_numeric gncEntryReturnValue (GncEntry *entry, gboolean is_inv);
|
|
|
|
gnc_numeric gncEntryReturnDiscountValue (GncEntry *entry, gboolean is_inv);
|
|
|
|
gnc_numeric gncEntryReturnTaxValue (GncEntry *entry, gboolean is_inv);
|
|
|
|
GList * gncEntryReturnTaxValues (GncEntry *entry, gboolean is_inv);
|
2002-06-16 00:11:33 -05:00
|
|
|
|
|
|
|
/* Compute the Entry value, tax-value, and discount_value, based on
|
|
|
|
* the quantity, price, discount, tax-table, and types. The value is
|
|
|
|
* the amount the merchant gets, the taxes are what the gov't gets,
|
|
|
|
* and the discount is how much the customer saved.
|
|
|
|
*
|
|
|
|
* The tax_values list is the property of the entry and will be
|
|
|
|
* destroyed automatically, so use it quickly. Note that all return
|
|
|
|
* values from these two functions are NOT rounded.
|
2002-01-12 22:25:55 -06:00
|
|
|
*/
|
2002-09-14 00:32:37 -05:00
|
|
|
void gncEntryGetValue (GncEntry *entry, gboolean is_inv, gnc_numeric *value,
|
2002-06-16 00:11:33 -05:00
|
|
|
gnc_numeric *discount, gnc_numeric *tax_value,
|
|
|
|
GList **tax_values);
|
2002-09-14 00:32:37 -05:00
|
|
|
|
2002-01-20 20:27:02 -06:00
|
|
|
void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price,
|
2002-06-16 00:11:33 -05:00
|
|
|
GncTaxTable *tax_table, gboolean tax_included,
|
|
|
|
gnc_numeric discount, GncAmountType discount_type,
|
|
|
|
GncDiscountHow discount_how,
|
|
|
|
/* return values */
|
|
|
|
gnc_numeric *value, gnc_numeric *discount_value,
|
|
|
|
GList **tax_values);
|
2001-11-21 19:23:07 -06:00
|
|
|
|
|
|
|
GncOrder * gncEntryGetOrder (GncEntry *entry);
|
|
|
|
GncInvoice * gncEntryGetInvoice (GncEntry *entry);
|
2002-07-09 23:12:19 -05:00
|
|
|
GncInvoice * gncEntryGetBill (GncEntry *entry);
|
2001-11-21 19:23:07 -06:00
|
|
|
|
2003-06-26 22:05:25 -05:00
|
|
|
GncEntry * gncEntryLookup (QofBook *book, const GUID *guid);
|
2001-11-21 19:23:07 -06:00
|
|
|
|
2002-11-03 14:21:42 -06:00
|
|
|
gboolean gncEntryIsOpen (GncEntry *entry);
|
|
|
|
void gncEntryBeginEdit (GncEntry *entry);
|
2001-11-21 19:23:07 -06:00
|
|
|
void gncEntryCommitEdit (GncEntry *entry);
|
2002-02-03 14:01:08 -06:00
|
|
|
int gncEntryCompare (GncEntry *a, GncEntry *b);
|
|
|
|
|
|
|
|
#define ENTRY_DATE "date"
|
2002-07-02 17:08:00 -05:00
|
|
|
#define ENTRY_DATE_ENTERED "date-entered"
|
2002-02-03 14:01:08 -06:00
|
|
|
#define ENTRY_DESC "desc"
|
|
|
|
#define ENTRY_ACTION "action"
|
2002-06-16 23:04:05 -05:00
|
|
|
#define ENTRY_NOTES "notes"
|
2002-02-03 14:01:08 -06:00
|
|
|
#define ENTRY_QTY "qty"
|
2002-09-14 00:32:37 -05:00
|
|
|
|
|
|
|
#define ENTRY_IPRICE "iprice"
|
|
|
|
#define ENTRY_BPRICE "bprice"
|
2002-07-10 12:32:59 -05:00
|
|
|
#define ENTRY_BILLABLE "billable?"
|
|
|
|
#define ENTRY_BILLTO "bill-to"
|
2001-11-21 19:23:07 -06:00
|
|
|
|
2002-02-03 19:55:33 -06:00
|
|
|
#define ENTRY_ORDER "order"
|
|
|
|
#define ENTRY_INVOICE "invoice"
|
2002-07-09 23:12:19 -05:00
|
|
|
#define ENTRY_BILL "bill"
|
2002-02-03 19:55:33 -06:00
|
|
|
|
2003-10-14 16:20:55 -05:00
|
|
|
/* deprecated functions, should be removed */
|
|
|
|
#define gncEntryGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x))
|
|
|
|
|
2001-11-21 19:23:07 -06:00
|
|
|
#endif /* GNC_ENTRY_H_ */
|