GnuCash Engine: Core, Non-GUI Accounting Functions


Modules

 Business
 Account
 Cap Gains
 Commodities
 Lots: Core Function for AR/AP, Inventory, Stock Lots, Cap Gains
 Price Database
 Prices
 Accounting Periods
 Accounting Policy (FIFO/LIFO)
 Scheduled/Periodic/Recurring Transactions
 Data Validation
 Financial Transactions
 Transaction Logging

Files

file  gnc-engine.h
 All type declarations for the whole Gnucash engine.

Defines

#define ACCOUNT_MATCH_ALL_TYPE   "account-match-all"
#define GNC_ID_NONE   QOF_ID_NONE
 IDENTIFIERS GUID Identifiers can be used to reference Accounts, Transactions, Splits and other objects. These Gnucash types are referred to as Gnucash entities. GUID Identifiers are globally-unique and permanent, i.e., once an entity has been assigned an identifier, it retains that same identifier for its lifetime.
  • Identifiers are 'typed' with strings. The ids used in gnucash are defined below. An id with type GNC_ID_NONE does not refer to any entity, although that may change as new ids are created. An id with type GNC_ID_NULL does not refer to any entity, and will never refer to any entity. An identifier with any other type may refer to an actual entity, but that is not guaranteed. If an id does refer to an entity, the type of the entity will match the type of the identifier.

#define GNC_ID_BOOK   QOF_ID_BOOK
#define GNC_ID_SESSION   QOF_ID_SESSION
#define GNC_ID_NULL   QOF_ID_NULL
#define GNC_ID_ACCOUNT   "Account"
#define GNC_ID_COMMODITY   "Commodity"
#define GNC_ID_COMMODITY_NAMESPACE   "CommodityNamespace"
#define GNC_ID_COMMODITY_TABLE   "CommodityTable"
#define GNC_ID_LOT   "Lot"
#define GNC_ID_PERIOD   "Period"
#define GNC_ID_PRICE   "Price"
#define GNC_ID_PRICEDB   "PriceDB"
#define GNC_ID_SPLIT   "Split"
#define GNC_ID_BUDGET   "Budget"
#define GNC_ID_SCHEDXACTION   "SchedXaction"
#define GNC_ID_SXES   "SchedXactions"
#define GNC_ID_SXTG   "SXTGroup"
#define GNC_ID_SXTT   "SXTTrans"
#define GNC_ID_TRANS   "Trans"

Typedefs

typedef struct account_s Account
 Account in Gnucash. This is the typename for an account. The actual structure is defined in the private header AccountP.h, but no one outside the engine should include that file. Instead, access that data only through the functions in Account.h .
typedef struct split_s Split
 Split in Gnucash. A "split" is more commonly refered to as a "entry" in a "transaction". Each split belongs to one Account and one Transaction. The split is one out of several parts a Transaction is divided into.
typedef struct transaction_s Transaction
 Transaction in Gnucash. A Transaction is a piece of business done; the transfer of money from one account to one or more other accounts. Each Transaction is divided into one or more Splits (usually two).
typedef struct gnc_commodity_s gnc_commodity
 An article that is bought and sold. A Commodity is the most general term of what an account keeps track of. Usually this is a monetary currency, but it can also be a stock share or even a precious metal. Every account keeps track of exactly one gnc_commodity.
typedef struct
gnc_commodity_namespace_s 
gnc_commodity_namespace
 A gnc_commodity_namespace is an collection of commodities.
typedef struct
gnc_commodity_table_s 
gnc_commodity_table
 A gnc_commodity_table is a database of commodity info.
typedef struct gnc_lot_s GNCLot
 Identifies that something sold at one time was bought at another. A GNCLot provides a way of tracking physical items as they are bought and sold in different transactions. By identifying the individual, underlying physical objects, it provides the needed framework for implementing depreciation, capital gains, inventory control and invoices.
typedef struct gnc_price_s GNCPrice
 Price of commodity on a given date. A GNCPrice encapsulates price information: the cost of a commodity expressed as a currency, on a given date. It also holds info about the provenance of the price: where it came from, its general validity.
typedef struct gnc_quote_source_s gnc_quote_source
typedef GList AccountList
typedef GList LotList
typedef GList SplitList
typedef GList TransList
typedef GList AccountGUIDList
typedef GList BookGUIDList
typedef void(* EngineCommitErrorCallback )(gpointer data, QofBackendError errcode)
typedef gint(* SplitCallback )(Split *s, gpointer data)
typedef gint(* TransactionCallback )(Transaction *t, void *data)
typedef void(* gnc_engine_init_hook_t )(int, char **)

Enumerations

enum  GNCPlaceholderType { PLACEHOLDER_NONE, PLACEHOLDER_THIS, PLACEHOLDER_CHILD }

Functions

unsigned int gnucash_major_version (void)
unsigned int gnucash_minor_version (void)
unsigned int gnucash_micro_version (void)
void gnc_engine_init (int argc, char **argv)
void gnc_engine_init_static (int argc, char **argv)
void gnc_engine_shutdown (void)
gboolean gnc_engine_is_initialized (void)
void gnc_log_default (void)
void gnc_engine_add_init_hook (gnc_engine_init_hook_t hook)
void gnc_engine_add_commit_error_callback (EngineCommitErrorCallback cb, gpointer data)
void gnc_engine_signal_commit_error (QofBackendError errcode)

Detailed Description

The GnuCash Engine provides a set of objects and classes that encapsulate typical financial accounting concepts. The GnuCash GUI is expected to manipulate these objects through the provided engine API.

Define Documentation

#define ACCOUNT_MATCH_ALL_TYPE   "account-match-all"

This is the type-override when you want to match all accounts. Used in the gnome-search parameter list. Be careful when you use this.

Definition at line 1439 of file Account.h.

#define xaccAccountInsertSplit ( acc,
 )     xaccSplitSetAccount((s), (acc))

The xaccAccountInsertSplit() method will insert the indicated split into the indicated account. If the split already belongs to another account, it will be removed from that account first.

Definition at line 980 of file Account.h.


Typedef Documentation

typedef GList AccountGUIDList

GList of GUIDs of a Account

Definition at line 207 of file gnc-engine.h.

typedef GList AccountList

GList of Account

Definition at line 199 of file gnc-engine.h.

typedef GList BookGUIDList

GList of GUIDs of a QofBook

Definition at line 209 of file gnc-engine.h.

typedef struct gnc_commodity_s gnc_commodity

An article that is bought and sold. A Commodity is the most general term of what an account keeps track of. Usually this is a monetary currency, but it can also be a stock share or even a precious metal. Every account keeps track of exactly one gnc_commodity.

(Up to version 1.6.x, we used to have currencies and securities. Now these concepts have been merged into this gnc_commodity. See the comments at xaccAccountSetCommodity() for more about that.)

This is the typename for a gnc_commodity. The actual structure is defined in a private source file. For accessing that data, only use the functions in gnc-commodity.h .

Definition at line 171 of file gnc-engine.h.

typedef void(* gnc_engine_init_hook_t)(int, char **)

Function type for init hooks in the engine.

Definition at line 217 of file gnc-engine.h.

typedef struct gnc_lot_s GNCLot

Identifies that something sold at one time was bought at another. A GNCLot provides a way of tracking physical items as they are bought and sold in different transactions. By identifying the individual, underlying physical objects, it provides the needed framework for implementing depreciation, capital gains, inventory control and invoices.

See the file src/doc/lots.txt for implmentation overview.

Definition at line 188 of file gnc-engine.h.

typedef GList LotList

GList of GNCLots

Definition at line 201 of file gnc-engine.h.

typedef struct split_s Split

Split in Gnucash. A "split" is more commonly refered to as a "entry" in a "transaction". Each split belongs to one Account and one Transaction. The split is one out of several parts a Transaction is divided into.

This is the typename for a split. The actual structure is defined in the private header TransactionP.h, but no one outside the engine should include that file. Instead, access that data only through the functions in Transaction.h .

Definition at line 144 of file gnc-engine.h.

typedef GList SplitList

GList of Split

Definition at line 203 of file gnc-engine.h.

typedef struct transaction_s Transaction

Transaction in Gnucash. A Transaction is a piece of business done; the transfer of money from one account to one or more other accounts. Each Transaction is divided into one or more Splits (usually two).

This is the typename for a transaction. The actual structure is defined in the private header TransactionP.h, but no one outside the engine should include that file. Instead, access that data only through the functions in Transaction.h .

Definition at line 155 of file gnc-engine.h.

typedef GList TransList

GList of Transaction

Definition at line 205 of file gnc-engine.h.


Enumeration Type Documentation

DOCUMENT ME!

Definition at line 1123 of file Account.h.

01124 {
01125     PLACEHOLDER_NONE,
01126     PLACEHOLDER_THIS,
01127     PLACEHOLDER_CHILD,
01128 } GNCPlaceholderType;


Function Documentation

gnc_commodity* DxaccAccountGetCurrency ( const Account account  ) 

Deprecated:
The current API associates only one thing with an account: the 'commodity'. Use xaccAccountGetCommodity() to fetch it.

Definition at line 2928 of file Account.c.

02929 {
02930     KvpValue *v;
02931     const char *s;
02932     gnc_commodity_table *table;
02933 
02934     if (!acc) return NULL;
02935 
02936     v = kvp_frame_get_slot(acc->inst.kvp_data, "old-currency");
02937     if (!v) return NULL;
02938 
02939     s = kvp_value_get_string (v);
02940     if (!s) return NULL;
02941 
02942     table = gnc_commodity_table_get_table (qof_instance_get_book(acc));
02943 
02944     return gnc_commodity_table_lookup_unique (table, s);
02945 }

const char* dxaccAccountGetQuoteTZ ( const Account account  ) 

Get the timezone to be used when interpreting the results from a given Finance::Quote backend. Unfortunately, the upstream sources don't label their output, so the user has to specify this bit.

Deprecated:
Price quote information is now stored on the commodity, not the account.

Definition at line 4308 of file Account.c.

04309 {
04310     if (!acc) return NULL;
04311 
04312     if (xaccAccountIsPriced(acc))
04313     {
04314         KvpValue *value = kvp_frame_get_slot(acc->inst.kvp_data, "old-quote-tz");
04315         if (value) return (kvp_value_get_string(value));
04316     }
04317     return NULL;
04318 }

void DxaccAccountSetCurrency ( Account account,
gnc_commodity currency 
)

Deprecated:
The current API associates only one thing with an account: the 'commodity'. Use xaccAccountGetCommodity() to fetch it.
These two funcs take control of their gnc_commodity args. Don't free

Definition at line 2289 of file Account.c.

02290 {
02291     QofBook *book;
02292     const char *string;
02293     gnc_commodity *commodity;
02294 
02295     if ((!acc) || (!currency)) return;
02296 
02297     xaccAccountBeginEdit(acc);
02298     string = gnc_commodity_get_unique_name (currency);
02299     kvp_frame_set_slot_nc(acc->inst.kvp_data, "old-currency",
02300                           kvp_value_new_string(string));
02301     mark_account (acc);
02302     xaccAccountCommitEdit(acc);
02303 
02304     commodity = DxaccAccountGetCurrency (acc);
02305     if (!commodity)
02306     {
02307         book = qof_instance_get_book(acc);
02308         gnc_commodity_table_insert (gnc_commodity_table_get_table (book), currency);
02309     }
02310 }

void dxaccAccountSetQuoteTZ ( Account account,
const char *  tz 
)

Set the timezone to be used when interpreting the results from a given Finance::Quote backend. Unfortunately, the upstream sources don't label their output, so the user has to specify this bit.

Deprecated:
Price quote information is now stored on the commodity, not the account.

Definition at line 4288 of file Account.c.

04289 {
04290     if (!acc) return;
04291 
04292     xaccAccountBeginEdit(acc);
04293     if (xaccAccountIsPriced(acc))
04294     {
04295         kvp_frame_set_slot_nc(acc->inst.kvp_data,
04296                               "old-quote-tz",
04297                               tz ? kvp_value_new_string(tz) : NULL);
04298         mark_account (acc);
04299     }
04300     qof_instance_set_dirty(&acc->inst);
04301     xaccAccountCommitEdit(acc);
04302 }

Account* gnc_account_lookup_by_code ( const Account parent,
const char *  code 
)

The gnc_account_lookup_full_name() subroutine works like gnc_account_lookup_by_name, but uses the account code.

Definition at line 2627 of file Account.c.

02628 {
02629     AccountPrivate *cpriv, *ppriv;
02630     Account *child, *result;
02631     GList *node;
02632 
02633     g_return_val_if_fail(GNC_IS_ACCOUNT(parent), NULL);
02634     g_return_val_if_fail(code, NULL);
02635 
02636     /* first, look for accounts hanging off the current node */
02637     ppriv = GET_PRIVATE(parent);
02638     for (node = ppriv->children; node; node = node->next)
02639     {
02640         child = node->data;
02641         cpriv = GET_PRIVATE(child);
02642         if (safe_strcmp(cpriv->accountCode, code) == 0)
02643             return child;
02644     }
02645 
02646     /* if we are still here, then we haven't found the account yet.
02647      * Recursively search each of the child accounts next */
02648     for (node = ppriv->children; node; node = node->next)
02649     {
02650         child = node->data;
02651         result = gnc_account_lookup_by_code (child, code);
02652         if (result)
02653             return result;
02654     }
02655 
02656     return NULL;
02657 }

Account* gnc_account_lookup_by_full_name ( const Account any_account,
const gchar *  name 
)

The gnc_account_lookup_full_name() subroutine works like gnc_account_lookup_by_name, but uses fully-qualified names using the given separator.

Definition at line 2706 of file Account.c.

02708 {
02709     const AccountPrivate *rpriv;
02710     const Account *root;
02711     Account *found;
02712     gchar **names;
02713 
02714     g_return_val_if_fail(GNC_IS_ACCOUNT(any_acc), NULL);
02715     g_return_val_if_fail(name, NULL);
02716 
02717     root = any_acc;
02718     rpriv = GET_PRIVATE(root);
02719     while (rpriv->parent)
02720     {
02721         root = rpriv->parent;
02722         rpriv = GET_PRIVATE(root);
02723     }
02724     names = g_strsplit(name, gnc_get_account_separator_string(), -1);
02725     found = gnc_account_lookup_by_full_name_helper(root, names);
02726     g_strfreev(names);
02727     return found;
02728 }

Account* gnc_account_lookup_by_name ( const Account parent,
const char *  name 
)

The gnc_account_lookup_by_name() subroutine fetches the account by name from the descendants of the specified account. The immediate children are searched first. If there is no match,, then a recursive search of all descendants is performed looking for a match.

Returns:
A pointer to the account with the specified name, or NULL if the account was not found.

Definition at line 2594 of file Account.c.

02595 {
02596     AccountPrivate *cpriv, *ppriv;
02597     Account *child, *result;
02598     GList *node;
02599 
02600     g_return_val_if_fail(GNC_IS_ACCOUNT(parent), NULL);
02601     g_return_val_if_fail(name, NULL);
02602 
02603     /* first, look for accounts hanging off the current node */
02604     ppriv = GET_PRIVATE(parent);
02605     for (node = ppriv->children; node; node = node->next)
02606     {
02607         child = node->data;
02608         cpriv = GET_PRIVATE(child);
02609         if (safe_strcmp(cpriv->accountName, name) == 0)
02610             return child;
02611     }
02612 
02613     /* if we are still here, then we haven't found the account yet.
02614      * Recursively search each of the child accounts next */
02615     for (node = ppriv->children; node; node = node->next)
02616     {
02617         child = node->data;
02618         result = gnc_account_lookup_by_name (child, name);
02619         if (result)
02620             return result;
02621     }
02622 
02623     return NULL;
02624 }

void gnc_account_tree_begin_staged_transaction_traversals ( Account acc  ) 

gnc_account_tree_begin_staged_transaction_traversals() resets the traversal marker inside every transactions of every account in the account tree originating with the specified node. This is done so that a new sequence of staged traversals can begin.

Definition at line 4630 of file Account.c.

04631 {
04632     GList *descendants;
04633 
04634     descendants = gnc_account_get_descendants(account);
04635     g_list_foreach(descendants, (GFunc)do_one_account, NULL);
04636     g_list_free(descendants);
04637 }

int gnc_account_tree_staged_transaction_traversal ( const Account account,
unsigned int  stage,
TransactionCallback  thunk,
void *  data 
)

gnc_account_tree_staged_transaction_traversal() calls thunk on each transaction in the group whose current marker is less than the given stage and updates each transaction's marker to be stage. The traversal will stop if thunk returns a non-zero value. gnc_account_tree_staged_transaction_traversal() function will return zero or the non-zero value returned by thunk. This API does not handle handle recursive traversals.

Warning:
For performance reasons, the transaction callback thunk must never destroy any of the transaction's splits, nor assign any of them to a different account. To do so risks a crash.

Definition at line 4680 of file Account.c.

04684 {
04685     const AccountPrivate *priv;
04686     GList *acc_p, *split_p;
04687     Transaction *trans;
04688     Split *s;
04689     int retval;
04690 
04691     if (!acc) return 0;
04692 
04693     /* depth first traversal */
04694     priv = GET_PRIVATE(acc);
04695     for (acc_p = priv->children; acc_p; acc_p = g_list_next(acc_p))
04696     {
04697         retval = gnc_account_tree_staged_transaction_traversal(acc_p->data, stage,
04698                  thunk, cb_data);
04699         if (retval) return retval;
04700     }
04701 
04702     /* Now this account */
04703     for (split_p = priv->splits; split_p; split_p = g_list_next(split_p))
04704     {
04705         s = split_p->data;
04706         trans = s->parent;
04707         if (trans && (trans->marker < stage))
04708         {
04709             trans->marker = stage;
04710             if (thunk)
04711             {
04712                 retval = thunk(trans, cb_data);
04713                 if (retval) return retval;
04714             }
04715         }
04716     }
04717 
04718     return 0;
04719 }

void gnc_engine_add_commit_error_callback ( EngineCommitErrorCallback  cb,
gpointer  data 
)

Set a callback function to be called in case an engine commit fails

Definition at line 197 of file gnc-engine.c.

00198 {
00199     g_error_cb = cb;
00200     g_error_cb_data = data;
00201 }

void gnc_engine_add_init_hook ( gnc_engine_init_hook_t  hook  ) 

Pass a function pointer to gnc_engine_add_init_hook and it will be called during the evaluation of gnc_engine_init

Definition at line 173 of file gnc-engine.c.

00174 {
00175     engine_init_hooks = g_list_append(engine_init_hooks, (gpointer)h);
00176 }

void gnc_engine_init ( int  argc,
char **  argv 
)

gnc_engine_init should be called before gnc engine functions can be used - see also qof_init for a method that does not require Guile.

Definition at line 139 of file gnc-engine.c.

00140 {
00141     gnc_engine_init_part1();
00142     gnc_engine_init_part2();
00143     gnc_engine_init_part3(argc, argv);
00144 }

void gnc_engine_init_static ( int  argc,
char **  argv 
)

This is the statically linked-in version of gnc_engine_init. It is identically to that function except that it doesn't load the loadable shared module, which means this function will not load the "(gnucash engine)" scheme module.

Definition at line 147 of file gnc-engine.c.

00148 {
00149     gnc_engine_init_part1();
00150     gnc_engine_init_part3(argc, argv);
00151 }

gboolean gnc_engine_is_initialized ( void   ) 

check the engine is fully initialized

Definition at line 179 of file gnc-engine.c.

00180 {
00181     return (engine_is_initialized == 1) ? TRUE : FALSE;
00182 }

void gnc_engine_shutdown ( void   ) 

Called to shutdown the engine, see also qof_close for use without Guile.

Definition at line 160 of file gnc-engine.c.

00161 {
00162     qof_log_shutdown();
00163     qof_close();
00164     engine_is_initialized = 0;
00165 }

void gnc_log_default ( void   ) 

enable default log modules

Definition at line 189 of file gnc-engine.c.

00190 {
00191     qof_log_set_default(QOF_LOG_WARNING);
00192     qof_log_set_level(GNC_MOD_ROOT, QOF_LOG_WARNING);
00193     qof_log_set_level(GNC_MOD_TEST, QOF_LOG_DEBUG);
00194 }

unsigned int gnucash_major_version ( void   ) 

PROTOTYPES GnuCash version number infomation.

Definition at line 53 of file gnc-engine.c.

00054 {
00055     return GNUCASH_MAJOR_VERSION;
00056 }

unsigned int gnucash_micro_version ( void   ) 

GnuCash version number infomation.

Definition at line 65 of file gnc-engine.c.

00066 {
00067     return GNUCASH_MICRO_VERSION;
00068 }

unsigned int gnucash_minor_version ( void   ) 

GnuCash version number infomation.

Definition at line 59 of file gnc-engine.c.

00060 {
00061     return GNUCASH_MINOR_VERSION;
00062 }

void xaccAccountBeginStagedTransactionTraversals ( const Account account  ) 

xaccAccountBeginStagedTransactionTraversals() resets the traversal marker for each transaction which is a parent of one of the splits in the account.

Definition at line 4584 of file Account.c.

04585 {
04586     AccountPrivate *priv;
04587 
04588     if (!account)
04589         return;
04590     priv = GET_PRIVATE(account);
04591     xaccSplitsBeginStagedTransactionTraversals(priv->splits);
04592 }

void xaccAccountClearReconcilePostpone ( Account account  ) 

DOCUMENT ME!

Definition at line 4178 of file Account.c.

04179 {
04180     if (!acc) return;
04181 
04182     xaccAccountBeginEdit (acc);
04183     kvp_frame_set_value (acc->inst.kvp_data, "reconcile-info/postpone", NULL);
04184     mark_account (acc);
04185     xaccAccountCommitEdit (acc);
04186 }

LotList* xaccAccountFindOpenLots ( const Account acc,
gboolean(*)(GNCLot *lot, gpointer user_data)  match_func,
gpointer  user_data,
GCompareFunc  sort_func 
)

Find a list of open lots that match the match_func. Sort according to sort_func. If match_func is NULL, then all open lots are returned. If sort_func is NULL, then the returned list has no particular order. The caller must free to returned list.

Definition at line 3524 of file Account.c.

03528 {
03529     AccountPrivate *priv;
03530     GList *lot_list;
03531     GList *retval = NULL;
03532 
03533     g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
03534 
03535     priv = GET_PRIVATE(acc);
03536     for (lot_list = priv->lots; lot_list; lot_list = lot_list->next)
03537     {
03538         GNCLot *lot = lot_list->data;
03539 
03540         /* If this lot is closed, then ignore it */
03541         if (gnc_lot_is_closed (lot))
03542             continue;
03543 
03544         if (match_func && !(match_func)(lot, user_data))
03545             continue;
03546 
03547         /* Ok, this is a valid lot.  Add it to our list of lots */
03548         if (sort_func)
03549             retval = g_list_insert_sorted (retval, lot, sort_func);
03550         else
03551             retval = g_list_prepend (retval, lot);
03552     }
03553 
03554     return retval;
03555 }

Split* xaccAccountFindSplitByDesc ( const Account account,
const char *  description 
)

Returns a pointer to the split, not a copy.

Definition at line 4392 of file Account.c.

04393 {
04394     Split *split;
04395 
04396     /* Get the split which has a transaction matching the description. */
04397     finder_help_function(acc, description, &split, NULL);
04398     return split;
04399 }

Transaction* xaccAccountFindTransByDesc ( const Account account,
const char *  description 
)

Returns a pointer to the transaction, not a copy.

Definition at line 4407 of file Account.c.

04408 {
04409     Transaction *trans;
04410 
04411     /* Get the transation matching the description. */
04412     finder_help_function(acc, description, NULL, &trans);
04413     return trans;
04414 }

gpointer xaccAccountForEachLot ( const Account acc,
gpointer(*)(GNCLot *lot, gpointer user_data)  proc,
gpointer  user_data 
)

The xaccAccountForEachLot() method will apply the function 'proc' to each lot in the account. If 'proc' returns a non-NULL value, further application will be stopped, and the resulting value will be returned. There is no guarenteed order over which the Lots will be traversed.

gint xaccAccountForEachTransaction ( const Account account,
TransactionCallback  proc,
void *  data 
)

The xaccAccountForEachTransaction() routine will traverse all of the transactions in account and call the callback function proc on each transaction. Processing will continue if-and-only-if proc returns 0. The user data pointer data will be passed on to the callback function proc.

This function does not descend recursively to traverse transactions in child accounts.

proc will be called exactly once for each transaction that is pointed to by at least one split in the given account.

The result of this function will be 0 if and only if every relevant transaction was traversed exactly once. Else the return value is the last non-zero value returned by proc.

Warning:
For performance reasons, the transaction callback proc must never destroy any of the transaction's splits, nor assign any of them to a different account. To do so risks a crash.

The traversal occurs only over the transactions that are locally cached in the local gnucash engine. If the gnucash engine is attached to a remote database, the database may contain (many) transactions that are not mirrored in the local cache. This routine will not cause an SQL database query to be performed; it will not traverse transactions present only in the remote database.

Definition at line 4737 of file Account.c.

04739 {
04740     if (!acc || !proc) return 0;
04741     xaccAccountBeginStagedTransactionTraversals (acc);
04742     return xaccAccountStagedTransactionTraversal(acc, 42, proc, data);
04743 }

GNCPlaceholderType xaccAccountGetDescendantPlaceholder ( const Account account  ) 

Returns PLACEHOLDER_NONE if account is NULL or neither account nor any descendant of account is a placeholder. If account is a placeholder, returns PLACEHOLDER_THIS. Otherwise, if any descendant of account is a placeholder, return PLACEHOLDER_CHILD.

Definition at line 3708 of file Account.c.

03709 {
03710     GList *descendants, *node;
03711     GNCPlaceholderType ret = PLACEHOLDER_NONE;
03712 
03713     g_return_val_if_fail(GNC_IS_ACCOUNT(acc), PLACEHOLDER_NONE);
03714     if (xaccAccountGetPlaceholder(acc)) return PLACEHOLDER_THIS;
03715 
03716     descendants = gnc_account_get_descendants(acc);
03717     for (node = descendants; node; node = node->next)
03718         if (xaccAccountGetPlaceholder((Account *) node->data))
03719         {
03720             ret = PLACEHOLDER_CHILD;
03721             break;
03722         }
03723 
03724     g_list_free(descendants);
03725     return ret;
03726 }

gboolean xaccAccountGetHidden ( const Account acc  ) 

Get the "hidden" flag for an account. If this flag is set then the account (and any children) will be hidden from the user unless they explicitly ask to see them.

Parameters:
acc The account whose flag should be retrieved.
Returns:
The current state of the account's "hidden" flag.

Definition at line 3732 of file Account.c.

03733 {
03734     const char *str;
03735 
03736     g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
03737 
03738     str = kvp_frame_get_string(acc->inst.kvp_data, "hidden");
03739     return (str && !strcmp(str, "true"));
03740 }

LotList* xaccAccountGetLotList ( const Account account  ) 

The xaccAccountGetLotList() routine returns a list of all lots in this account.

Parameters:
account The account whose lots should be returned.
Returns:
A GList of lot pointers, or NULL if there are no lots in this account children. It is the callers responsibility to free any returned list with the g_list_free() function.

Definition at line 3517 of file Account.c.

03518 {
03519     g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
03520     return g_list_copy(GET_PRIVATE(acc)->lots);
03521 }

short xaccAccountGetMark ( const Account account  ) 

Get the mark set by xaccAccountSetMark

Definition at line 1661 of file Account.c.

01662 {
01663     g_return_val_if_fail(GNC_IS_ACCOUNT(acc), 0);
01664 
01665     return GET_PRIVATE(acc)->mark;
01666 }

gboolean xaccAccountGetPlaceholder ( const Account account  ) 

Get the "placeholder" flag for an account. If this flag is set then the account may not be modified by the user.

Parameters:
account The account whose flag should be retrieved.
Returns:
The current state of the account's "placeholder" flag.

Definition at line 3685 of file Account.c.

03686 {
03687     const char *str;
03688 
03689     g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
03690 
03691     str = kvp_frame_get_string(acc->inst.kvp_data, "placeholder");
03692     return (str && !strcmp(str, "true"));
03693 }

gboolean xaccAccountGetReconcileLastDate ( const Account account,
time_t *  last_date 
)

DOCUMENT ME!

Definition at line 4019 of file Account.c.

04020 {
04021     KvpValue *v;
04022 
04023     if (!acc) return FALSE;
04024 
04025     v = kvp_frame_get_value(acc->inst.kvp_data, "reconcile-info/last-date");
04026 
04027     if (!v || kvp_value_get_type(v) != KVP_TYPE_GINT64)
04028         return FALSE;
04029 
04030     if (last_date)
04031         *last_date = kvp_value_get_gint64(v);
04032 
04033     return TRUE;
04034 }

gboolean xaccAccountGetReconcileLastInterval ( const Account account,
int *  months,
int *  days 
)

DOCUMENT ME!

Definition at line 4055 of file Account.c.

04057 {
04058     KvpValue *v1, *v2;
04059 
04060     if (!acc) return FALSE;
04061 
04062     v1 = kvp_frame_get_value(acc->inst.kvp_data,
04063                              "reconcile-info/last-interval/months");
04064     v2 = kvp_frame_get_value(acc->inst.kvp_data,
04065                              "reconcile-info/last-interval/days");
04066     if (!v1 || (kvp_value_get_type (v1) != KVP_TYPE_GINT64) ||
04067             !v2 || (kvp_value_get_type (v2) != KVP_TYPE_GINT64))
04068         return FALSE;
04069 
04070     if (months)
04071         *months = kvp_value_get_gint64 (v1);
04072     if (days)
04073         *days = kvp_value_get_gint64 (v2);
04074     return TRUE;
04075 }

gboolean xaccAccountGetReconcilePostponeBalance ( const Account account,
gnc_numeric balance 
)

DOCUMENT ME!

Definition at line 4140 of file Account.c.

04142 {
04143     KvpValue *v;
04144 
04145     if (!acc) return FALSE;
04146 
04147     v = kvp_frame_get_value(acc->inst.kvp_data,
04148                             "reconcile-info/postpone/balance");
04149     if (!v || kvp_value_get_type (v) != KVP_TYPE_NUMERIC)
04150         return FALSE;
04151 
04152     if (balance)
04153         *balance = kvp_value_get_numeric (v);
04154 
04155     return TRUE;
04156 }

gboolean xaccAccountGetReconcilePostponeDate ( const Account account,
time_t *  postpone_date 
)

DOCUMENT ME!

Definition at line 4103 of file Account.c.

04104 {
04105     KvpValue *v;
04106 
04107     if (!acc) return FALSE;
04108 
04109     v = kvp_frame_get_value(acc->inst.kvp_data, "reconcile-info/postpone/date");
04110     if (!v || kvp_value_get_type (v) != KVP_TYPE_GINT64)
04111         return FALSE;
04112 
04113     if (postpone_date)
04114         *postpone_date = kvp_value_get_gint64 (v);
04115 
04116     return TRUE;
04117 }

SplitList* xaccAccountGetSplitList ( const Account account  ) 

The xaccAccountGetSplitList() routine returns a pointer to a GList of the splits in the account.

Note:
This GList is the account's internal data structure: do not delete it when done; treat it as a read-only structure. Note that some routines (such as xaccAccountRemoveSplit()) modify this list directly, and could leave you with a corrupted pointer.

This should be changed so that the returned value is a copy of the list. No other part of the code should have access to the internal data structure used by this object.

Definition at line 3509 of file Account.c.

03510 {
03511     g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
03512     xaccAccountSortSplits((Account*)acc, FALSE);  // normally a noop
03513     return GET_PRIVATE(acc)->splits;
03514 }

gboolean xaccAccountGetTaxRelated ( const Account account  ) 

DOCUMENT ME!

Definition at line 3581 of file Account.c.

03582 {
03583     g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
03584     return kvp_frame_get_gint64(acc->inst.kvp_data, "tax-related");
03585 }

const char* xaccAccountGetTaxUSCode ( const Account account  ) 

DOCUMENT ME!

Definition at line 3606 of file Account.c.

03607 {
03608     g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
03609     return kvp_frame_get_string(acc->inst.kvp_data, "tax-US/code");
03610 }

gint64 xaccAccountGetTaxUSCopyNumber ( const Account account  ) 

DOCUMENT ME!

Definition at line 3649 of file Account.c.

03650 {
03651     gint64 copy_number;
03652 
03653     g_return_val_if_fail(GNC_IS_ACCOUNT(acc), 1);
03654     copy_number = kvp_frame_get_gint64(acc->inst.kvp_data,
03655                                        "tax-US/copy-number");
03656     return (copy_number == 0) ? 1 : copy_number;
03657 }

const char* xaccAccountGetTaxUSPayerNameSource ( const Account account  ) 

DOCUMENT ME!

Definition at line 3629 of file Account.c.

03630 {
03631     g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
03632     return kvp_frame_get_string(acc->inst.kvp_data,
03633                                 "tax-US/payer-name-source");
03634 }

GNCAccountType xaccAccountGetTypeFromStr ( const gchar *  str  ) 

The xaccAccountGetTypeStr() routine returns a string suitable for use in the GUI/Interface. These strings should be translated to the local language.

Definition at line 3917 of file Account.c.

03918 {
03919     gint type;
03920 
03921     for (type = 0; type < NUM_ACCOUNT_TYPES; type++)
03922     {
03923         if (!safe_strcmp (str, _(account_type_name [type])))
03924             return type;
03925     }
03926 
03927     PERR("asked to translate unknown account type string %s.\n",
03928          str ? str : "(null)");
03929 
03930     return ACCT_TYPE_INVALID;
03931 }

const char* xaccAccountGetTypeStr ( GNCAccountType  type  ) 

The xaccAccountGetTypeStr() routine returns a string suitable for use in the GUI/Interface. These strings should be translated to the local language.

Definition at line 3910 of file Account.c.

03911 {
03912     if (type < 0 || NUM_ACCOUNT_TYPES <= type ) return "";
03913     return _(account_type_name [type]);
03914 }

void xaccAccountInsertLot ( Account ,
GNCLot  
)

The xaccAccountInsertLot() method will register the indicated lot with this account. Any splits later inserted into this lot must belong to this account. If the lot is already in another account, the lot, and all of the splits in it, will be moved from that account to this account.

Definition at line 1750 of file Account.c.

01751 {
01752     AccountPrivate *priv, *opriv;
01753     Account * old_acc = NULL;
01754     Account* lot_account;
01755 
01756     /* errors */
01757     g_return_if_fail(GNC_IS_ACCOUNT(acc));
01758     g_return_if_fail(GNC_IS_LOT(lot));
01759 
01760     /* optimizations */
01761     lot_account = gnc_lot_get_account(lot);
01762     if (lot_account == acc)
01763         return;
01764 
01765     ENTER ("(acc=%p, lot=%p)", acc, lot);
01766 
01767     /* pull it out of the old account */
01768     if (lot_account)
01769     {
01770         old_acc = lot_account;
01771         opriv = GET_PRIVATE(old_acc);
01772         opriv->lots = g_list_remove(opriv->lots, lot);
01773     }
01774 
01775     priv = GET_PRIVATE(acc);
01776     priv->lots = g_list_prepend(priv->lots, lot);
01777     gnc_lot_set_account(lot, acc);
01778 
01779     /* Don't move the splits to the new account.  The caller will do this
01780      * if appropriate, and doing it here will not work if we are being
01781      * called from gnc_book_close_period since xaccAccountInsertSplit
01782      * will try to balance capital gains and things aren't ready for that. */
01783 
01784     qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_ADD, NULL);
01785     qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, NULL);
01786 
01787     LEAVE ("(acc=%p, lot=%p)", acc, lot);
01788 }

gboolean xaccAccountIsHidden ( const Account acc  ) 

Should this account be "hidden". If this flag is set for this account (or any parent account) then the account should be hidden from the user unless they explicitly ask to see it. This function is different from the xaccAccountGetHidden() function because it checks the flag in parent accounts in addition to this account.

Parameters:
acc The account whose flag should be retrieved.
Returns:
Whether or not this account should be "hidden".

Definition at line 3755 of file Account.c.

03756 {
03757     AccountPrivate *priv;
03758 
03759     g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
03760 
03761     if (xaccAccountGetHidden(acc))
03762         return TRUE;
03763     priv = GET_PRIVATE(acc);
03764     while ((acc = priv->parent) != NULL)
03765     {
03766         priv = GET_PRIVATE(acc);
03767         if (xaccAccountGetHidden(acc))
03768             return TRUE;
03769     }
03770     return FALSE;
03771 }

void xaccAccountMoveAllSplits ( Account accfrom,
Account accto 
)

The xaccAccountMoveAllSplits() routine reassigns each of the splits in accfrom to accto.

Definition at line 1810 of file Account.c.

01811 {
01812     AccountPrivate *from_priv, *to_priv;
01813 
01814     /* errors */
01815     g_return_if_fail(GNC_IS_ACCOUNT(accfrom));
01816     g_return_if_fail(GNC_IS_ACCOUNT(accto));
01817 
01818     /* optimizations */
01819     from_priv = GET_PRIVATE(accfrom);
01820     to_priv = GET_PRIVATE(accto);
01821     if (!from_priv->splits || accfrom == accto)
01822         return;
01823 
01824     /* check for book mix-up */
01825     g_return_if_fail (qof_instance_books_equal(accfrom, accto));
01826     ENTER ("(accfrom=%p, accto=%p)", accfrom, accto);
01827 
01828     xaccAccountBeginEdit(accfrom);
01829     xaccAccountBeginEdit(accto);
01830     /* Begin editing both accounts and all transactions in accfrom. */
01831     g_list_foreach(from_priv->splits, (GFunc)xaccPreSplitMove, NULL);
01832 
01833     /* Concatenate accfrom's lists of splits and lots to accto's lists. */
01834     //to_priv->splits = g_list_concat(to_priv->splits, from_priv->splits);
01835     //to_priv->lots = g_list_concat(to_priv->lots, from_priv->lots);
01836 
01837     /* Set appropriate flags. */
01838     //from_priv->balance_dirty = TRUE;
01839     //from_priv->sort_dirty = FALSE;
01840     //to_priv->balance_dirty = TRUE;
01841     //to_priv->sort_dirty = TRUE;
01842 
01843     /*
01844      * Change each split's account back pointer to accto.
01845      * Convert each split's amount to accto's commodity.
01846      * Commit to editing each transaction.
01847      */
01848     g_list_foreach(from_priv->splits, (GFunc)xaccPostSplitMove, (gpointer)accto);
01849 
01850     /* Finally empty accfrom. */
01851     g_assert(from_priv->splits == NULL);
01852     g_assert(from_priv->lots == NULL);
01853     xaccAccountCommitEdit(accfrom);
01854     xaccAccountCommitEdit(accto);
01855 
01856     LEAVE ("(accfrom=%p, accto=%p)", accfrom, accto);
01857 }

void xaccAccountSetHidden ( Account acc,
gboolean  val 
)

Set the "hidden" flag for an account. If this flag is set then the account (and any children) will be hidden from the user unless they explicitly ask to see them.

Parameters:
acc The account whose flag should be retrieved.
val The new state for the account's "hidden" flag.

Definition at line 3743 of file Account.c.

03744 {
03745     g_return_if_fail(GNC_IS_ACCOUNT(acc));
03746 
03747     xaccAccountBeginEdit (acc);
03748     kvp_frame_set_string (acc->inst.kvp_data, "hidden",
03749                           val ? "true" : NULL);
03750     mark_account (acc);
03751     xaccAccountCommitEdit (acc);
03752 }

void xaccAccountSetMark ( Account account,
short  mark 
)

Set a mark on the account. The meaning of this mark is completely undefined. Its presented here as a utility for the programmer, to use as desired. Handy for performing customer traversals over the account tree. The mark is *not* stored in the database/file format. When accounts are newly created, the mark is set to zero.

Definition at line 1669 of file Account.c.

01670 {
01671     AccountPrivate *priv;
01672 
01673     g_return_if_fail(GNC_IS_ACCOUNT(acc));
01674 
01675     priv = GET_PRIVATE(acc);
01676     priv->mark = m;
01677 }

void xaccAccountSetPlaceholder ( Account account,
gboolean  val 
)

Set the "placeholder" flag for an account. If this flag is set then the account may not be modified by the user.

Parameters:
account The account whose flag should be retrieved.
val The new state for the account's "placeholder" flag.

Definition at line 3696 of file Account.c.

03697 {
03698     g_return_if_fail(GNC_IS_ACCOUNT(acc));
03699 
03700     xaccAccountBeginEdit (acc);
03701     kvp_frame_set_string (acc->inst.kvp_data,
03702                           "placeholder", val ? "true" : NULL);
03703     mark_account (acc);
03704     xaccAccountCommitEdit (acc);
03705 }

void xaccAccountSetReconcileLastDate ( Account account,
time_t  last_date 
)

DOCUMENT ME!

Definition at line 4040 of file Account.c.

04041 {
04042     if (!acc) return;
04043 
04044     xaccAccountBeginEdit (acc);
04045     kvp_frame_set_gint64 (acc->inst.kvp_data,
04046                           "/reconcile-info/last-date", last_date);
04047     mark_account (acc);
04048     xaccAccountCommitEdit (acc);
04049 }

void xaccAccountSetReconcileLastInterval ( Account account,
int  months,
int  days 
)

DOCUMENT ME!

Definition at line 4081 of file Account.c.

04082 {
04083     KvpFrame *frame;
04084     if (!acc) return;
04085 
04086     xaccAccountBeginEdit (acc);
04087 
04088     frame = kvp_frame_get_frame_slash (acc->inst.kvp_data,
04089                                        "/reconcile-info/last-interval");
04090     g_assert(frame);
04091 
04092     kvp_frame_set_gint64 (frame, "months", months);
04093     kvp_frame_set_gint64 (frame, "days", days);
04094 
04095     mark_account (acc);
04096     xaccAccountCommitEdit (acc);
04097 }

void xaccAccountSetReconcilePostponeBalance ( Account account,
gnc_numeric  balance 
)

DOCUMENT ME!

Definition at line 4162 of file Account.c.

04163 {
04164     if (!acc) return;
04165 
04166     xaccAccountBeginEdit (acc);
04167     kvp_frame_set_gnc_numeric (acc->inst.kvp_data,
04168                                "/reconcile-info/postpone/balance", balance);
04169     mark_account (acc);
04170     xaccAccountCommitEdit (acc);
04171 }

void xaccAccountSetReconcilePostponeDate ( Account account,
time_t  postpone_date 
)

DOCUMENT ME!

Definition at line 4123 of file Account.c.

04124 {
04125     if (!acc) return;
04126 
04127     xaccAccountBeginEdit (acc);
04128 
04129     /* XXX this should be using timespecs, not gints !! */
04130     kvp_frame_set_gint64 (acc->inst.kvp_data,
04131                           "reconcile-info/postpone/date", postpone_date);
04132     mark_account (acc);
04133     xaccAccountCommitEdit (acc);
04134 }

void xaccAccountSetTaxRelated ( Account account,
gboolean  tax_related 
)

DOCUMENT ME!

Definition at line 3588 of file Account.c.

03589 {
03590     KvpValue *new_value;
03591 
03592     g_return_if_fail(GNC_IS_ACCOUNT(acc));
03593 
03594     if (tax_related)
03595         new_value = kvp_value_new_gint64 (tax_related);
03596     else
03597         new_value = NULL;
03598 
03599     xaccAccountBeginEdit (acc);
03600     kvp_frame_set_slot_nc(acc->inst.kvp_data, "tax-related", new_value);
03601     mark_account (acc);
03602     xaccAccountCommitEdit (acc);
03603 }

void xaccAccountSetTaxUSCode ( Account account,
const char *  code 
)

DOCUMENT ME!

Definition at line 3613 of file Account.c.

03614 {
03615     g_return_if_fail(GNC_IS_ACCOUNT(acc));
03616 
03617     xaccAccountBeginEdit (acc);
03618     kvp_frame_set_string (acc->inst.kvp_data, "/tax-US/code", code);
03619     if (!code)
03620     {
03621         KvpFrame  *frame = NULL;
03622         kvp_frame_set_frame (acc->inst.kvp_data, "/tax-US", frame);
03623     }
03624     mark_account (acc);
03625     xaccAccountCommitEdit (acc);
03626 }

void xaccAccountSetTaxUSCopyNumber ( Account account,
gint64  copy_number 
)

DOCUMENT ME!

Definition at line 3660 of file Account.c.

03661 {
03662     g_return_if_fail(GNC_IS_ACCOUNT(acc));
03663 
03664     xaccAccountBeginEdit (acc);
03665     if (copy_number != 0)
03666         kvp_frame_set_gint64 (acc->inst.kvp_data, "/tax-US/copy-number", copy_number);
03667     else
03668     {
03669         KvpFrame * frame;
03670         KvpValue *value;
03671 
03672         value = NULL;
03673         frame = kvp_frame_set_value_nc (acc->inst.kvp_data,
03674                                         "/tax-US/copy-number", value);
03675         if (!frame) kvp_value_delete (value);
03676     }
03677     mark_account (acc);
03678     xaccAccountCommitEdit (acc);
03679 }

void xaccAccountSetTaxUSPayerNameSource ( Account account,
const char *  source 
)

DOCUMENT ME!

Definition at line 3637 of file Account.c.

03638 {
03639     g_return_if_fail(GNC_IS_ACCOUNT(acc));
03640 
03641     xaccAccountBeginEdit (acc);
03642     kvp_frame_set_string (acc->inst.kvp_data,
03643                           "/tax-US/payer-name-source", source);
03644     mark_account (acc);
03645     xaccAccountCommitEdit (acc);
03646 }

int xaccAccountStagedTransactionTraversal ( const Account a,
unsigned int  stage,
TransactionCallback  thunk,
void *  data 
)

xaccAccountStagedTransactionTraversal() calls thunk on each transaction in account a whose current marker is less than the given stage and updates each transaction's marker to be stage. The traversal will stop if thunk returns a non-zero value. xaccAccountStagedTransactionTraversal() function will return zero or the non-zero value returned by thunk. This API does not handle handle recursive traversals.

Warning:
For performance reasons, the transaction callback thunk must never destroy any of the transaction's splits, nor assign any of them to a different account. To do so risks a crash.

Definition at line 4640 of file Account.c.

04644 {
04645     AccountPrivate *priv;
04646     GList *split_p;
04647     GList *next;
04648     Transaction *trans;
04649     Split *s;
04650     int retval;
04651 
04652     if (!acc) return 0;
04653 
04654     priv = GET_PRIVATE(acc);
04655     for (split_p = priv->splits; split_p; split_p = next)
04656     {
04657         /* Get the next element in the split list now, just in case some
04658          * naughty thunk destroys the one we're using. This reduces, but
04659          * does not eliminate, the possibility of undefined results if
04660          * a thunk removes splits from this account. */
04661         next = g_list_next(split_p);
04662 
04663         s = split_p->data;
04664         trans = s->parent;
04665         if (trans && (trans->marker < stage))
04666         {
04667             trans->marker = stage;
04668             if (thunk)
04669             {
04670                 retval = thunk(trans, cb_data);
04671                 if (retval) return retval;
04672             }
04673         }
04674     }
04675 
04676     return 0;
04677 }

GNCAccountType xaccAccountStringToEnum ( const char *  str  ) 

Conversion routines for the account types to/from strings that are used in persistant storage, communications. These strings should *not* be translated to the local language. Typical converstion is "INCOME" -> ACCT_TYPE_INCOME.

Definition at line 3871 of file Account.c.

03872 {
03873     GNCAccountType type;
03874     gboolean rc;
03875     rc = xaccAccountStringToType(str, &type);
03876     if (FALSE == rc) return ACCT_TYPE_INVALID;
03877     return type;
03878 }

gboolean xaccAccountStringToType ( const char *  str,
GNCAccountType type 
)

Conversion routines for the account types to/from strings that are used in persistant storage, communications. These strings should *not* be translated to the local language. Typical converstion is "INCOME" -> ACCT_TYPE_INCOME.

Definition at line 3837 of file Account.c.

03838 {
03839 
03840     GNC_RETURN_ON_MATCH(NONE);
03841     GNC_RETURN_ON_MATCH(BANK);
03842     GNC_RETURN_ON_MATCH(CASH);
03843     GNC_RETURN_ON_MATCH(CREDIT);
03844     GNC_RETURN_ON_MATCH(ASSET);
03845     GNC_RETURN_ON_MATCH(LIABILITY);
03846     GNC_RETURN_ON_MATCH(STOCK);
03847     GNC_RETURN_ON_MATCH(MUTUAL);
03848     GNC_RETURN_ON_MATCH(CURRENCY);
03849     GNC_RETURN_ON_MATCH(INCOME);
03850     GNC_RETURN_ON_MATCH(EXPENSE);
03851     GNC_RETURN_ON_MATCH(EQUITY);
03852     GNC_RETURN_ON_MATCH(RECEIVABLE);
03853     GNC_RETURN_ON_MATCH(PAYABLE);
03854     GNC_RETURN_ON_MATCH(ROOT);
03855     GNC_RETURN_ON_MATCH(TRADING);
03856     GNC_RETURN_ON_MATCH(CHECKING);
03857     GNC_RETURN_ON_MATCH(SAVINGS);
03858     GNC_RETURN_ON_MATCH(MONEYMRKT);
03859     GNC_RETURN_ON_MATCH(CREDITLINE);
03860 
03861     PERR("asked to translate unknown account type string %s.\n",
03862          str ? str : "(null)");
03863 
03864     return(FALSE);
03865 }

int xaccAccountTreeForEachTransaction ( Account acc,
TransactionCallback  proc,
void *  data 
)

Traverse all of the transactions in the given account group. Continue processing IFF proc returns 0. This function will descend recursively to traverse transactions in the children of the accounts in the group.

Proc will be called exactly once for each transaction that is pointed to by at least one split in any account in the hierarchy topped by the root Account acc.

The result of this function will be 0 IFF every relevant transaction was traversed exactly once; otherwise, the return value is the last non-zero value returned by the callback.

Warning:
For performance reasons, the transaction callback proc must never destroy any of the transaction's splits, nor assign any of them to a different account. To do so risks a crash.

The traversal occurs only over the transactions that are locally cached in the local gnucash engine. If the gnucash engine is attached to a remote database, the database may contain (many) transactions that are not mirrored in the local cache. This routine will not cause an SQL database query to be performed; it will not traverse transactions present only in the remote database.

Note that this routine is just a trivial wrapper for

gnc_account_tree_begin_staged_transaction_traversals(g); gnc_account_tree_staged_transaction_traversal(g, 42, proc, data);

const char* xaccAccountTypeEnumAsString ( GNCAccountType  type  ) 

Conversion routines for the account types to/from strings that are used in persistant storage, communications. These strings should *not* be translated to the local language. Typical converstion is ACCT_TYPE_INCOME -> "INCOME".

Definition at line 3800 of file Account.c.

03801 {
03802     switch (type)
03803     {
03804         GNC_RETURN_ENUM_AS_STRING(NONE);
03805         GNC_RETURN_ENUM_AS_STRING(BANK);
03806         GNC_RETURN_ENUM_AS_STRING(CASH);
03807         GNC_RETURN_ENUM_AS_STRING(CREDIT);
03808         GNC_RETURN_ENUM_AS_STRING(ASSET);
03809         GNC_RETURN_ENUM_AS_STRING(LIABILITY);
03810         GNC_RETURN_ENUM_AS_STRING(STOCK);
03811         GNC_RETURN_ENUM_AS_STRING(MUTUAL);
03812         GNC_RETURN_ENUM_AS_STRING(CURRENCY);
03813         GNC_RETURN_ENUM_AS_STRING(INCOME);
03814         GNC_RETURN_ENUM_AS_STRING(EXPENSE);
03815         GNC_RETURN_ENUM_AS_STRING(EQUITY);
03816         GNC_RETURN_ENUM_AS_STRING(RECEIVABLE);
03817         GNC_RETURN_ENUM_AS_STRING(PAYABLE);
03818         GNC_RETURN_ENUM_AS_STRING(ROOT);
03819         GNC_RETURN_ENUM_AS_STRING(TRADING);
03820         GNC_RETURN_ENUM_AS_STRING(CHECKING);
03821         GNC_RETURN_ENUM_AS_STRING(SAVINGS);
03822         GNC_RETURN_ENUM_AS_STRING(MONEYMRKT);
03823         GNC_RETURN_ENUM_AS_STRING(CREDITLINE);
03824     default:
03825         PERR ("asked to translate unknown account type %d.\n", type);
03826         break;
03827     }
03828     return(NULL);
03829 }

gboolean xaccAccountTypesCompatible ( GNCAccountType  parent_type,
GNCAccountType  child_type 
)

Return TRUE if accounts of type parent_type can have accounts of type child_type as children.

Definition at line 3985 of file Account.c.

03987 {
03988     return ((xaccParentAccountTypesCompatibleWith (parent_type) &
03989              (1 << child_type))
03990             != 0);
03991 }

guint32 xaccAccountTypesValid ( void   ) 

Returns the bitmask of the account type enums that are valid. Deprecated and root account types are stripped.

Definition at line 3994 of file Account.c.

03995 {
03996     guint32 mask = (1 << NUM_ACCOUNT_TYPES) - 1;
03997     mask &= ~((1 << ACCT_TYPE_CURRENCY) |  /* DEPRECATED */
03998               (1 << ACCT_TYPE_ROOT));      /* ROOT */
03999 
04000     return mask;
04001 }

void xaccClearMark ( Account account,
short  val 
)

The xaccClearMark will find the root account, and clear the mark in the entire account tree.

Definition at line 1680 of file Account.c.

01681 {
01682     Account *root;
01683 
01684     g_return_if_fail(GNC_IS_ACCOUNT(acc));
01685 
01686     root = gnc_account_get_root(acc);
01687     xaccClearMarkDown(root ? root : acc, val);
01688 }

void xaccClearMarkDown ( Account account,
short  val 
)

The xaccClearMarkDown will clear the mark only in this and in sub-accounts.

Definition at line 1691 of file Account.c.

01692 {
01693     AccountPrivate *priv;
01694     GList *node;
01695 
01696     g_return_if_fail(GNC_IS_ACCOUNT(acc));
01697 
01698     priv = GET_PRIVATE(acc);
01699     priv->mark = val;
01700     for (node = priv->children; node; node = node->next)
01701     {
01702         xaccClearMarkDown(node->data, val);
01703     }
01704 }

guint32 xaccParentAccountTypesCompatibleWith ( GNCAccountType  type  ) 

Return the bitmask of parent account types compatible with a given type.

Definition at line 3938 of file Account.c.

03939 {
03940     switch (type)
03941     {
03942     case ACCT_TYPE_BANK:
03943     case ACCT_TYPE_CASH:
03944     case ACCT_TYPE_ASSET:
03945     case ACCT_TYPE_STOCK:
03946     case ACCT_TYPE_MUTUAL:
03947     case ACCT_TYPE_CURRENCY:
03948     case ACCT_TYPE_CREDIT:
03949     case ACCT_TYPE_LIABILITY:
03950     case ACCT_TYPE_RECEIVABLE:
03951     case ACCT_TYPE_PAYABLE:
03952         return
03953             (1 << ACCT_TYPE_BANK)       |
03954             (1 << ACCT_TYPE_CASH)       |
03955             (1 << ACCT_TYPE_ASSET)      |
03956             (1 << ACCT_TYPE_STOCK)      |
03957             (1 << ACCT_TYPE_MUTUAL)     |
03958             (1 << ACCT_TYPE_CURRENCY)   |
03959             (1 << ACCT_TYPE_CREDIT)     |
03960             (1 << ACCT_TYPE_LIABILITY)  |
03961             (1 << ACCT_TYPE_RECEIVABLE) |
03962             (1 << ACCT_TYPE_PAYABLE)    |
03963             (1 << ACCT_TYPE_ROOT);
03964     case ACCT_TYPE_INCOME:
03965     case ACCT_TYPE_EXPENSE:
03966         return
03967             (1 << ACCT_TYPE_INCOME)     |
03968             (1 << ACCT_TYPE_EXPENSE)    |
03969             (1 << ACCT_TYPE_ROOT);
03970     case ACCT_TYPE_EQUITY:
03971         return
03972             (1 << ACCT_TYPE_EQUITY)     |
03973             (1 << ACCT_TYPE_ROOT);
03974     case ACCT_TYPE_TRADING:
03975         return
03976             (1 << ACCT_TYPE_TRADING)    |
03977             (1 << ACCT_TYPE_ROOT);
03978     default:
03979         PERR("bad account type: %d", type);
03980         return 0;
03981     }
03982 }

void xaccSplitsBeginStagedTransactionTraversals ( SplitList splits  ) 

xaccSplitsBeginStagedTransactionTraversals() resets the traversal marker for each transaction which is a parent of one of the splits in the list.

Definition at line 4568 of file Account.c.

04569 {
04570     GList *lp;
04571 
04572     for (lp = splits; lp; lp = lp->next)
04573     {
04574         Split *s = lp->data;
04575         Transaction *trans = s->parent;
04576 
04577         if (trans)
04578             trans->marker = 0;
04579     }
04580 }

gboolean xaccSplitTransactionTraverse ( Split split,
int  stage 
)

xaccSplitTransactionTraverse() behaves as above using the parent of the given split.

Definition at line 4609 of file Account.c.

04610 {
04611     if (split == NULL) return FALSE;
04612 
04613     return xaccTransactionTraverse (split->parent, stage);
04614 }

gboolean xaccTransactionTraverse ( Transaction trans,
int  stage 
)

xaccTransactionTraverse() checks the stage of the given transaction. If the transaction hasn't reached the given stage, the transaction is updated to that stage and the function returns TRUE. Otherwise no change is made and the function returns FALSE.

Definition at line 4595 of file Account.c.

04596 {
04597     if (trans == NULL) return FALSE;
04598 
04599     if (trans->marker < stage)
04600     {
04601         trans->marker = stage;
04602         return TRUE;
04603     }
04604 
04605     return FALSE;
04606 }


Generated on Tue Mar 16 04:43:36 2010 for GnuCash by  doxygen 1.5.7.1