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"
|
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
|
|
|
/* How to interpret the Discount and Tax numbers.. You can interpret
|
|
|
|
* the as a VALUE or a PERCENT. Similarly, you can set the PRETAX
|
|
|
|
* bit if you want the discount to be applied before a percentage-tax.
|
|
|
|
*/
|
|
|
|
#define GNC_ENTRY_INTERP_VALUE 0x00
|
|
|
|
#define GNC_ENTRY_INTERP_PERCENT 0x01
|
2001-11-26 17:30:33 -06:00
|
|
|
#define GNC_ENTRY_PRETAX_FLAG 0x02
|
2001-11-23 23:35:08 -06:00
|
|
|
|
|
|
|
#define GNC_ENTRY_INTERP_IS_VALUE(x) (((x)&0x01) == GNC_ENTRY_INTERP_VALUE)
|
|
|
|
#define GNC_ENTRY_INTERP_IS_PERCENT(x) (((x)&0x01) == GNC_ENTRY_INTERP_PERCENT)
|
|
|
|
|
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);
|
|
|
|
void gncEntrySetQuantity (GncEntry *entry, gnc_numeric quantity);
|
|
|
|
void gncEntrySetPrice (GncEntry *entry, gnc_numeric price);
|
|
|
|
void gncEntrySetTax (GncEntry *entry, gnc_numeric tax);
|
2001-11-23 23:35:08 -06:00
|
|
|
void gncEntrySetTaxType (GncEntry *entry, gint type);
|
2001-11-21 19:23:07 -06:00
|
|
|
void gncEntrySetDiscount (GncEntry *entry, gnc_numeric discount);
|
2001-11-23 23:35:08 -06:00
|
|
|
void gncEntrySetDiscountType (GncEntry *entry, gint type);
|
2001-11-21 19:23:07 -06:00
|
|
|
|
|
|
|
void gncEntrySetAccount (GncEntry *entry, Account *acc);
|
|
|
|
void gncEntrySetTaxAccount (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);
|
|
|
|
gnc_numeric gncEntryGetQuantity (GncEntry *entry);
|
|
|
|
gnc_numeric gncEntryGetPrice (GncEntry *entry);
|
|
|
|
gnc_numeric gncEntryGetTax (GncEntry *entry);
|
2001-11-23 23:35:08 -06:00
|
|
|
gint gncEntryGetTaxType (GncEntry *entry);
|
2001-11-26 17:30:33 -06:00
|
|
|
const char * gncEntryGetTaxTypeStr (gint type);
|
2001-11-21 19:23:07 -06:00
|
|
|
gnc_numeric gncEntryGetDiscount (GncEntry *entry);
|
2001-11-23 23:35:08 -06:00
|
|
|
gint gncEntryGetDiscountType (GncEntry *entry);
|
2001-11-26 17:30:33 -06:00
|
|
|
const char * gncEntryGetDiscountTypeStr (gint type);
|
2001-11-23 23:35:08 -06:00
|
|
|
|
2002-05-18 15:10:27 -05:00
|
|
|
void gncEntryCopy (const GncEntry *src, GncEntry *dest);
|
|
|
|
|
2002-02-24 23:02:21 -06:00
|
|
|
gnc_numeric gncEntryReturnValue (GncEntry *entry);
|
|
|
|
gnc_numeric gncEntryReturnTaxValue (GncEntry *entry);
|
|
|
|
|
2002-01-12 22:25:55 -06:00
|
|
|
/* Compute the Entry value and tax-value numbers, based on the
|
|
|
|
* quantity, price, discount, tax, and discount/tax types
|
|
|
|
*/
|
|
|
|
void gncEntryGetValue (GncEntry *entry, gnc_numeric *value,
|
|
|
|
gnc_numeric *tax_value);
|
2002-01-20 20:27:02 -06:00
|
|
|
void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price,
|
|
|
|
gnc_numeric tax, gint tax_type,
|
|
|
|
gnc_numeric discount, gint discount_type,
|
|
|
|
gnc_numeric *value, gnc_numeric *tax_value);
|
2002-01-12 22:25:55 -06:00
|
|
|
|
2001-11-26 17:30:33 -06:00
|
|
|
gint gncEntryGetTypeFromStr (const char *type);
|
2001-11-21 19:23:07 -06:00
|
|
|
|
|
|
|
Account * gncEntryGetAccount (GncEntry *entry);
|
|
|
|
Account * gncEntryGetTaxAccount (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"
|
|
|
|
#define ENTRY_DESC "desc"
|
|
|
|
#define ENTRY_ACTION "action"
|
|
|
|
#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_ */
|