2001-11-21 19:23:07 -06:00
|
|
|
/*
|
|
|
|
* gncEntry.h -- the Core Business Entry Interface
|
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;
|
|
|
|
|
|
|
|
#include "date.h"
|
2001-11-24 23:34:34 -06:00
|
|
|
#include "gnc-book.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"
|
|
|
|
|
|
|
|
#define GNC_ENTRY_MODULE_NAME "gncEntry"
|
|
|
|
|
2001-11-23 23:35:08 -06:00
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
GNC_DISC_PRETAX = 1,
|
|
|
|
GNC_DISC_SAMETIME,
|
|
|
|
GNC_DISC_POSTTAX
|
|
|
|
} GncDiscountHow;
|
2001-11-23 23:35:08 -06:00
|
|
|
|
2002-07-01 13:31:48 -05:00
|
|
|
const char * gncEntryDiscountHowToString (GncDiscountHow how);
|
|
|
|
gboolean gncEntryDiscountStringToHow (const char *str, GncDiscountHow *how);
|
|
|
|
|
2001-11-21 19:23:07 -06:00
|
|
|
/* Create/Destroy Functions */
|
|
|
|
|
2001-11-24 23:34:34 -06:00
|
|
|
GncEntry *gncEntryCreate (GNCBook *book);
|
2001-11-21 19:23:07 -06:00
|
|
|
void gncEntryDestroy (GncEntry *entry);
|
|
|
|
|
|
|
|
/* Set Functions */
|
|
|
|
|
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);
|
|
|
|
void gncEntrySetPrice (GncEntry *entry, gnc_numeric price);
|
|
|
|
void gncEntrySetDiscount (GncEntry *entry, gnc_numeric discount);
|
2002-06-16 00:11:33 -05:00
|
|
|
void gncEntrySetDiscountType (GncEntry *entry, GncAmountType type);
|
|
|
|
void gncEntrySetDiscountHow (GncEntry *entry, GncDiscountHow how);
|
|
|
|
void gncEntrySetTaxable (GncEntry *entry, gboolean taxable);
|
|
|
|
void gncEntrySetTaxIncluded (GncEntry *entry, gboolean tax_included);
|
|
|
|
void gncEntrySetTaxTable (GncEntry *entry, GncTaxTable *table);
|
2001-11-21 19:23:07 -06:00
|
|
|
|
|
|
|
void gncEntrySetAccount (GncEntry *entry, Account *acc);
|
|
|
|
|
|
|
|
/* Get Functions */
|
|
|
|
|
2001-11-24 23:34:34 -06:00
|
|
|
GNCBook * gncEntryGetBook (GncEntry *entry);
|
2001-11-21 19:23:07 -06:00
|
|
|
const GUID * gncEntryGetGUID (GncEntry *entry);
|
|
|
|
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);
|
|
|
|
gnc_numeric gncEntryGetPrice (GncEntry *entry);
|
|
|
|
gnc_numeric gncEntryGetDiscount (GncEntry *entry);
|
2002-06-16 00:11:33 -05:00
|
|
|
GncAmountType gncEntryGetDiscountType (GncEntry *entry);
|
|
|
|
GncDiscountHow gncEntryGetDiscountHow (GncEntry *entry);
|
|
|
|
gboolean gncEntryGetTaxable (GncEntry *entry);
|
|
|
|
gboolean gncEntryGetTaxIncluded (GncEntry *entry);
|
|
|
|
GncTaxTable * gncEntryGetTaxTable (GncEntry *entry);
|
2001-11-23 23:35:08 -06: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-02-24 23:02:21 -06:00
|
|
|
gnc_numeric gncEntryReturnValue (GncEntry *entry);
|
2002-05-24 16:19:45 -05:00
|
|
|
gnc_numeric gncEntryReturnDiscountValue (GncEntry *entry);
|
2002-06-16 00:11:33 -05:00
|
|
|
gnc_numeric gncEntryReturnTaxValue (GncEntry *entry);
|
|
|
|
GList * gncEntryReturnTaxValues (GncEntry *entry);
|
|
|
|
|
|
|
|
/* 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
|
|
|
*/
|
|
|
|
void gncEntryGetValue (GncEntry *entry, gnc_numeric *value,
|
2002-06-16 00:11:33 -05:00
|
|
|
gnc_numeric *discount, gnc_numeric *tax_value,
|
|
|
|
GList **tax_values);
|
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
|
|
|
|
|
|
|
Account * gncEntryGetAccount (GncEntry *entry);
|
|
|
|
|
|
|
|
GncOrder * gncEntryGetOrder (GncEntry *entry);
|
|
|
|
GncInvoice * gncEntryGetInvoice (GncEntry *entry);
|
|
|
|
|
2001-11-24 23:34:34 -06:00
|
|
|
GncEntry * gncEntryLookup (GNCBook *book, const GUID *guid);
|
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"
|
|
|
|
#define ENTRY_PRICE "price"
|
2001-11-21 19:23:07 -06:00
|
|
|
|
2002-02-03 19:55:33 -06:00
|
|
|
#define ENTRY_ORDER "order"
|
|
|
|
#define ENTRY_INVOICE "invoice"
|
|
|
|
|
2001-11-21 19:23:07 -06:00
|
|
|
#endif /* GNC_ENTRY_H_ */
|