GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Modules | Files | Macros | Typedefs | Enumerations | Functions
GnuCash Engine: Core, Non-GUI Accounting Functions

Modules

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

Files

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

Macros

#define ACCOUNT_MATCH_ALL_TYPE   "account-match-all"
 
#define GNC_ID_NONE   QOF_ID_NONE
 IDENTIFIERS GncGUID Identifiers can be used to reference Accounts, Transactions, Splits and other objects. These Gnucash types are referred to as Gnucash entities. GncGUID 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"
 
#define GNC_INVOICE_ID   "gncInvoice"
 
#define GNC_INVOICE_GUID   "invoice-guid"
 
#define GNC_OWNER_ID   "gncOwner"
 
#define GNC_OWNER_TYPE   "owner-type"
 
#define GNC_OWNER_GUID   "owner-guid"
 
#define GNC_SX_ID   "sched-xaction"
 

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 referred 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. More...
 
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). More...
 
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. More...
 
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. More...
 
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

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)
 

Lookup Accounts and Subaccounts by name or code

Accountgnc_account_lookup_by_name (const Account *parent, const char *name)
 
Accountgnc_account_lookup_by_full_name (const Account *any_account, const gchar *name)
 
Accountgnc_account_lookup_by_code (const Account *parent, const char *code)
 

GNCAccountType conversion/checking

const char * xaccAccountTypeEnumAsString (GNCAccountType type)
 
gboolean xaccAccountStringToType (const char *str, GNCAccountType *type)
 
GNCAccountType xaccAccountStringToEnum (const char *str)
 
const char * xaccAccountGetTypeStr (GNCAccountType type)
 
guint32 xaccParentAccountTypesCompatibleWith (GNCAccountType type)
 
gboolean xaccAccountTypesCompatible (GNCAccountType parent_type, GNCAccountType child_type)
 
guint32 xaccAccountTypesValid (void)
 
gboolean xaccAccountIsAssetLiabType (GNCAccountType t)
 
gboolean xaccAccountIsAPARType (GNCAccountType t)
 
gboolean xaccAccountIsEquityType (GNCAccountType t)
 

Account split/transaction list management

SplitListxaccAccountGetSplitList (const Account *account)
 
gint64 xaccAccountCountSplits (const Account *acc, gboolean include_children)
 
void xaccAccountMoveAllSplits (Account *accfrom, Account *accto)
 
gint xaccAccountForEachTransaction (const Account *account, TransactionCallback proc, void *data)
 
TransactionxaccAccountFindTransByDesc (const Account *account, const char *description)
 
SplitxaccAccountFindSplitByDesc (const Account *account, const char *description)
 
#define xaccAccountInsertSplit(acc, s)   xaccSplitSetAccount((s), (acc))
 

Account lots

void xaccAccountInsertLot (Account *, GNCLot *)
 
void xaccAccountRemoveLot (Account *, GNCLot *)
 
LotListxaccAccountGetLotList (const Account *account)
 
gpointer xaccAccountForEachLot (const Account *acc, gpointer(*proc)(GNCLot *lot, gpointer user_data), gpointer user_data)
 
LotListxaccAccountFindOpenLots (const Account *acc, gboolean(*match_func)(GNCLot *lot, gpointer user_data), gpointer user_data, GCompareFunc sort_func)
 

Account Reconciliation information getters/setters

gboolean xaccAccountGetReconcileLastDate (const Account *account, time64 *last_date)
 
void xaccAccountSetReconcileLastDate (Account *account, time64 last_date)
 
gboolean xaccAccountGetReconcileLastInterval (const Account *account, int *months, int *days)
 
void xaccAccountSetReconcileLastInterval (Account *account, int months, int days)
 
gboolean xaccAccountGetReconcilePostponeDate (const Account *account, time64 *postpone_date)
 
void xaccAccountSetReconcilePostponeDate (Account *account, time64 postpone_date)
 
gboolean xaccAccountGetReconcilePostponeBalance (const Account *account, gnc_numeric *balance)
 
void xaccAccountSetReconcilePostponeBalance (Account *account, gnc_numeric balance)
 
void xaccAccountClearReconcilePostpone (Account *account)
 

Account Placeholder flag

gboolean xaccAccountGetPlaceholder (const Account *account)
 
void xaccAccountSetPlaceholder (Account *account, gboolean val)
 
GNCPlaceholderType xaccAccountGetDescendantPlaceholder (const Account *account)
 

Account Hidden flag

gboolean xaccAccountGetHidden (const Account *acc)
 
void xaccAccountSetHidden (Account *acc, gboolean val)
 
gboolean xaccAccountIsHidden (const Account *acc)
 

Account Tax related getters/setters

gboolean xaccAccountGetTaxRelated (const Account *account)
 
void xaccAccountSetTaxRelated (Account *account, gboolean tax_related)
 
const char * xaccAccountGetTaxUSCode (const Account *account)
 
void xaccAccountSetTaxUSCode (Account *account, const char *code)
 
const char * xaccAccountGetTaxUSPayerNameSource (const Account *account)
 
void xaccAccountSetTaxUSPayerNameSource (Account *account, const char *source)
 
gint64 xaccAccountGetTaxUSCopyNumber (const Account *account)
 
void xaccAccountSetTaxUSCopyNumber (Account *account, gint64 copy_number)
 

Account marking

void xaccAccountSetMark (Account *account, short mark)
 
void xaccClearMark (Account *account, short val)
 
void xaccClearMarkDown (Account *account, short val)
 

Staged Traversal

The following functions provide support for "staged traversals" over all of the transactions in an account or group. The idea is to be able to perform a sequence of traversals ("stages"), and perform an operation on each transaction exactly once for that stage.

Only transactions whose current "stage" is less than the stage of the current traversal will be affected, and they will be "brought up" to the current stage when they are processed.

For example, you could perform a stage 1 traversal of all the transactions in an account, and then perform a stage 1 traversal of the transactions in a second account. Presuming the traversal of the first account didn't abort prematurely, any transactions shared by both accounts would be ignored during the traversal of the second account since they had been processed while traversing the first account.

However, if you had traversed the second account using a stage of 2, then all the transactions in the second account would have been processed.

Traversal can be aborted by having the callback function return a non-zero value. The traversal is aborted immediately, and the non-zero value is returned. Note that an aborted traversal can be restarted; no information is lost due to an abort.

The initial impetus for this particular approach came from generalizing a mark/sweep practice that was already being used in FileIO.c.

Note that currently, there is a hard limit of 256 stages, which can be changed by enlarging "marker" in the transaction struct.

void gnc_account_tree_begin_staged_transaction_traversals (Account *acc)
 
void xaccSplitsBeginStagedTransactionTraversals (SplitList *splits)
 
void xaccAccountBeginStagedTransactionTraversals (const Account *account)
 
gboolean xaccTransactionTraverse (Transaction *trans, int stage)
 
int xaccAccountStagedTransactionTraversal (const Account *a, unsigned int stage, TransactionCallback thunk, void *data)
 
int gnc_account_tree_staged_transaction_traversal (const Account *account, unsigned int stage, TransactionCallback thunk, void *data)
 
int xaccAccountTreeForEachTransaction (Account *acc, TransactionCallback proc, void *data)
 

Deprecated Routines.

void DxaccAccountSetCurrency (Account *account, gnc_commodity *currency)
 
gnc_commodityDxaccAccountGetCurrency (const Account *account)
 
void dxaccAccountSetQuoteTZ (Account *account, const char *tz)
 
const char * dxaccAccountGetQuoteTZ (const Account *account)
 

Account parameter names

#define ACCOUNT_KVP   "kvp"
 
#define ACCOUNT_NAME_   "name"
 
#define ACCOUNT_CODE_   "code"
 
#define ACCOUNT_DESCRIPTION_   "desc"
 
#define ACCOUNT_COLOR_   "color"
 
#define ACCOUNT_FILTER_   "filter"
 
#define ACCOUNT_SORT_ORDER_   "sort-order"
 
#define ACCOUNT_NOTES_   "notes"
 
#define ACCOUNT_BALANCE_   "balance"
 
#define ACCOUNT_CLEARED_   "cleared"
 
#define ACCOUNT_RECONCILED_   "reconciled"
 
#define ACCOUNT_PRESENT_   "present"
 
#define ACCOUNT_FUTURE_MINIMUM_   "future-minimum"
 
#define ACCOUNT_TAX_RELATED   "tax-related-p"
 
#define ACCOUNT_TYPE_   "account-type"
 
#define ACCOUNT_SCU   "smallest-commodity-unit"
 
#define ACCOUNT_NSCU   "non-standard-scu"
 
#define ACCOUNT_PARENT   "parent-account"
 

QofLogModule identifiers

#define GNC_MOD_ROOT   "gnc"
 
#define GNC_MOD_ENGINE   "gnc.engine"
 
#define GNC_MOD_ACCOUNT   "gnc.account"
 
#define GNC_MOD_SX   "gnc.engine.sx"
 
#define GNC_MOD_QUERY   "gnc.query"
 
#define GNC_MOD_SCRUB   "gnc.scrub"
 
#define GNC_MOD_LOT   "gnc.lots"
 
#define GNC_MOD_COMMODITY   "gnc.commodity"
 
#define GNC_MOD_BACKEND   "gnc.backend"
 
#define GNC_MOD_PRICE   "gnc.pricedb"
 
#define GNC_MOD_BUSINESS   "gnc.business"
 
#define GNC_MOD_IO   "gnc.io"
 
#define GNC_MOD_BOOK   "gnc.book-period"
 
#define GNC_MOD_GUI   "gnc.gui"
 
#define GNC_MOD_GUI_SX   "gnc.gui.sx"
 
#define GNC_MOD_GUILE   "gnc.guile"
 
#define GNC_MOD_LEDGER   "gnc.ledger"
 
#define GNC_MOD_REGISTER   "gnc.register"
 
#define GNC_MOD_HTML   "gnc.html"
 
#define GNC_MOD_PREFS   "gnc.pref"
 
#define GNC_MOD_IMPORT   "gnc.import"
 
#define GNC_MOD_ASSISTANT   "gnc.assistant"
 
#define GNC_MOD_TEST   "gnc.tests"
 
#define GNC_MOD_BUDGET   "gnc.budget"
 

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.

Macro Definition 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 1438 of file Account.h.

#define GNC_INVOICE_ID   "gncInvoice"

STRING CONSTANTS ********************************************** Used to declare constant KVP keys used in more than one class

Definition at line 257 of file gnc-engine.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 972 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.

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 implementation 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 referred 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 1125 of file Account.h.

1126 {
1127  PLACEHOLDER_NONE,
1128  PLACEHOLDER_THIS,
1129  PLACEHOLDER_CHILD,
GNCPlaceholderType
Definition: Account.h:1125

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 3128 of file Account.c.

3129 {
3130  KvpValue *v;
3131  const char *s;
3133 
3134  if (!acc) return NULL;
3135 
3136  v = kvp_frame_get_slot(acc->inst.kvp_data, "old-currency");
3137  if (!v) return NULL;
3138 
3139  s = kvp_value_get_string (v);
3140  if (!s) return NULL;
3141 
3143 
3144  return gnc_commodity_table_lookup_unique (table, s);
3145 }
gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book)
QofBook * qof_instance_get_book(gconstpointer)
char * kvp_value_get_string(const KvpValue *value)
struct KvpValueImpl KvpValue
Definition: kvp_frame.h:80
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 4627 of file Account.c.

4628 {
4629  if (!acc) return NULL;
4630 
4631  if (xaccAccountIsPriced(acc))
4632  {
4633  KvpValue *value = kvp_frame_get_slot(acc->inst.kvp_data, "old-quote-tz");
4634  if (value) return (kvp_value_get_string(value));
4635  }
4636  return NULL;
4637 }
gboolean xaccAccountIsPriced(const Account *acc)
Definition: Account.c:4249
char * kvp_value_get_string(const KvpValue *value)
struct KvpValueImpl KvpValue
Definition: kvp_frame.h:80
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 2498 of file Account.c.

2499 {
2500  QofBook *book;
2501  const char *string;
2502  gnc_commodity *commodity;
2503 
2504  if ((!acc) || (!currency)) return;
2505 
2506  xaccAccountBeginEdit(acc);
2507  string = gnc_commodity_get_unique_name (currency);
2508  kvp_frame_set_slot_nc(acc->inst.kvp_data, "old-currency",
2509  kvp_value_new_string(string));
2510  mark_account (acc);
2511  xaccAccountCommitEdit(acc);
2512 
2513  commodity = DxaccAccountGetCurrency (acc);
2514  if (!commodity)
2515  {
2516  book = qof_instance_get_book(acc);
2518  }
2519 }
gnc_commodity * gnc_commodity_table_insert(gnc_commodity_table *table, gnc_commodity *comm)
gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book)
gnc_commodity * DxaccAccountGetCurrency(const Account *acc)
Definition: Account.c:3128
QofBook * qof_instance_get_book(gconstpointer)
void kvp_frame_set_slot_nc(KvpFrame *frame, const gchar *key, KvpValue *value)
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
const char * gnc_commodity_get_unique_name(const gnc_commodity *cm)
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
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 4607 of file Account.c.

4608 {
4609  if (!acc) return;
4610 
4611  xaccAccountBeginEdit(acc);
4612  if (xaccAccountIsPriced(acc))
4613  {
4614  kvp_frame_set_slot_nc(acc->inst.kvp_data,
4615  "old-quote-tz",
4616  tz ? kvp_value_new_string(tz) : NULL);
4617  mark_account (acc);
4618  }
4619  qof_instance_set_dirty(&acc->inst);
4620  xaccAccountCommitEdit(acc);
4621 }
gboolean xaccAccountIsPriced(const Account *acc)
Definition: Account.c:4249
void kvp_frame_set_slot_nc(KvpFrame *frame, const gchar *key, KvpValue *value)
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
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 2836 of file Account.c.

2837 {
2838  AccountPrivate *cpriv, *ppriv;
2839  Account *child, *result;
2840  GList *node;
2841 
2842  g_return_val_if_fail(GNC_IS_ACCOUNT(parent), NULL);
2843  g_return_val_if_fail(code, NULL);
2844 
2845  /* first, look for accounts hanging off the current node */
2846  ppriv = GET_PRIVATE(parent);
2847  for (node = ppriv->children; node; node = node->next)
2848  {
2849  child = node->data;
2850  cpriv = GET_PRIVATE(child);
2851  if (g_strcmp0(cpriv->accountCode, code) == 0)
2852  return child;
2853  }
2854 
2855  /* if we are still here, then we haven't found the account yet.
2856  * Recursively search each of the child accounts next */
2857  for (node = ppriv->children; node; node = node->next)
2858  {
2859  child = node->data;
2860  result = gnc_account_lookup_by_code (child, code);
2861  if (result)
2862  return result;
2863  }
2864 
2865  return NULL;
2866 }
Account * gnc_account_lookup_by_code(const Account *parent, const char *code)
Definition: Account.c:2836
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 2915 of file Account.c.

2917 {
2918  const AccountPrivate *rpriv;
2919  const Account *root;
2920  Account *found;
2921  gchar **names;
2922 
2923  g_return_val_if_fail(GNC_IS_ACCOUNT(any_acc), NULL);
2924  g_return_val_if_fail(name, NULL);
2925 
2926  root = any_acc;
2927  rpriv = GET_PRIVATE(root);
2928  while (rpriv->parent)
2929  {
2930  root = rpriv->parent;
2931  rpriv = GET_PRIVATE(root);
2932  }
2933  names = g_strsplit(name, gnc_get_account_separator_string(), -1);
2934  found = gnc_account_lookup_by_full_name_helper(root, names);
2935  g_strfreev(names);
2936  return found;
2937 }
const gchar * gnc_get_account_separator_string(void)
Definition: Account.c:129
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 2803 of file Account.c.

2804 {
2805  AccountPrivate *cpriv, *ppriv;
2806  Account *child, *result;
2807  GList *node;
2808 
2809  g_return_val_if_fail(GNC_IS_ACCOUNT(parent), NULL);
2810  g_return_val_if_fail(name, NULL);
2811 
2812  /* first, look for accounts hanging off the current node */
2813  ppriv = GET_PRIVATE(parent);
2814  for (node = ppriv->children; node; node = node->next)
2815  {
2816  child = node->data;
2817  cpriv = GET_PRIVATE(child);
2818  if (g_strcmp0(cpriv->accountName, name) == 0)
2819  return child;
2820  }
2821 
2822  /* if we are still here, then we haven't found the account yet.
2823  * Recursively search each of the child accounts next */
2824  for (node = ppriv->children; node; node = node->next)
2825  {
2826  child = node->data;
2827  result = gnc_account_lookup_by_name (child, name);
2828  if (result)
2829  return result;
2830  }
2831 
2832  return NULL;
2833 }
Account * gnc_account_lookup_by_name(const Account *parent, const char *name)
Definition: Account.c:2803
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 4889 of file Account.c.

4890 {
4891  GList *descendants;
4892 
4893  descendants = gnc_account_get_descendants(account);
4894  g_list_foreach(descendants, (GFunc)do_one_account, NULL);
4895  g_list_free(descendants);
4896 }
GList * gnc_account_get_descendants(const Account *account)
Definition: Account.c:2755
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 4939 of file Account.c.

4943 {
4944  const AccountPrivate *priv;
4945  GList *acc_p, *split_p;
4946  Transaction *trans;
4947  Split *s;
4948  int retval;
4949 
4950  if (!acc) return 0;
4951 
4952  /* depth first traversal */
4953  priv = GET_PRIVATE(acc);
4954  for (acc_p = priv->children; acc_p; acc_p = g_list_next(acc_p))
4955  {
4956  retval = gnc_account_tree_staged_transaction_traversal(acc_p->data, stage,
4957  thunk, cb_data);
4958  if (retval) return retval;
4959  }
4960 
4961  /* Now this account */
4962  for (split_p = priv->splits; split_p; split_p = g_list_next(split_p))
4963  {
4964  s = split_p->data;
4965  trans = s->parent;
4966  if (trans && (trans->marker < stage))
4967  {
4968  trans->marker = stage;
4969  if (thunk)
4970  {
4971  retval = thunk(trans, cb_data);
4972  if (retval) return retval;
4973  }
4974  }
4975  }
4976 
4977  return 0;
4978 }
int gnc_account_tree_staged_transaction_traversal(const Account *acc, unsigned int stage, TransactionCallback thunk, void *cb_data)
Definition: Account.c:4939
Definition: SplitP.h:71
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.

198 {
199  g_error_cb = cb;
200  g_error_cb_data = data;
201 }
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.

174 {
175  engine_init_hooks = g_list_append(engine_init_hooks, (gpointer)h);
176 }
void gnc_engine_init ( int  argc,
char **  argv 
)

PROTOTYPES 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.

140 {
141  gnc_engine_init_part1();
142  gnc_engine_init_part2();
143  gnc_engine_init_part3(argc, argv);
144 }
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.

148 {
149  gnc_engine_init_part1();
150  gnc_engine_init_part3(argc, argv);
151 }
gboolean gnc_engine_is_initialized ( void  )

check the engine is fully initialized

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

180 {
181  return (engine_is_initialized == 1) ? TRUE : FALSE;
182 }
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.

161 {
163  qof_close();
164  engine_is_initialized = 0;
165 }
void qof_log_shutdown(void)
void qof_close(void)
Safely close down the Query Object Framework.
void gnc_log_default ( void  )

enable default log modules

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

190 {
191  qof_log_set_default(QOF_LOG_WARNING);
192  qof_log_set_level(GNC_MOD_ROOT, QOF_LOG_WARNING);
193  qof_log_set_level(GNC_MOD_TEST, QOF_LOG_DEBUG);
194 }
void qof_log_set_level(QofLogModule module, QofLogLevel level)
void qof_log_set_default(QofLogLevel log_level)
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 4851 of file Account.c.

4852 {
4853  AccountPrivate *priv;
4854 
4855  if (!account)
4856  return;
4857  priv = GET_PRIVATE(account);
4859 }
void xaccSplitsBeginStagedTransactionTraversals(GList *splits)
Definition: Account.c:4835
void xaccAccountClearReconcilePostpone ( Account account)

DOCUMENT ME!

Definition at line 4423 of file Account.c.

4424 {
4425  if (!acc) return;
4426 
4427  xaccAccountBeginEdit (acc);
4428  kvp_frame_set_value (acc->inst.kvp_data, "reconcile-info/postpone", NULL);
4429  mark_account (acc);
4430  xaccAccountCommitEdit (acc);
4431 }
KvpFrame * kvp_frame_set_value(KvpFrame *frame, const gchar *path, const KvpValue *value)
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
gint64 xaccAccountCountSplits ( const Account acc,
gboolean  include_children 
)

The xaccAccountCountSplits() routine returns the number of all the splits in the account.

Parameters
accthe account for which to count the splits
include_childrenalso count splits in descendants (TRUE) or for this account only (FALSE).

Definition at line 3725 of file Account.c.

3726 {
3727  gint64 nr, i;
3728 
3729  nr = 0;
3730  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), 0);
3731 
3732  nr = g_list_length(xaccAccountGetSplitList(acc));
3733  if (include_children && (gnc_account_n_children(acc) != 0))
3734  {
3735  for (i=0; i < gnc_account_n_children(acc); i++)
3736  {
3737  nr += xaccAccountCountSplits(gnc_account_nth_child(acc, i), TRUE);
3738  }
3739  }
3740  return nr;
3741 }
SplitList * xaccAccountGetSplitList(const Account *acc)
Definition: Account.c:3717
gint gnc_account_n_children(const Account *account)
Definition: Account.c:2676
gint64 xaccAccountCountSplits(const Account *acc, gboolean include_children)
Definition: Account.c:3725
Account * gnc_account_nth_child(const Account *parent, gint num)
Definition: Account.c:2691
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 3751 of file Account.c.

3755 {
3756  AccountPrivate *priv;
3757  GList *lot_list;
3758  GList *retval = NULL;
3759 
3760  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
3761 
3762  priv = GET_PRIVATE(acc);
3763  for (lot_list = priv->lots; lot_list; lot_list = lot_list->next)
3764  {
3765  GNCLot *lot = lot_list->data;
3766 
3767  /* If this lot is closed, then ignore it */
3768  if (gnc_lot_is_closed (lot))
3769  continue;
3770 
3771  if (match_func && !(match_func)(lot, user_data))
3772  continue;
3773 
3774  /* Ok, this is a valid lot. Add it to our list of lots */
3775  if (sort_func)
3776  retval = g_list_insert_sorted (retval, lot, sort_func);
3777  else
3778  retval = g_list_prepend (retval, lot);
3779  }
3780 
3781  return retval;
3782 }
gboolean gnc_lot_is_closed(GNCLot *lot)
Definition: gnc-lot.c:376
Split* xaccAccountFindSplitByDesc ( const Account account,
const char *  description 
)

Returns a pointer to the split, not a copy.

Definition at line 4711 of file Account.c.

4712 {
4713  Split *split;
4714 
4715  /* Get the split which has a transaction matching the description. */
4716  finder_help_function(acc, description, &split, NULL);
4717  return split;
4718 }
Definition: SplitP.h:71
Transaction* xaccAccountFindTransByDesc ( const Account account,
const char *  description 
)

Returns a pointer to the transaction, not a copy.

Definition at line 4726 of file Account.c.

4727 {
4728  Transaction *trans;
4729 
4730  /* Get the translation matching the description. */
4731  finder_help_function(acc, description, NULL, &trans);
4732  return trans;
4733 }
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 guaranteed 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 4996 of file Account.c.

4998 {
4999  if (!acc || !proc) return 0;
5001  return xaccAccountStagedTransactionTraversal(acc, 42, proc, data);
5002 }
void xaccAccountBeginStagedTransactionTraversals(const Account *account)
Definition: Account.c:4851
int xaccAccountStagedTransactionTraversal(const Account *acc, unsigned int stage, TransactionCallback thunk, void *cb_data)
Definition: Account.c:4899
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 3935 of file Account.c.

3936 {
3937  GList *descendants, *node;
3938  GNCPlaceholderType ret = PLACEHOLDER_NONE;
3939 
3940  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), PLACEHOLDER_NONE);
3941  if (xaccAccountGetPlaceholder(acc)) return PLACEHOLDER_THIS;
3942 
3943  descendants = gnc_account_get_descendants(acc);
3944  for (node = descendants; node; node = node->next)
3945  if (xaccAccountGetPlaceholder((Account *) node->data))
3946  {
3947  ret = PLACEHOLDER_CHILD;
3948  break;
3949  }
3950 
3951  g_list_free(descendants);
3952  return ret;
3953 }
GList * gnc_account_get_descendants(const Account *account)
Definition: Account.c:2755
GNCPlaceholderType
Definition: Account.h:1125
gboolean xaccAccountGetPlaceholder(const Account *acc)
Definition: Account.c:3912
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
accThe account whose flag should be retrieved.
Returns
The current state of the account's "hidden" flag.

Definition at line 3959 of file Account.c.

3960 {
3961  const char *str;
3962 
3963  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
3964 
3965  str = kvp_frame_get_string(acc->inst.kvp_data, "hidden");
3966  return (str && !strcmp(str, "true"));
3967 }
LotList* xaccAccountGetLotList ( const Account account)

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

Parameters
accountThe 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 3744 of file Account.c.

3745 {
3746  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
3747  return g_list_copy(GET_PRIVATE(acc)->lots);
3748 }
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
accountThe account whose flag should be retrieved.
Returns
The current state of the account's "placeholder" flag.

Definition at line 3912 of file Account.c.

3913 {
3914  const char *str;
3915 
3916  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
3917 
3918  str = kvp_frame_get_string(acc->inst.kvp_data, "placeholder");
3919  return (str && !strcmp(str, "true"));
3920 }
gboolean xaccAccountGetReconcileLastDate ( const Account account,
time64 last_date 
)

DOCUMENT ME!

Definition at line 4264 of file Account.c.

4265 {
4266  KvpValue *v;
4267 
4268  if (!acc) return FALSE;
4269 
4270  v = kvp_frame_get_value(acc->inst.kvp_data, "reconcile-info/last-date");
4271 
4272  if (!v || kvp_value_get_type(v) != KVP_TYPE_GINT64)
4273  return FALSE;
4274 
4275  if (last_date)
4276  *last_date = kvp_value_get_gint64(v);
4277 
4278  return TRUE;
4279 }
gint64 kvp_value_get_gint64(const KvpValue *value)
struct KvpValueImpl KvpValue
Definition: kvp_frame.h:80
gboolean xaccAccountGetReconcileLastInterval ( const Account account,
int *  months,
int *  days 
)

DOCUMENT ME!

Definition at line 4300 of file Account.c.

4302 {
4303  KvpValue *v1, *v2;
4304 
4305  if (!acc) return FALSE;
4306 
4307  v1 = kvp_frame_get_value(acc->inst.kvp_data,
4308  "reconcile-info/last-interval/months");
4309  v2 = kvp_frame_get_value(acc->inst.kvp_data,
4310  "reconcile-info/last-interval/days");
4311  if (!v1 || (kvp_value_get_type (v1) != KVP_TYPE_GINT64) ||
4312  !v2 || (kvp_value_get_type (v2) != KVP_TYPE_GINT64))
4313  return FALSE;
4314 
4315  if (months)
4316  *months = kvp_value_get_gint64 (v1);
4317  if (days)
4318  *days = kvp_value_get_gint64 (v2);
4319  return TRUE;
4320 }
gint64 kvp_value_get_gint64(const KvpValue *value)
struct KvpValueImpl KvpValue
Definition: kvp_frame.h:80
gboolean xaccAccountGetReconcilePostponeBalance ( const Account account,
gnc_numeric balance 
)

DOCUMENT ME!

Definition at line 4385 of file Account.c.

4387 {
4388  KvpValue *v;
4389 
4390  if (!acc) return FALSE;
4391 
4392  v = kvp_frame_get_value(acc->inst.kvp_data,
4393  "reconcile-info/postpone/balance");
4394  if (!v || kvp_value_get_type (v) != KVP_TYPE_NUMERIC)
4395  return FALSE;
4396 
4397  if (balance)
4398  *balance = kvp_value_get_numeric (v);
4399 
4400  return TRUE;
4401 }
struct KvpValueImpl KvpValue
Definition: kvp_frame.h:80
gboolean xaccAccountGetReconcilePostponeDate ( const Account account,
time64 postpone_date 
)

DOCUMENT ME!

Definition at line 4348 of file Account.c.

4349 {
4350  KvpValue *v;
4351 
4352  if (!acc) return FALSE;
4353 
4354  v = kvp_frame_get_value(acc->inst.kvp_data, "reconcile-info/postpone/date");
4355  if (!v || kvp_value_get_type (v) != KVP_TYPE_GINT64)
4356  return FALSE;
4357 
4358  if (postpone_date)
4359  *postpone_date = kvp_value_get_gint64 (v);
4360 
4361  return TRUE;
4362 }
gint64 kvp_value_get_gint64(const KvpValue *value)
struct KvpValueImpl KvpValue
Definition: kvp_frame.h:80
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 3717 of file Account.c.

3718 {
3719  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
3720  xaccAccountSortSplits((Account*)acc, FALSE); // normally a noop
3721  return GET_PRIVATE(acc)->splits;
3722 }
void xaccAccountSortSplits(Account *acc, gboolean force)
Definition: Account.c:1781
gboolean xaccAccountGetTaxRelated ( const Account account)

DOCUMENT ME!

Definition at line 3808 of file Account.c.

3809 {
3810  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
3811  return kvp_frame_get_gint64(acc->inst.kvp_data, "tax-related");
3812 }
const char* xaccAccountGetTaxUSCode ( const Account account)

DOCUMENT ME!

Definition at line 3833 of file Account.c.

3834 {
3835  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
3836  return kvp_frame_get_string(acc->inst.kvp_data, "tax-US/code");
3837 }
gint64 xaccAccountGetTaxUSCopyNumber ( const Account account)

DOCUMENT ME!

Definition at line 3876 of file Account.c.

3877 {
3878  gint64 copy_number;
3879 
3880  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), 1);
3881  copy_number = kvp_frame_get_gint64(acc->inst.kvp_data,
3882  "tax-US/copy-number");
3883  return (copy_number == 0) ? 1 : copy_number;
3884 }
const char* xaccAccountGetTaxUSPayerNameSource ( const Account account)

DOCUMENT ME!

Definition at line 3856 of file Account.c.

3857 {
3858  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
3859  return kvp_frame_get_string(acc->inst.kvp_data,
3860  "tax-US/payer-name-source");
3861 }
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 4137 of file Account.c.

4138 {
4139  if (type < 0 || NUM_ACCOUNT_TYPES <= type ) return "";
4140  return _(account_type_name [type]);
4141 }
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 1920 of file Account.c.

1921 {
1922  AccountPrivate *priv, *opriv;
1923  Account * old_acc = NULL;
1924  Account* lot_account;
1925 
1926  /* errors */
1927  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1928  g_return_if_fail(GNC_IS_LOT(lot));
1929 
1930  /* optimizations */
1931  lot_account = gnc_lot_get_account(lot);
1932  if (lot_account == acc)
1933  return;
1934 
1935  ENTER ("(acc=%p, lot=%p)", acc, lot);
1936 
1937  /* pull it out of the old account */
1938  if (lot_account)
1939  {
1940  old_acc = lot_account;
1941  opriv = GET_PRIVATE(old_acc);
1942  opriv->lots = g_list_remove(opriv->lots, lot);
1943  }
1944 
1945  priv = GET_PRIVATE(acc);
1946  priv->lots = g_list_prepend(priv->lots, lot);
1947  gnc_lot_set_account(lot, acc);
1948 
1949  /* Don't move the splits to the new account. The caller will do this
1950  * if appropriate, and doing it here will not work if we are being
1951  * called from gnc_book_close_period since xaccAccountInsertSplit
1952  * will try to balance capital gains and things aren't ready for that. */
1953 
1954  qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_ADD, NULL);
1955  qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, NULL);
1956 
1957  LEAVE ("(acc=%p, lot=%p)", acc, lot);
1958 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
Account * gnc_lot_get_account(const GNCLot *lot)
Definition: gnc-lot.c:386
void qof_event_gen(QofInstance *entity, QofEventId event_type, gpointer event_data)
Invoke all registered event handlers using the given arguments.
gboolean xaccAccountIsAPARType ( GNCAccountType  t)

Convenience function to check if the account is a valid business account type (meaning an Accounts Payable/Accounts Receivable).

Definition at line 4225 of file Account.c.

4226 {
4227  switch (t)
4228  {
4229  case ACCT_TYPE_RECEIVABLE:
4230  case ACCT_TYPE_PAYABLE:
4231  return TRUE;
4232  default:
4233  return FALSE;
4234  }
4235 }
gboolean xaccAccountIsAssetLiabType ( GNCAccountType  t)

Convenience function to check if the account is a valid Asset or Liability type, but not a business account type (meaning not an Accounts Payable/Accounts Receivable).

Definition at line 4212 of file Account.c.

4213 {
4214  switch (t)
4215  {
4216  case ACCT_TYPE_RECEIVABLE:
4217  case ACCT_TYPE_PAYABLE:
4218  return FALSE;
4219  default:
4222  }
4223 }
gboolean xaccAccountTypesCompatible(GNCAccountType parent_type, GNCAccountType child_type)
Definition: Account.c:4194
gboolean xaccAccountIsEquityType ( GNCAccountType  t)

Convenience function to check if the account is a valid Equity type.

Definition at line 4237 of file Account.c.

4238 {
4239  switch (t)
4240  {
4241  case ACCT_TYPE_EQUITY:
4242  return TRUE;
4243  default:
4244  return FALSE;
4245  }
4246 }
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
accThe account whose flag should be retrieved.
Returns
Whether or not this account should be "hidden".

Definition at line 3982 of file Account.c.

3983 {
3984  AccountPrivate *priv;
3985 
3986  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
3987 
3988  if (xaccAccountGetHidden(acc))
3989  return TRUE;
3990  priv = GET_PRIVATE(acc);
3991  while ((acc = priv->parent) != NULL)
3992  {
3993  priv = GET_PRIVATE(acc);
3994  if (xaccAccountGetHidden(acc))
3995  return TRUE;
3996  }
3997  return FALSE;
3998 }
gboolean xaccAccountGetHidden(const Account *acc)
Definition: Account.c:3959
void xaccAccountMoveAllSplits ( Account accfrom,
Account accto 
)

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

Definition at line 1980 of file Account.c.

1981 {
1982  AccountPrivate *from_priv;
1983 
1984  /* errors */
1985  g_return_if_fail(GNC_IS_ACCOUNT(accfrom));
1986  g_return_if_fail(GNC_IS_ACCOUNT(accto));
1987 
1988  /* optimizations */
1989  from_priv = GET_PRIVATE(accfrom);
1990  if (!from_priv->splits || accfrom == accto)
1991  return;
1992 
1993  /* check for book mix-up */
1994  g_return_if_fail (qof_instance_books_equal(accfrom, accto));
1995  ENTER ("(accfrom=%p, accto=%p)", accfrom, accto);
1996 
1997  xaccAccountBeginEdit(accfrom);
1998  xaccAccountBeginEdit(accto);
1999  /* Begin editing both accounts and all transactions in accfrom. */
2000  g_list_foreach(from_priv->splits, (GFunc)xaccPreSplitMove, NULL);
2001 
2002  /* Concatenate accfrom's lists of splits and lots to accto's lists. */
2003  //to_priv->splits = g_list_concat(to_priv->splits, from_priv->splits);
2004  //to_priv->lots = g_list_concat(to_priv->lots, from_priv->lots);
2005 
2006  /* Set appropriate flags. */
2007  //from_priv->balance_dirty = TRUE;
2008  //from_priv->sort_dirty = FALSE;
2009  //to_priv->balance_dirty = TRUE;
2010  //to_priv->sort_dirty = TRUE;
2011 
2012  /*
2013  * Change each split's account back pointer to accto.
2014  * Convert each split's amount to accto's commodity.
2015  * Commit to editing each transaction.
2016  */
2017  g_list_foreach(from_priv->splits, (GFunc)xaccPostSplitMove, (gpointer)accto);
2018 
2019  /* Finally empty accfrom. */
2020  g_assert(from_priv->splits == NULL);
2021  g_assert(from_priv->lots == NULL);
2022  xaccAccountCommitEdit(accfrom);
2023  xaccAccountCommitEdit(accto);
2024 
2025  LEAVE ("(accfrom=%p, accto=%p)", accfrom, accto);
2026 }
#define ENTER(format, args...)
Definition: qoflog.h:261
gboolean qof_instance_books_equal(gconstpointer ptr1, gconstpointer ptr2)
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
#define LEAVE(format, args...)
Definition: qoflog.h:271
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
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
accThe account whose flag should be retrieved.
valThe new state for the account's "hidden" flag.

Definition at line 3970 of file Account.c.

3971 {
3972  g_return_if_fail(GNC_IS_ACCOUNT(acc));
3973 
3974  xaccAccountBeginEdit (acc);
3975  kvp_frame_set_string (acc->inst.kvp_data, "hidden",
3976  val ? "true" : NULL);
3977  mark_account (acc);
3978  xaccAccountCommitEdit (acc);
3979 }
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
void kvp_frame_set_string(KvpFrame *frame, const gchar *path, const gchar *str)
Store a copy of the string at the indicated path.
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 1839 of file Account.c.

1840 {
1841  AccountPrivate *priv;
1842 
1843  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1844 
1845  priv = GET_PRIVATE(acc);
1846  priv->mark = m;
1847 }
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
accountThe account whose flag should be retrieved.
valThe new state for the account's "placeholder" flag.

Definition at line 3923 of file Account.c.

3924 {
3925  g_return_if_fail(GNC_IS_ACCOUNT(acc));
3926 
3927  xaccAccountBeginEdit (acc);
3928  kvp_frame_set_string (acc->inst.kvp_data,
3929  "placeholder", val ? "true" : NULL);
3930  mark_account (acc);
3931  xaccAccountCommitEdit (acc);
3932 }
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
void kvp_frame_set_string(KvpFrame *frame, const gchar *path, const gchar *str)
Store a copy of the string at the indicated path.
void xaccAccountSetReconcileLastDate ( Account account,
time64  last_date 
)

DOCUMENT ME!

Definition at line 4285 of file Account.c.

4286 {
4287  if (!acc) return;
4288 
4289  xaccAccountBeginEdit (acc);
4290  kvp_frame_set_gint64 (acc->inst.kvp_data,
4291  "/reconcile-info/last-date", last_date);
4292  mark_account (acc);
4293  xaccAccountCommitEdit (acc);
4294 }
void kvp_frame_set_gint64(KvpFrame *frame, const gchar *path, gint64 ival)
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
void xaccAccountSetReconcileLastInterval ( Account account,
int  months,
int  days 
)

DOCUMENT ME!

Definition at line 4326 of file Account.c.

4327 {
4328  KvpFrame *frame;
4329  if (!acc) return;
4330 
4331  xaccAccountBeginEdit (acc);
4332 
4333  frame = kvp_frame_get_frame_slash (acc->inst.kvp_data,
4334  "/reconcile-info/last-interval");
4335  g_assert(frame);
4336 
4337  kvp_frame_set_gint64 (frame, "months", months);
4338  kvp_frame_set_gint64 (frame, "days", days);
4339 
4340  mark_account (acc);
4341  xaccAccountCommitEdit (acc);
4342 }
void kvp_frame_set_gint64(KvpFrame *frame, const gchar *path, gint64 ival)
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
struct KvpFrameImpl KvpFrame
Definition: kvp_frame.h:76
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
void xaccAccountSetReconcilePostponeBalance ( Account account,
gnc_numeric  balance 
)

DOCUMENT ME!

Definition at line 4407 of file Account.c.

4408 {
4409  if (!acc) return;
4410 
4411  xaccAccountBeginEdit (acc);
4412  kvp_frame_set_gnc_numeric (acc->inst.kvp_data,
4413  "/reconcile-info/postpone/balance", balance);
4414  mark_account (acc);
4415  xaccAccountCommitEdit (acc);
4416 }
#define kvp_frame_set_gnc_numeric
Definition: kvp_frame.h:170
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
void xaccAccountSetReconcilePostponeDate ( Account account,
time64  postpone_date 
)

DOCUMENT ME!

Definition at line 4368 of file Account.c.

4369 {
4370  if (!acc) return;
4371 
4372  xaccAccountBeginEdit (acc);
4373 
4374  /* XXX this should be using timespecs, not gints !! */
4375  kvp_frame_set_gint64 (acc->inst.kvp_data,
4376  "reconcile-info/postpone/date", postpone_date);
4377  mark_account (acc);
4378  xaccAccountCommitEdit (acc);
4379 }
void kvp_frame_set_gint64(KvpFrame *frame, const gchar *path, gint64 ival)
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
void xaccAccountSetTaxRelated ( Account account,
gboolean  tax_related 
)

DOCUMENT ME!

Definition at line 3815 of file Account.c.

3816 {
3817  KvpValue *new_value;
3818 
3819  g_return_if_fail(GNC_IS_ACCOUNT(acc));
3820 
3821  if (tax_related)
3822  new_value = kvp_value_new_gint64 (tax_related);
3823  else
3824  new_value = NULL;
3825 
3826  xaccAccountBeginEdit (acc);
3827  kvp_frame_set_slot_nc(acc->inst.kvp_data, "tax-related", new_value);
3828  mark_account (acc);
3829  xaccAccountCommitEdit (acc);
3830 }
void kvp_frame_set_slot_nc(KvpFrame *frame, const gchar *key, KvpValue *value)
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
struct KvpValueImpl KvpValue
Definition: kvp_frame.h:80
void xaccAccountSetTaxUSCode ( Account account,
const char *  code 
)

DOCUMENT ME!

Definition at line 3840 of file Account.c.

3841 {
3842  g_return_if_fail(GNC_IS_ACCOUNT(acc));
3843 
3844  xaccAccountBeginEdit (acc);
3845  kvp_frame_set_string (acc->inst.kvp_data, "/tax-US/code", code);
3846  if (!code)
3847  {
3848  KvpFrame *frame = NULL;
3849  kvp_frame_set_frame (acc->inst.kvp_data, "/tax-US", frame);
3850  }
3851  mark_account (acc);
3852  xaccAccountCommitEdit (acc);
3853 }
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
struct KvpFrameImpl KvpFrame
Definition: kvp_frame.h:76
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
void kvp_frame_set_string(KvpFrame *frame, const gchar *path, const gchar *str)
Store a copy of the string at the indicated path.
void xaccAccountSetTaxUSCopyNumber ( Account account,
gint64  copy_number 
)

DOCUMENT ME!

Definition at line 3887 of file Account.c.

3888 {
3889  g_return_if_fail(GNC_IS_ACCOUNT(acc));
3890 
3891  xaccAccountBeginEdit (acc);
3892  if (copy_number != 0)
3893  kvp_frame_set_gint64 (acc->inst.kvp_data, "/tax-US/copy-number", copy_number);
3894  else
3895  {
3896  KvpFrame * frame;
3897  KvpValue *value;
3898 
3899  value = NULL;
3900  frame = kvp_frame_set_value_nc (acc->inst.kvp_data,
3901  "/tax-US/copy-number", value);
3902  if (!frame) kvp_value_delete (value);
3903  }
3904  mark_account (acc);
3905  xaccAccountCommitEdit (acc);
3906 }
void kvp_frame_set_gint64(KvpFrame *frame, const gchar *path, gint64 ival)
KvpFrame * kvp_frame_set_value_nc(KvpFrame *frame, const gchar *path, KvpValue *value)
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
struct KvpFrameImpl KvpFrame
Definition: kvp_frame.h:76
void kvp_value_delete(KvpValue *value)
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
struct KvpValueImpl KvpValue
Definition: kvp_frame.h:80
void xaccAccountSetTaxUSPayerNameSource ( Account account,
const char *  source 
)

DOCUMENT ME!

Definition at line 3864 of file Account.c.

3865 {
3866  g_return_if_fail(GNC_IS_ACCOUNT(acc));
3867 
3868  xaccAccountBeginEdit (acc);
3869  kvp_frame_set_string (acc->inst.kvp_data,
3870  "/tax-US/payer-name-source", source);
3871  mark_account (acc);
3872  xaccAccountCommitEdit (acc);
3873 }
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
void kvp_frame_set_string(KvpFrame *frame, const gchar *path, const gchar *str)
Store a copy of the string at the indicated path.
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 4899 of file Account.c.

4903 {
4904  AccountPrivate *priv;
4905  GList *split_p;
4906  GList *next;
4907  Transaction *trans;
4908  Split *s;
4909  int retval;
4910 
4911  if (!acc) return 0;
4912 
4913  priv = GET_PRIVATE(acc);
4914  for (split_p = priv->splits; split_p; split_p = next)
4915  {
4916  /* Get the next element in the split list now, just in case some
4917  * naughty thunk destroys the one we're using. This reduces, but
4918  * does not eliminate, the possibility of undefined results if
4919  * a thunk removes splits from this account. */
4920  next = g_list_next(split_p);
4921 
4922  s = split_p->data;
4923  trans = s->parent;
4924  if (trans && (trans->marker < stage))
4925  {
4926  trans->marker = stage;
4927  if (thunk)
4928  {
4929  retval = thunk(trans, cb_data);
4930  if (retval) return retval;
4931  }
4932  }
4933  }
4934 
4935  return 0;
4936 }
Definition: SplitP.h:71
GNCAccountType xaccAccountStringToEnum ( const char *  str)

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

Definition at line 4098 of file Account.c.

4099 {
4100  GNCAccountType type;
4101  gboolean rc;
4102  rc = xaccAccountStringToType(str, &type);
4103  if (FALSE == rc) return ACCT_TYPE_INVALID;
4104  return type;
4105 }
gboolean xaccAccountStringToType(const char *str, GNCAccountType *type)
Definition: Account.c:4064
GNCAccountType
Definition: Account.h:96
gboolean xaccAccountStringToType ( const char *  str,
GNCAccountType type 
)

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

Definition at line 4064 of file Account.c.

4065 {
4066 
4067  GNC_RETURN_ON_MATCH(NONE);
4068  GNC_RETURN_ON_MATCH(BANK);
4069  GNC_RETURN_ON_MATCH(CASH);
4070  GNC_RETURN_ON_MATCH(CREDIT);
4071  GNC_RETURN_ON_MATCH(ASSET);
4072  GNC_RETURN_ON_MATCH(LIABILITY);
4073  GNC_RETURN_ON_MATCH(STOCK);
4074  GNC_RETURN_ON_MATCH(MUTUAL);
4075  GNC_RETURN_ON_MATCH(CURRENCY);
4076  GNC_RETURN_ON_MATCH(INCOME);
4077  GNC_RETURN_ON_MATCH(EXPENSE);
4078  GNC_RETURN_ON_MATCH(EQUITY);
4079  GNC_RETURN_ON_MATCH(RECEIVABLE);
4080  GNC_RETURN_ON_MATCH(PAYABLE);
4081  GNC_RETURN_ON_MATCH(ROOT);
4082  GNC_RETURN_ON_MATCH(TRADING);
4083  GNC_RETURN_ON_MATCH(CHECKING);
4084  GNC_RETURN_ON_MATCH(SAVINGS);
4085  GNC_RETURN_ON_MATCH(MONEYMRKT);
4086  GNC_RETURN_ON_MATCH(CREDITLINE);
4087 
4088  PERR("asked to translate unknown account type string %s.\n",
4089  str ? str : "(null)");
4090 
4091  return(FALSE);
4092 }
#define PERR(format, args...)
Definition: qoflog.h:237
int xaccAccountTreeForEachTransaction ( Account acc,
TransactionCallback  proc,
void *  data 
)

Traverse all of the transactions in the given account group. Continue processing IF 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 IF 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 persistent storage, communications. These strings should not be translated to the local language. Typical conversion is ACCT_TYPE_INCOME -> "INCOME".

Definition at line 4027 of file Account.c.

4028 {
4029  switch (type)
4030  {
4031  GNC_RETURN_ENUM_AS_STRING(NONE);
4032  GNC_RETURN_ENUM_AS_STRING(BANK);
4033  GNC_RETURN_ENUM_AS_STRING(CASH);
4034  GNC_RETURN_ENUM_AS_STRING(CREDIT);
4035  GNC_RETURN_ENUM_AS_STRING(ASSET);
4036  GNC_RETURN_ENUM_AS_STRING(LIABILITY);
4037  GNC_RETURN_ENUM_AS_STRING(STOCK);
4038  GNC_RETURN_ENUM_AS_STRING(MUTUAL);
4039  GNC_RETURN_ENUM_AS_STRING(CURRENCY);
4040  GNC_RETURN_ENUM_AS_STRING(INCOME);
4041  GNC_RETURN_ENUM_AS_STRING(EXPENSE);
4042  GNC_RETURN_ENUM_AS_STRING(EQUITY);
4043  GNC_RETURN_ENUM_AS_STRING(RECEIVABLE);
4044  GNC_RETURN_ENUM_AS_STRING(PAYABLE);
4045  GNC_RETURN_ENUM_AS_STRING(ROOT);
4046  GNC_RETURN_ENUM_AS_STRING(TRADING);
4047  GNC_RETURN_ENUM_AS_STRING(CHECKING);
4048  GNC_RETURN_ENUM_AS_STRING(SAVINGS);
4049  GNC_RETURN_ENUM_AS_STRING(MONEYMRKT);
4050  GNC_RETURN_ENUM_AS_STRING(CREDITLINE);
4051  default:
4052  PERR ("asked to translate unknown account type %d.\n", type);
4053  break;
4054  }
4055  return(NULL);
4056 }
#define PERR(format, args...)
Definition: qoflog.h:237
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 4194 of file Account.c.

4196 {
4197  return ((xaccParentAccountTypesCompatibleWith (parent_type) &
4198  (1 << child_type))
4199  != 0);
4200 }
guint32 xaccParentAccountTypesCompatibleWith(GNCAccountType type)
Definition: Account.c:4147
guint32 xaccAccountTypesValid ( void  )

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

Definition at line 4203 of file Account.c.

4204 {
4205  guint32 mask = (1 << NUM_ACCOUNT_TYPES) - 1;
4206  mask &= ~((1 << ACCT_TYPE_CURRENCY) | /* DEPRECATED */
4207  (1 << ACCT_TYPE_ROOT)); /* ROOT */
4208 
4209  return mask;
4210 }
void xaccClearMark ( Account account,
short  val 
)

Get the mark set by xaccAccountSetMark short xaccAccountGetMark (const Account *account); The xaccClearMark will find the root account, and clear the mark in the entire account tree.

Definition at line 1850 of file Account.c.

1851 {
1852  Account *root;
1853 
1854  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1855 
1856  root = gnc_account_get_root(acc);
1857  xaccClearMarkDown(root ? root : acc, val);
1858 }
void xaccClearMarkDown(Account *acc, short val)
Definition: Account.c:1861
Account * gnc_account_get_root(Account *acc)
Definition: Account.c:2630
void xaccClearMarkDown ( Account account,
short  val 
)

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

Definition at line 1861 of file Account.c.

1862 {
1863  AccountPrivate *priv;
1864  GList *node;
1865 
1866  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1867 
1868  priv = GET_PRIVATE(acc);
1869  priv->mark = val;
1870  for (node = priv->children; node; node = node->next)
1871  {
1872  xaccClearMarkDown(node->data, val);
1873  }
1874 }
void xaccClearMarkDown(Account *acc, short val)
Definition: Account.c:1861
guint32 xaccParentAccountTypesCompatibleWith ( GNCAccountType  type)

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

Definition at line 4147 of file Account.c.

4148 {
4149  switch (type)
4150  {
4151  case ACCT_TYPE_BANK:
4152  case ACCT_TYPE_CASH:
4153  case ACCT_TYPE_ASSET:
4154  case ACCT_TYPE_STOCK:
4155  case ACCT_TYPE_MUTUAL:
4156  case ACCT_TYPE_CURRENCY:
4157  case ACCT_TYPE_CREDIT:
4158  case ACCT_TYPE_LIABILITY:
4159  case ACCT_TYPE_RECEIVABLE:
4160  case ACCT_TYPE_PAYABLE:
4161  return
4162  (1 << ACCT_TYPE_BANK) |
4163  (1 << ACCT_TYPE_CASH) |
4164  (1 << ACCT_TYPE_ASSET) |
4165  (1 << ACCT_TYPE_STOCK) |
4166  (1 << ACCT_TYPE_MUTUAL) |
4167  (1 << ACCT_TYPE_CURRENCY) |
4168  (1 << ACCT_TYPE_CREDIT) |
4169  (1 << ACCT_TYPE_LIABILITY) |
4170  (1 << ACCT_TYPE_RECEIVABLE) |
4171  (1 << ACCT_TYPE_PAYABLE) |
4172  (1 << ACCT_TYPE_ROOT);
4173  case ACCT_TYPE_INCOME:
4174  case ACCT_TYPE_EXPENSE:
4175  return
4176  (1 << ACCT_TYPE_INCOME) |
4177  (1 << ACCT_TYPE_EXPENSE) |
4178  (1 << ACCT_TYPE_ROOT);
4179  case ACCT_TYPE_EQUITY:
4180  return
4181  (1 << ACCT_TYPE_EQUITY) |
4182  (1 << ACCT_TYPE_ROOT);
4183  case ACCT_TYPE_TRADING:
4184  return
4185  (1 << ACCT_TYPE_TRADING) |
4186  (1 << ACCT_TYPE_ROOT);
4187  default:
4188  PERR("bad account type: %d", type);
4189  return 0;
4190  }
4191 }
#define PERR(format, args...)
Definition: qoflog.h:237
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 4835 of file Account.c.

4836 {
4837  GList *lp;
4838 
4839  for (lp = splits; lp; lp = lp->next)
4840  {
4841  Split *s = lp->data;
4842  Transaction *trans = s->parent;
4843 
4844  if (trans)
4845  trans->marker = 0;
4846  }
4847 }
Definition: SplitP.h:71
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 4862 of file Account.c.

4863 {
4864  if (trans == NULL) return FALSE;
4865 
4866  if (trans->marker < stage)
4867  {
4868  trans->marker = stage;
4869  return TRUE;
4870  }
4871 
4872  return FALSE;
4873 }