TaxTable
[Business]


Files

file  gncTaxTable.h
 Tax Table programming interface.

Data Structures

struct  _gncAccountValue
struct  GncTaxTable
struct  GncTaxTableEntry

Get Functions

#define gncTaxTableLookup(book, guid)   QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_TAXTABLE, GncTaxTable)
#define gncTaxTableGetChild(t)   gncTaxTableReturnChild((t),FALSE)
GncTaxTablegncTaxTableLookupByName (QofBook *book, const char *name)
GList * gncTaxTableGetTables (QofBook *book)
const char * gncTaxTableGetName (GncTaxTable *table)
GncTaxTablegncTaxTableGetParent (GncTaxTable *table)
GncTaxTablegncTaxTableReturnChild (GncTaxTable *table, gboolean make_new)
GList * gncTaxTableGetEntries (GncTaxTable *table)
gint64 gncTaxTableGetRefcount (GncTaxTable *table)
Timespec gncTaxTableLastModified (GncTaxTable *table)
AccountgncTaxTableEntryGetAccount (GncTaxTableEntry *entry)
GncAmountType gncTaxTableEntryGetType (GncTaxTableEntry *entry)
gnc_numeric gncTaxTableEntryGetAmount (GncTaxTableEntry *entry)

Create/Destroy Functions

GncTaxTablegncTaxTableCreate (QofBook *book)
void gncTaxTableDestroy (GncTaxTable *table)
GncTaxTableEntrygncTaxTableEntryCreate (void)
void gncTaxTableEntryDestroy (GncTaxTableEntry *entry)

Set Functions

void gncTaxTableSetName (GncTaxTable *table, const char *name)
void gncTaxTableIncRef (GncTaxTable *table)
void gncTaxTableDecRef (GncTaxTable *table)
void gncTaxTableEntrySetAccount (GncTaxTableEntry *entry, Account *account)
void gncTaxTableEntrySetType (GncTaxTableEntry *entry, GncAmountType type)
void gncTaxTableEntrySetAmount (GncTaxTableEntry *entry, gnc_numeric amount)

Defines

#define GNC_ID_TAXTABLE   "gncTaxTable"
#define GNC_IS_TAXTABLE(obj)   (QOF_CHECK_TYPE((obj), GNC_ID_TAXTABLE))
#define GNC_TAXTABLE(obj)   (QOF_CHECK_CAST((obj), GNC_ID_TAXTABLE, GncTaxTable))
#define GNC_TT_NAME   "tax table name"
#define GNC_TT_REFCOUNT   "reference count"
#define gncTaxTableGetGUID(x)   qof_instance_get_guid(QOF_INSTANCE(x))
#define gncTaxTableRetGUID(x)   (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null()))
#define gncTaxTableLookupDirect(G, B)   gncTaxTableLookup((B), &(G))

Typedefs

typedef _gncTaxTable GncTaxTable
typedef _gncTaxTableEntry GncTaxTableEntry
typedef _gncAccountValue GncAccountValue

Enumerations

enum  GncAmountType { GNC_AMT_TYPE_VALUE = 1, GNC_AMT_TYPE_PERCENT }
enum  GncTaxIncluded { GNC_TAXINCLUDED_YES = 1, GNC_TAXINCLUDED_NO, GNC_TAXINCLUDED_USEGLOBAL }

Functions

const char * gncAmountTypeToString (GncAmountType type)
gboolean gncAmountStringToType (const char *str, GncAmountType *type)
const char * gncTaxIncludedTypeToString (GncTaxIncluded type)
gboolean gncTaxIncludedStringToType (const char *str, GncTaxIncluded *type)
void gncTaxTableAddEntry (GncTaxTable *table, GncTaxTableEntry *entry)
void gncTaxTableRemoveEntry (GncTaxTable *table, GncTaxTableEntry *entry)
void gncTaxTableChanged (GncTaxTable *table)
void gncTaxTableBeginEdit (GncTaxTable *table)
void gncTaxTableCommitEdit (GncTaxTable *table)
int gncTaxTableCompare (GncTaxTable *a, GncTaxTable *b)
int gncTaxTableEntryCompare (GncTaxTableEntry *a, GncTaxTableEntry *b)
GList * gncAccountValueAdd (GList *list, Account *acc, gnc_numeric value)
GList * gncAccountValueAddList (GList *l1, GList *l2)
gnc_numeric gncAccountValueTotal (GList *list)
void gncAccountValueDestroy (GList *list)


Define Documentation

#define GNC_TT_NAME   "tax table name"
 

QOF parameter definitions

Definition at line 182 of file gncTaxTable.h.

#define gncTaxTableGetGUID  )     qof_instance_get_guid(QOF_INSTANCE(x))
 

Deprecated:
routine

Definition at line 186 of file gncTaxTable.h.

#define gncTaxTableLookup book,
guid   )     QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_TAXTABLE, GncTaxTable)
 

Return a pointer to the instance gncTaxTable that is identified by the guid, and is residing in the book. Returns NULL if the instance can't be found. Equivalent function prototype is GncTaxTable * gncTaxTableLookup (QofBook *book, const GUID *guid);

Definition at line 136 of file gncTaxTable.h.


Enumeration Type Documentation

enum GncAmountType
 

How to interpret the amount. You can interpret it as a VALUE or a PERCENT.

Enumerator:
GNC_AMT_TYPE_VALUE  tax is a number
GNC_AMT_TYPE_PERCENT  tax is a percentage

Definition at line 84 of file gncTaxTable.h.

00084              {
00085   GNC_AMT_TYPE_VALUE = 1,       
00086   GNC_AMT_TYPE_PERCENT          
00087 } GncAmountType;

enum GncTaxIncluded
 

How to interpret the TaxIncluded

Enumerator:
GNC_TAXINCLUDED_YES  tax is included
GNC_TAXINCLUDED_NO  tax is not included
GNC_TAXINCLUDED_USEGLOBAL  use the global setting

Definition at line 90 of file gncTaxTable.h.


Function Documentation

GList* gncAccountValueAdd GList *  list,
Account acc,
gnc_numeric  value
 

This will add value to the account-value for acc, creating a new list object if necessary

Definition at line 712 of file gncTaxTable.c.

00713 {
00714   GList *li;
00715   GncAccountValue *res = NULL;
00716 
00717   g_return_val_if_fail (acc, list);
00718   g_return_val_if_fail (gnc_numeric_check (value) == GNC_ERROR_OK, list);
00719 
00720   /* Try to find the account in the list */
00721   for (li = list; li; li = li->next) {
00722     res = li->data;
00723     if (res->account == acc) {
00724       res->value = gnc_numeric_add (res->value, value, GNC_DENOM_AUTO,
00725                                     GNC_DENOM_LCD);
00726       return list;
00727     }
00728   }
00729   /* Nope, didn't find it. */
00730 
00731   res = g_new0 (GncAccountValue, 1);
00732   res->account = acc;
00733   res->value = value;
00734   return g_list_prepend (list, res);
00735 }

GList* gncAccountValueAddList GList *  l1,
GList *  l2
 

Merge l2 into l1. l2 is not touched.

Definition at line 738 of file gncTaxTable.c.

00739 {
00740   GList *li;
00741 
00742   for (li = l2; li; li = li->next ) {
00743     GncAccountValue *val = li->data;
00744     l1 = gncAccountValueAdd (l1, val->account, val->value);
00745   }
00746 
00747   return l1;
00748 }

void gncAccountValueDestroy GList *  list  ) 
 

Destroy a list of accountvalues

Definition at line 763 of file gncTaxTable.c.

00764 {
00765   GList *node;
00766   for ( node = list; node ; node = node->next)
00767     g_free (node->data);
00768 
00769   g_list_free (list);
00770 }

gnc_numeric gncAccountValueTotal GList *  list  ) 
 

return the total for this list

Definition at line 751 of file gncTaxTable.c.

00752 {
00753   gnc_numeric total = gnc_numeric_zero ();
00754 
00755   for ( ; list ; list = list->next) {
00756     GncAccountValue *val = list->data;
00757     total = gnc_numeric_add (total, val->value, GNC_DENOM_AUTO, GNC_DENOM_LCD);
00758   }
00759   return total;
00760 }


Generated on Sun Sep 4 18:09:07 2005 for GnuCash by  doxygen 1.4.3-20050530