GnuCash  2.7.0
Modules | Files | Data Structures | Macros | Typedefs | Enumerations | Functions
GnuCash Engine: Core, Non-GUI Accounting Functions

The GnuCash Engine provides a set of objects and classes that encapsulate typical financial accounting concepts. More...

Modules

 Environment
 The API in this file is used to read the environment configuration file and set up a number of environment variables based on the values found in it.
 
 Generic Preference Utilities
 The only function in this file is meant to initialize the preferences system early in the load process.
 
 
 Cap Gains
 This file implements the various routines to automatically compute and handle Cap Gains/Losses resulting from trading activities.
 
 Commodities
 A commodity is something of value that is easily tradeable or sellable; for example, currencies, stocks, bonds, grain, copper, and oil are all commodities.
 
 Lots: Core Function for AR/AP, Inventory, Stock Lots, Cap Gains
 One often needs to know that the item 'bought' in one transaction is the same one as the item 'sold' in a different transaction.
 
 Price Database
 The PriceDB is intended to be a database of price quotes, or more specifically, a database of GNCPrices.
 
 Prices
 Each price in the database represents an "instantaneous" quote for a given commodity with respect to another commodity.
 
 Business
 The Business Engine provides a set of structures for that provide small-business accounting features.
 
 Accounting Policy (FIFO/LIFO)
 This file implements Accounting Policy.
 
 Scheduled/Periodic/Recurring Transactions
 Scheduled Transactions provide a framework for remembering information about a transactions that are set to occur in the future, either once or periodically.
 
 Data Validation
 Data scrubbing, repairing and forward migration routines.
 
 Transaction, Split
 A good overview of transactions, splits and accounts can be found in the texinfo documentation, together with an overview of how to use this API.
 
 Transaction Logging
 The transaction logging mechanism provides a very simple, low-level logging of user input to a file.
 

Files

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

Data Structures

struct  GncImapInfo
 

Macros

#define ACCOUNT_MATCH_ALL_TYPE   "account-match-all"
 This is the type-override when you want to match all accounts. More...
 
#define GNC_ID_NONE   QOF_ID_NONE
 IDENTIFIERS GncGUID Identifiers can be used to reference Accounts, Transactions, Splits and other objects. More...
 
#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"
 STRING CONSTANTS ********************************************** Used to declare constant KVP keys used in more than one class.
 
#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 GList AccountList
 GList of Account.
 
typedef GList LotList
 GList of GNCLots.
 
typedef GList SplitList
 GList of Split.
 
typedef GList TransList
 GList of Transaction.
 
typedef GList AccountGUIDList
 GList of GUIDs of a Account.
 
typedef GList BookGUIDList
 GList of GUIDs of a QofBook.
 
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 **)
 Function type for init hooks in the engine. More...
 

Enumerations

enum  GNCPlaceholderType { PLACEHOLDER_NONE, PLACEHOLDER_THIS, PLACEHOLDER_CHILD }
 DOCUMENT ME!
 

Functions

void gnc_engine_init (int argc, char **argv)
 PROTOTYPES. More...
 
void gnc_engine_init_static (int argc, char **argv)
 This is the statically linked-in version of gnc_engine_init. More...
 
void gnc_engine_shutdown (void)
 Called to shutdown the engine. More...
 
gboolean gnc_engine_is_initialized (void)
 check the engine is fully initialized
 
void gnc_log_default (void)
 enable default log modules
 
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.
 
void gnc_engine_add_commit_error_callback (EngineCommitErrorCallback cb, gpointer data)
 Set a callback function to be called in case an engine commit fails.
 
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)
 The gnc_account_lookup_by_name() subroutine fetches the account by name from the descendants of the specified account. More...
 
Accountgnc_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.
 
Accountgnc_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.
 

GNCAccountType conversion/checking

const char * xaccAccountTypeEnumAsString (GNCAccountType type)
 Conversion routines for the account types to/from strings that are used in persistent storage, communications. More...
 
gboolean xaccAccountStringToType (const char *str, GNCAccountType *type)
 Conversion routines for the account types to/from strings that are used in persistent storage, communications. More...
 
GNCAccountType xaccAccountStringToEnum (const char *str)
 Conversion routines for the account types to/from strings that are used in persistent storage, communications. More...
 
const char * xaccAccountGetTypeStr (GNCAccountType type)
 The xaccAccountGetTypeStr() routine returns a string suitable for use in the GUI/Interface. More...
 
guint32 xaccAccountTypesCompatibleWith (GNCAccountType type)
 Return the bitmask of account types compatible with a given type. More...
 
guint32 xaccParentAccountTypesCompatibleWith (GNCAccountType type)
 Return the bitmask of parent account types compatible with a given type. More...
 
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. More...
 
guint32 xaccAccountTypesValid (void)
 Returns the bitmask of the account type enums that are valid. More...
 
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). More...
 
gboolean xaccAccountIsAPARType (GNCAccountType t)
 Convenience function to check if the account is a valid business account type (meaning an Accounts Payable/Accounts Receivable). More...
 
gboolean xaccAccountIsEquityType (GNCAccountType t)
 Convenience function to check if the account is a valid Equity type. More...
 

Account split/transaction list management

SplitListxaccAccountGetSplitList (const Account *account)
 The xaccAccountGetSplitList() routine returns a pointer to a GList of the splits in the account. More...
 
gint64 xaccAccountCountSplits (const Account *acc, gboolean include_children)
 The xaccAccountCountSplits() routine returns the number of all the splits in the account. More...
 
void xaccAccountMoveAllSplits (Account *accfrom, Account *accto)
 The xaccAccountMoveAllSplits() routine reassigns each of the splits in accfrom to accto. More...
 
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. More...
 
Transaction * xaccAccountFindTransByDesc (const Account *account, const char *description)
 Returns a pointer to the transaction, not a copy. More...
 
Split * xaccAccountFindSplitByDesc (const Account *account, const char *description)
 Returns a pointer to the split, not a copy. More...
 
#define xaccAccountInsertSplit(acc, s)   xaccSplitSetAccount((s), (acc))
 The xaccAccountInsertSplit() method will insert the indicated split into the indicated account. More...
 

Account lots

void xaccAccountInsertLot (Account *, GNCLot *)
 The xaccAccountInsertLot() method will register the indicated lot with this account. More...
 
void xaccAccountRemoveLot (Account *, GNCLot *)
 
LotListxaccAccountGetLotList (const Account *account)
 The xaccAccountGetLotList() routine returns a list of all lots in this account. More...
 
gpointer xaccAccountForEachLot (const Account *acc, gpointer(*proc)(GNCLot *lot, gpointer user_data), gpointer user_data)
 The xaccAccountForEachLot() method will apply the function 'proc' to each lot in the account. More...
 
LotListxaccAccountFindOpenLots (const Account *acc, gboolean(*match_func)(GNCLot *lot, gpointer user_data), gpointer user_data, GCompareFunc sort_func)
 Find a list of open lots that match the match_func. More...
 

Account Reconciliation information getters/setters

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

Account Placeholder flag

gboolean xaccAccountGetPlaceholder (const Account *account)
 Get the "placeholder" flag for an account. More...
 
void xaccAccountSetPlaceholder (Account *account, gboolean val)
 Set the "placeholder" flag for an account. More...
 
GNCPlaceholderType xaccAccountGetDescendantPlaceholder (const Account *account)
 Returns PLACEHOLDER_NONE if account is NULL or neither account nor any descendant of account is a placeholder. More...
 

Account Hidden flag

gboolean xaccAccountGetHidden (const Account *acc)
 Get the "hidden" flag for an account. More...
 
void xaccAccountSetHidden (Account *acc, gboolean val)
 Set the "hidden" flag for an account. More...
 
gboolean xaccAccountIsHidden (const Account *acc)
 Should this account be "hidden". More...
 

Account Tax related getters/setters

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

Account marking

void xaccAccountSetMark (Account *account, short mark)
 Set a mark on the account. More...
 
void xaccClearMark (Account *account, short val)
 Get the mark set by xaccAccountSetMark short xaccAccountGetMark (const Account *account);. More...
 
void xaccClearMarkDown (Account *account, short val)
 The xaccClearMarkDown will clear the mark only in this and in sub-accounts. More...
 

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)
 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. More...
 
void xaccSplitsBeginStagedTransactionTraversals (SplitList *splits)
 xaccSplitsBeginStagedTransactionTraversals() resets the traversal marker for each transaction which is a parent of one of the splits in the list.
 
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.
 
gboolean xaccTransactionTraverse (Transaction *trans, int stage)
 xaccTransactionTraverse() checks the stage of the given transaction. More...
 
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. More...
 
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. More...
 
int xaccAccountTreeForEachTransaction (Account *acc, TransactionCallback proc, void *data)
 Traverse all of the transactions in the given account group. More...
 
GncImportMatchMapgnc_account_imap_create_imap (Account *acc)
 Obtain an ImportMatchMap object from an Account or a Book.
 
Accountgnc_account_imap_find_account (GncImportMatchMap *imap, const char *category, const char *key)
 
void gnc_account_imap_add_account (GncImportMatchMap *imap, const char *category, const char *key, Account *acc)
 
void gnc_account_imap_delete_account (GncImportMatchMap *imap, const char *category, const char *key)
 
Accountgnc_account_imap_find_account_bayes (GncImportMatchMap *imap, GList *tokens)
 Look up an Account in the map using Baysian. More...
 
void gnc_account_imap_add_account_bayes (GncImportMatchMap *imap, GList *tokens, Account *acc)
 Updates the imap for a given account using a list of tokens.
 
GList * gnc_account_imap_get_info_bayes (Account *acc)
 Returns a GList of structure imap_info of all Bayesian mappings for required Account.
 
GList * gnc_account_imap_get_info (Account *acc, const char *category)
 Returns a GList of structure imap_info of all Non Bayesian mappings for required Account.
 
gchar * gnc_account_get_map_entry (Account *acc, const char *full_category)
 Returns the text string pointed to by full_category for the Account, free the returned text.
 
void gnc_account_delete_map_entry (Account *acc, char *full_category, gboolean empty)
 Delete the entry for Account pointed to by full_category, if empty is TRUE then use delete if empty, full_category is freed.
 
void gnc_account_imap_convert_bayes (QofBook *book)
 Search for Bayesian entries with mappings based on full account name and change them to be based on the account guid.
 

Deprecated Routines.

void DxaccAccountSetCurrency (Account *account, gnc_commodity *currency)
 
gnc_commodity * DxaccAccountGetCurrency (const Account *account)
 
void dxaccAccountSetQuoteTZ (Account *account, const char *tz)
 Set the timezone to be used when interpreting the results from a given Finance::Quote backend. More...
 
const char * dxaccAccountGetQuoteTZ (const Account *account)
 Get the timezone to be used when interpreting the results from a given Finance::Quote backend. More...
 

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_SORT_REVERSED_   "sort-reversed"
 
#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

◆ ACCOUNT_MATCH_ALL_TYPE

#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 1518 of file Account.h.

◆ GNC_ID_NONE

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

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

◆ xaccAccountInsertSplit

#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 987 of file Account.h.

Typedef Documentation

◆ gnc_engine_init_hook_t

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.

Function Documentation

◆ DxaccAccountGetCurrency()

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

3137 {
3138  GValue v = G_VALUE_INIT;
3139  const char *s = NULL;
3140  gnc_commodity_table *table;
3141 
3142  if (!acc) return NULL;
3143  qof_instance_get_kvp (QOF_INSTANCE(acc), "old-currency", &v);
3144  if (G_VALUE_HOLDS_STRING (&v))
3145  s = g_value_get_string (&v);
3146  if (!s) return NULL;
3147 
3149 
3150  return gnc_commodity_table_lookup_unique (table, s);
3151 }
void qof_instance_get_kvp(const QofInstance *inst, const gchar *key, GValue *value)
Retrieves the contents of a KVP slot into a provided GValue.
gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book)
Returns the commodity table associated with a book.
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.

◆ dxaccAccountGetQuoteTZ()

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

4688 {
4689  GValue v = G_VALUE_INIT;
4690  if (!acc) return NULL;
4691  if (!xaccAccountIsPriced(acc)) return NULL;
4692  qof_instance_get_kvp (QOF_INSTANCE (acc), "old-quote-tz", &v);
4693  return G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL;
4694 }
void qof_instance_get_kvp(const QofInstance *inst, const gchar *key, GValue *value)
Retrieves the contents of a KVP slot into a provided GValue.
gboolean xaccAccountIsPriced(const Account *acc)
Returns true if the account is a stock, mutual fund or currency, otherwise false. ...
Definition: Account.c:4291

◆ DxaccAccountSetCurrency()

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

2496 {
2497  QofBook *book;
2498  GValue v = G_VALUE_INIT;
2499  const char *s = gnc_commodity_get_unique_name (currency);
2500  gnc_commodity *commodity;
2501  gnc_commodity_table *table;
2502 
2503  if ((!acc) || (!currency)) return;
2504  g_value_init (&v, G_TYPE_STRING);
2505  g_value_set_string (&v, s);
2506  qof_instance_set_kvp (QOF_INSTANCE (acc), "old-currency", &v);
2507  mark_account (acc);
2508  xaccAccountCommitEdit(acc);
2509 
2511  commodity = gnc_commodity_table_lookup_unique (table, s);
2512 
2513  if (!commodity)
2514  {
2515  book = qof_instance_get_book(acc);
2517  currency);
2518  }
2519 }
gnc_commodity * gnc_commodity_table_insert(gnc_commodity_table *table, gnc_commodity *comm)
Add a new commodity to the commodity table.
gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book)
Returns the commodity table associated with a book.
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.
const char * gnc_commodity_get_unique_name(const gnc_commodity *cm)
Retrieve the 'unique' name for the specified commodity.
void qof_instance_set_kvp(QofInstance *inst, const gchar *key, const GValue *value)
Sets a KVP slot to a value from a GValue.
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.c:1335

◆ dxaccAccountSetQuoteTZ()

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

4671 {
4672  GValue v = G_VALUE_INIT;
4673  if (!acc) return;
4674  if (!xaccAccountIsPriced(acc)) return;
4675  xaccAccountBeginEdit(acc);
4676  g_value_init (&v, G_TYPE_STRING);
4677  g_value_set_string (&v, tz);
4678  qof_instance_set_kvp (QOF_INSTANCE (acc), "old-quote-tz", &v);
4679  mark_account (acc);
4680  xaccAccountCommitEdit(acc);
4681 }
gboolean xaccAccountIsPriced(const Account *acc)
Returns true if the account is a stock, mutual fund or currency, otherwise false. ...
Definition: Account.c:4291
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition: Account.c:1294
void qof_instance_set_kvp(QofInstance *inst, const gchar *key, const GValue *value)
Sets a KVP slot to a value from a GValue.
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.c:1335

◆ gnc_account_imap_find_account_bayes()

Account* gnc_account_imap_find_account_bayes ( GncImportMatchMap imap,
GList *  tokens 
)

Look up an Account in the map using Baysian.

Look up an Account in the map using Baysian.

< holds the accounts and total token count for a single token

< pointer to the current token from the input GList tokens

< pointer to the struct account_token_count

< an account name and the number of times a token has appeared for the account

< intermediate storage of values to compute the bayes probability of an account

Definition at line 5303 of file Account.c.

5304 {
5305  struct token_accounts_info tokenInfo;
5307  GList *current_token;
5310  GList *current_account_token;
5312  struct account_token_count *account_c;
5315  struct account_probability *account_p;
5318  GHashTable *running_probabilities = g_hash_table_new(g_str_hash,
5319  g_str_equal);
5320  GHashTable *final_probabilities = g_hash_table_new(g_str_hash,
5321  g_str_equal);
5322  struct account_info account_i;
5323 
5324  ENTER(" ");
5325 
5326  /* check to see if the imap is NULL */
5327  if (!imap)
5328  {
5329  PINFO("imap is null, returning null");
5330  LEAVE(" ");
5331  return NULL;
5332  }
5333 
5334  /* find the probability for each account that contains any of the tokens
5335  * in the input tokens list
5336  */
5337  for (current_token = tokens; current_token;
5338  current_token = current_token->next)
5339  {
5340  char* path = g_strdup_printf (IMAP_FRAME_BAYES "/%s",
5341  (char*)current_token->data);
5342  /* zero out the token_accounts_info structure */
5343  memset(&tokenInfo, 0, sizeof(struct token_accounts_info));
5344 
5345  PINFO("token: '%s'", (char*)current_token->data);
5346 
5347  /* process the accounts for this token, adding the account if it
5348  * doesn't already exist or adding to the existing accounts token
5349  * count if it does
5350  */
5351  qof_instance_foreach_slot(QOF_INSTANCE (imap->acc), path,
5352  buildTokenInfo, &tokenInfo);
5353  g_free (path);
5354  /* for each account we have just found, see if the account
5355  * already exists in the list of account probabilities, if not
5356  * add it
5357  */
5358  for (current_account_token = tokenInfo.accounts; current_account_token;
5359  current_account_token = current_account_token->next)
5360  {
5361  /* get the account name and corresponding token count */
5362  account_c = (struct account_token_count*)current_account_token->data;
5363 
5364  PINFO("account_c->account_guid('%s'), "
5365  "account_c->token_count('%" G_GINT64_FORMAT
5366  "')/total_count('%" G_GINT64_FORMAT "')",
5367  account_c->account_guid, account_c->token_count,
5368  tokenInfo.total_count);
5369 
5370  account_p = g_hash_table_lookup(running_probabilities,
5371  account_c->account_guid);
5372 
5373  /* if the account exists in the list then continue
5374  * the running probablities
5375  */
5376  if (account_p)
5377  {
5378  account_p->product = (((double)account_c->token_count /
5379  (double)tokenInfo.total_count)
5380  * account_p->product);
5381  account_p->product_difference =
5382  ((double)1 - ((double)account_c->token_count /
5383  (double)tokenInfo.total_count))
5384  * account_p->product_difference;
5385  PINFO("product == %f, product_difference == %f",
5386  account_p->product, account_p->product_difference);
5387  }
5388  else
5389  {
5390  /* add a new entry */
5391  PINFO("adding a new entry for this account");
5392  account_p = (struct account_probability*)
5393  g_new0(struct account_probability, 1);
5394 
5395  /* set the product and product difference values */
5396  account_p->product = ((double)account_c->token_count /
5397  (double)tokenInfo.total_count);
5398  account_p->product_difference =
5399  (double)1 - ((double)account_c->token_count /
5400  (double)tokenInfo.total_count);
5401 
5402  PINFO("product == %f, product_difference == %f",
5403  account_p->product, account_p->product_difference);
5404 
5405  /* add the account guid and (struct account_probability*)
5406  * to the hash table */
5407  g_hash_table_insert(running_probabilities,
5408  account_c->account_guid, account_p);
5409  }
5410  } /* for all accounts in tokenInfo */
5411 
5412  /* free the data in tokenInfo */
5413  for (current_account_token = tokenInfo.accounts; current_account_token;
5414  current_account_token = current_account_token->next)
5415  {
5416  /* free up each struct account_token_count we allocated */
5417  g_free((struct account_token_count*)current_account_token->data);
5418  }
5419 
5420  g_list_free(tokenInfo.accounts); /* free the accounts GList */
5421  }
5422 
5423  /* build a hash table of account names and their final probabilities
5424  * from each entry in the running_probabilties hash table
5425  */
5426  g_hash_table_foreach(running_probabilities, buildProbabilities,
5427  final_probabilities);
5428 
5429  /* find the highest probabilty and the corresponding account */
5430  memset(&account_i, 0, sizeof(struct account_info));
5431  g_hash_table_foreach(final_probabilities, highestProbability, &account_i);
5432 
5433  /* free each element of the running_probabilities hash */
5434  g_hash_table_foreach(running_probabilities, freeProbabilities, NULL);
5435 
5436  /* free the hash tables */
5437  g_hash_table_destroy(running_probabilities);
5438  g_hash_table_destroy(final_probabilities);
5439 
5440  PINFO("highest P('%s') = '%d'",
5441  account_i.account_guid ? account_i.account_guid : "(null)",
5442  account_i.probability);
5443 
5444  /* has this probability met our threshold? */
5445  if (account_i.probability >= threshold)
5446  {
5447  GncGUID *guid;
5448  Account *account = NULL;
5449 
5450  PINFO("Probability has met threshold");
5451 
5452  guid = g_new (GncGUID, 1);
5453 
5454  if (string_to_guid (account_i.account_guid, guid))
5455  account = xaccAccountLookup (guid, imap->book);
5456 
5457  g_free (guid);
5458 
5459  if (account != NULL)
5460  LEAVE("Return account is '%s'", xaccAccountGetName (account));
5461  else
5462  LEAVE("Return NULL, account for Guid '%s' can not be found", account_i.account_guid);
5463 
5464  return account;
5465  }
5466  PINFO("Probability has not met threshold");
5467  LEAVE("Return NULL");
5468 
5469  return NULL; /* we didn't meet our threshold, return NULL for an account */
5470 }
#define PINFO(format, args...)
Print an informational note.
Definition: qoflog.h:249
holds an account guid and its corresponding integer probability the integer probability is some facto...
Definition: Account.c:5272
STRUCTS.
gboolean string_to_guid(const gchar *string, GncGUID *guid)
Given a string, replace the given guid with the parsed one unless the given value is null...
intermediate values used to calculate the bayes probability of a given account where p(AB) = (a*b)/[a...
Definition: Account.c:5228
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:261
total_count and the token_count for a given account let us calculate the probability of a given accou...
Definition: Account.c:5191
gint64 token_count
occurrences of a given token for this account_guid
Definition: Account.c:5185
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:271
const char * xaccAccountGetName(const Account *acc)
Get the account&#39;s name.
Definition: Account.c:3031
The type used to store guids in C.
Definition: guid.h:75
Account * xaccAccountLookup(const GncGUID *guid, QofBook *book)
The xaccAccountLookup() subroutine will return the account associated with the given id...
Definition: Account.c:1841

◆ gnc_account_lookup_by_name()

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 }
STRUCTS.
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 s...
Definition: Account.c:2803

◆ gnc_account_tree_begin_staged_transaction_traversals()

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

4955 {
4956  GList *descendants;
4957 
4958  descendants = gnc_account_get_descendants(account);
4959  g_list_foreach(descendants, (GFunc)do_one_account, NULL);
4960  g_list_free(descendants);
4961 }
GList * gnc_account_get_descendants(const Account *account)
This routine returns a flat list of all of the accounts that are descendants of the specified account...
Definition: Account.c:2755

◆ gnc_account_tree_staged_transaction_traversal()

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

5008 {
5009  const AccountPrivate *priv;
5010  GList *acc_p, *split_p;
5011  Transaction *trans;
5012  Split *s;
5013  int retval;
5014 
5015  if (!acc) return 0;
5016 
5017  /* depth first traversal */
5018  priv = GET_PRIVATE(acc);
5019  for (acc_p = priv->children; acc_p; acc_p = g_list_next(acc_p))
5020  {
5021  retval = gnc_account_tree_staged_transaction_traversal(acc_p->data, stage,
5022  thunk, cb_data);
5023  if (retval) return retval;
5024  }
5025 
5026  /* Now this account */
5027  for (split_p = priv->splits; split_p; split_p = g_list_next(split_p))
5028  {
5029  s = split_p->data;
5030  trans = s->parent;
5031  if (trans && (trans->marker < stage))
5032  {
5033  trans->marker = stage;
5034  if (thunk)
5035  {
5036  retval = thunk(trans, cb_data);
5037  if (retval) return retval;
5038  }
5039  }
5040  }
5041 
5042  return 0;
5043 }
int gnc_account_tree_staged_transaction_traversal(const Account *acc, unsigned int stage, TransactionCallback thunk, void *cb_data)
gnc_account_tree_staged_transaction_traversal() calls thunk on each transaction in the group whose cu...
Definition: Account.c:5004

◆ gnc_engine_init()

void gnc_engine_init ( int  argc,
char **  argv 
)

PROTOTYPES.

gnc_engine_init should be called before gnc engine functions can be used.

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

117 {
118  if (1 == engine_is_initialized) return;
119 
120  gnc_engine_init_part1();
121  gnc_engine_init_part2();
122  gnc_engine_init_part3(argc, argv);
123 }

◆ gnc_engine_init_static()

void gnc_engine_init_static ( int  argc,
char **  argv 
)

This is the statically linked-in version of gnc_engine_init.

It is identical to that function except that it doesn't load any backend library.

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

127 {
128  if (1 == engine_is_initialized) return;
129 
130  gnc_engine_init_part1();
131  gnc_engine_init_part3(argc, argv);
132 }

◆ gnc_engine_shutdown()

void gnc_engine_shutdown ( void  )

Called to shutdown the engine.

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

142 {
144  qof_close();
145  engine_is_initialized = 0;
146 }
void qof_log_shutdown(void)
Be nice, close the logfile if possible.
Definition: qoflog.cpp:204
void qof_close(void)
Safely close down the Query Object Framework.
Definition: qofutil.cpp:269

◆ xaccAccountCountSplits()

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

3732 {
3733  gint64 nr, i;
3734 
3735  nr = 0;
3736  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), 0);
3737 
3738  nr = g_list_length(xaccAccountGetSplitList(acc));
3739  if (include_children && (gnc_account_n_children(acc) != 0))
3740  {
3741  for (i=0; i < gnc_account_n_children(acc); i++)
3742  {
3743  nr += xaccAccountCountSplits(gnc_account_nth_child(acc, i), TRUE);
3744  }
3745  }
3746  return nr;
3747 }
SplitList * xaccAccountGetSplitList(const Account *acc)
The xaccAccountGetSplitList() routine returns a pointer to a GList of the splits in the account...
Definition: Account.c:3723
gint gnc_account_n_children(const Account *account)
Return the number of children of the specified account.
Definition: Account.c:2676
gint64 xaccAccountCountSplits(const Account *acc, gboolean include_children)
The xaccAccountCountSplits() routine returns the number of all the splits in the account.
Definition: Account.c:3731
Account * gnc_account_nth_child(const Account *parent, gint num)
Return the n&#39;th child account of the specified parent account.
Definition: Account.c:2691

◆ xaccAccountFindOpenLots()

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

3761 {
3762  AccountPrivate *priv;
3763  GList *lot_list;
3764  GList *retval = NULL;
3765 
3766  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
3767 
3768  priv = GET_PRIVATE(acc);
3769  for (lot_list = priv->lots; lot_list; lot_list = lot_list->next)
3770  {
3771  GNCLot *lot = lot_list->data;
3772 
3773  /* If this lot is closed, then ignore it */
3774  if (gnc_lot_is_closed (lot))
3775  continue;
3776 
3777  if (match_func && !(match_func)(lot, user_data))
3778  continue;
3779 
3780  /* Ok, this is a valid lot. Add it to our list of lots */
3781  if (sort_func)
3782  retval = g_list_insert_sorted (retval, lot, sort_func);
3783  else
3784  retval = g_list_prepend (retval, lot);
3785  }
3786 
3787  return retval;
3788 }
gboolean gnc_lot_is_closed(GNCLot *lot)
The gnc_lot_is_closed() routine returns a boolean flag: is this lot closed? A lot is closed if its ba...
Definition: gnc-lot.c:371

◆ xaccAccountFindSplitByDesc()

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

Returns a pointer to the split, not a copy.

Definition at line 4776 of file Account.c.

4777 {
4778  Split *split;
4779 
4780  /* Get the split which has a transaction matching the description. */
4781  finder_help_function(acc, description, &split, NULL);
4782  return split;
4783 }

◆ xaccAccountFindTransByDesc()

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

Returns a pointer to the transaction, not a copy.

Definition at line 4791 of file Account.c.

4792 {
4793  Transaction *trans;
4794 
4795  /* Get the translation matching the description. */
4796  finder_help_function(acc, description, NULL, &trans);
4797  return trans;
4798 }

◆ xaccAccountForEachLot()

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.

◆ xaccAccountForEachTransaction()

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

5063 {
5064  if (!acc || !proc) return 0;
5066  return xaccAccountStagedTransactionTraversal(acc, 42, proc, data);
5067 }
void xaccAccountBeginStagedTransactionTraversals(const Account *account)
xaccAccountBeginStagedTransactionTraversals() resets the traversal marker for each transaction which ...
Definition: Account.c:4916
int xaccAccountStagedTransactionTraversal(const Account *acc, unsigned int stage, TransactionCallback thunk, void *cb_data)
xaccAccountStagedTransactionTraversal() calls thunk on each transaction in account a whose current ma...
Definition: Account.c:4964

◆ xaccAccountGetDescendantPlaceholder()

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

3949 {
3950  GList *descendants, *node;
3951  GNCPlaceholderType ret = PLACEHOLDER_NONE;
3952 
3953  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), PLACEHOLDER_NONE);
3954  if (xaccAccountGetPlaceholder(acc)) return PLACEHOLDER_THIS;
3955 
3956  descendants = gnc_account_get_descendants(acc);
3957  for (node = descendants; node; node = node->next)
3958  if (xaccAccountGetPlaceholder((Account *) node->data))
3959  {
3960  ret = PLACEHOLDER_CHILD;
3961  break;
3962  }
3963 
3964  g_list_free(descendants);
3965  return ret;
3966 }
STRUCTS.
GList * gnc_account_get_descendants(const Account *account)
This routine returns a flat list of all of the accounts that are descendants of the specified account...
Definition: Account.c:2755
GNCPlaceholderType
DOCUMENT ME!
Definition: Account.h:1140
gboolean xaccAccountGetPlaceholder(const Account *acc)
Get the "placeholder" flag for an account.
Definition: Account.c:3936

◆ xaccAccountGetHidden()

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

3973 {
3974  return boolean_from_key (acc, "hidden");
3975 }

◆ xaccAccountGetLotList()

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

3751 {
3752  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
3753  return g_list_copy(GET_PRIVATE(acc)->lots);
3754 }

◆ xaccAccountGetPlaceholder()

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

3937 {
3938  return boolean_from_key(acc, "placeholder");
3939 }

◆ xaccAccountGetSplitList()

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

3724 {
3725  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
3726  xaccAccountSortSplits((Account*)acc, FALSE); // normally a noop
3727  return GET_PRIVATE(acc)->splits;
3728 }
STRUCTS.
void xaccAccountSortSplits(Account *acc, gboolean force)
The xaccAccountSortSplits() routine will resort the account&#39;s splits if the sort is dirty...
Definition: Account.c:1795

◆ xaccAccountGetTypeStr()

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

4140 {
4141  if (type < 0 || NUM_ACCOUNT_TYPES <= type ) return "";
4142  return _(account_type_name [type]);
4143 }
stop here; the following types just aren&#39;t ready for prime time
Definition: Account.h:161

◆ xaccAccountInsertLot()

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

1935 {
1936  AccountPrivate *priv, *opriv;
1937  Account * old_acc = NULL;
1938  Account* lot_account;
1939 
1940  /* errors */
1941  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1942  g_return_if_fail(GNC_IS_LOT(lot));
1943 
1944  /* optimizations */
1945  lot_account = gnc_lot_get_account(lot);
1946  if (lot_account == acc)
1947  return;
1948 
1949  ENTER ("(acc=%p, lot=%p)", acc, lot);
1950 
1951  /* pull it out of the old account */
1952  if (lot_account)
1953  {
1954  old_acc = lot_account;
1955  opriv = GET_PRIVATE(old_acc);
1956  opriv->lots = g_list_remove(opriv->lots, lot);
1957  }
1958 
1959  priv = GET_PRIVATE(acc);
1960  priv->lots = g_list_prepend(priv->lots, lot);
1961  gnc_lot_set_account(lot, acc);
1962 
1963  /* Don't move the splits to the new account. The caller will do this
1964  * if appropriate, and doing it here will not work if we are being
1965  * called from gnc_book_close_period since xaccAccountInsertSplit
1966  * will try to balance capital gains and things aren't ready for that. */
1967 
1968  qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_ADD, NULL);
1969  qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, NULL);
1970 
1971  LEAVE ("(acc=%p, lot=%p)", acc, lot);
1972 }
STRUCTS.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:261
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:271
Account * gnc_lot_get_account(const GNCLot *lot)
The gnc_lot_get_account() routine returns the account with which this lot is associated.
Definition: gnc-lot.c:381
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition: qofevent.cpp:234

◆ xaccAccountIsAPARType()

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

4268 {
4269  switch (t)
4270  {
4271  case ACCT_TYPE_RECEIVABLE:
4272  case ACCT_TYPE_PAYABLE:
4273  return TRUE;
4274  default:
4275  return FALSE;
4276  }
4277 }
A/P account type.
Definition: Account.h:151
A/R account type.
Definition: Account.h:149

◆ xaccAccountIsAssetLiabType()

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

4255 {
4256  switch (t)
4257  {
4258  case ACCT_TYPE_RECEIVABLE:
4259  case ACCT_TYPE_PAYABLE:
4260  return FALSE;
4261  default:
4264  }
4265 }
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: Account.c:4236
A/P account type.
Definition: Account.h:151
asset (and liability) accounts indicate generic, generalized accounts that are none of the above...
Definition: Account.h:116
liability (and asset) accounts indicate generic, generalized accounts that are none of the above...
Definition: Account.h:119
A/R account type.
Definition: Account.h:149

◆ xaccAccountIsEquityType()

gboolean xaccAccountIsEquityType ( GNCAccountType  t)

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

Definition at line 4279 of file Account.c.

4280 {
4281  switch (t)
4282  {
4283  case ACCT_TYPE_EQUITY:
4284  return TRUE;
4285  default:
4286  return FALSE;
4287  }
4288 }
Equity account is used to balance the balance sheet.
Definition: Account.h:146

◆ xaccAccountIsHidden()

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

3985 {
3986  AccountPrivate *priv;
3987 
3988  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
3989 
3990  if (xaccAccountGetHidden(acc))
3991  return TRUE;
3992  priv = GET_PRIVATE(acc);
3993  while ((acc = priv->parent) != NULL)
3994  {
3995  priv = GET_PRIVATE(acc);
3996  if (xaccAccountGetHidden(acc))
3997  return TRUE;
3998  }
3999  return FALSE;
4000 }
gboolean xaccAccountGetHidden(const Account *acc)
Get the "hidden" flag for an account.
Definition: Account.c:3972

◆ xaccAccountMoveAllSplits()

void xaccAccountMoveAllSplits ( Account accfrom,
Account accto 
)

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

Definition at line 1994 of file Account.c.

1995 {
1996  AccountPrivate *from_priv;
1997 
1998  /* errors */
1999  g_return_if_fail(GNC_IS_ACCOUNT(accfrom));
2000  g_return_if_fail(GNC_IS_ACCOUNT(accto));
2001 
2002  /* optimizations */
2003  from_priv = GET_PRIVATE(accfrom);
2004  if (!from_priv->splits || accfrom == accto)
2005  return;
2006 
2007  /* check for book mix-up */
2008  g_return_if_fail (qof_instance_books_equal(accfrom, accto));
2009  ENTER ("(accfrom=%p, accto=%p)", accfrom, accto);
2010 
2011  xaccAccountBeginEdit(accfrom);
2012  xaccAccountBeginEdit(accto);
2013  /* Begin editing both accounts and all transactions in accfrom. */
2014  g_list_foreach(from_priv->splits, (GFunc)xaccPreSplitMove, NULL);
2015 
2016  /* Concatenate accfrom's lists of splits and lots to accto's lists. */
2017  //to_priv->splits = g_list_concat(to_priv->splits, from_priv->splits);
2018  //to_priv->lots = g_list_concat(to_priv->lots, from_priv->lots);
2019 
2020  /* Set appropriate flags. */
2021  //from_priv->balance_dirty = TRUE;
2022  //from_priv->sort_dirty = FALSE;
2023  //to_priv->balance_dirty = TRUE;
2024  //to_priv->sort_dirty = TRUE;
2025 
2026  /*
2027  * Change each split's account back pointer to accto.
2028  * Convert each split's amount to accto's commodity.
2029  * Commit to editing each transaction.
2030  */
2031  g_list_foreach(from_priv->splits, (GFunc)xaccPostSplitMove, (gpointer)accto);
2032 
2033  /* Finally empty accfrom. */
2034  g_assert(from_priv->splits == NULL);
2035  g_assert(from_priv->lots == NULL);
2036  xaccAccountCommitEdit(accfrom);
2037  xaccAccountCommitEdit(accto);
2038 
2039  LEAVE ("(accfrom=%p, accto=%p)", accfrom, accto);
2040 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:261
gboolean qof_instance_books_equal(gconstpointer ptr1, gconstpointer ptr2)
See if two QofInstances share the same book.
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition: Account.c:1294
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:271
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.c:1335

◆ xaccAccountSetHidden()

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

3979 {
3980  set_boolean_key (acc, "hidden", val);
3981 }

◆ xaccAccountSetMark()

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

1854 {
1855  AccountPrivate *priv;
1856 
1857  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1858 
1859  priv = GET_PRIVATE(acc);
1860  priv->mark = m;
1861 }

◆ xaccAccountSetPlaceholder()

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

3943 {
3944  set_boolean_key(acc, "placeholder", val);
3945 }

◆ xaccAccountStagedTransactionTraversal()

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

4968 {
4969  AccountPrivate *priv;
4970  GList *split_p;
4971  GList *next;
4972  Transaction *trans;
4973  Split *s;
4974  int retval;
4975 
4976  if (!acc) return 0;
4977 
4978  priv = GET_PRIVATE(acc);
4979  for (split_p = priv->splits; split_p; split_p = next)
4980  {
4981  /* Get the next element in the split list now, just in case some
4982  * naughty thunk destroys the one we're using. This reduces, but
4983  * does not eliminate, the possibility of undefined results if
4984  * a thunk removes splits from this account. */
4985  next = g_list_next(split_p);
4986 
4987  s = split_p->data;
4988  trans = s->parent;
4989  if (trans && (trans->marker < stage))
4990  {
4991  trans->marker = stage;
4992  if (thunk)
4993  {
4994  retval = thunk(trans, cb_data);
4995  if (retval) return retval;
4996  }
4997  }
4998  }
4999 
5000  return 0;
5001 }

◆ xaccAccountStringToEnum()

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

4101 {
4102  GNCAccountType type;
4103  gboolean rc;
4104  rc = xaccAccountStringToType(str, &type);
4105  if (FALSE == rc) return ACCT_TYPE_INVALID;
4106  return type;
4107 }
gboolean xaccAccountStringToType(const char *str, GNCAccountType *type)
Conversion routines for the account types to/from strings that are used in persistent storage...
Definition: Account.c:4066
GNCAccountType
The account types are used to determine how the transaction data in the account is displayed...
Definition: Account.h:102
Not a type.
Definition: Account.h:104

◆ xaccAccountStringToType()

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

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

◆ xaccAccountTreeForEachTransaction()

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);

◆ xaccAccountTypeEnumAsString()

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

4030 {
4031  switch (type)
4032  {
4033  GNC_RETURN_ENUM_AS_STRING(NONE);
4034  GNC_RETURN_ENUM_AS_STRING(BANK);
4035  GNC_RETURN_ENUM_AS_STRING(CASH);
4036  GNC_RETURN_ENUM_AS_STRING(CREDIT);
4037  GNC_RETURN_ENUM_AS_STRING(ASSET);
4038  GNC_RETURN_ENUM_AS_STRING(LIABILITY);
4039  GNC_RETURN_ENUM_AS_STRING(STOCK);
4040  GNC_RETURN_ENUM_AS_STRING(MUTUAL);
4041  GNC_RETURN_ENUM_AS_STRING(CURRENCY);
4042  GNC_RETURN_ENUM_AS_STRING(INCOME);
4043  GNC_RETURN_ENUM_AS_STRING(EXPENSE);
4044  GNC_RETURN_ENUM_AS_STRING(EQUITY);
4045  GNC_RETURN_ENUM_AS_STRING(RECEIVABLE);
4046  GNC_RETURN_ENUM_AS_STRING(PAYABLE);
4047  GNC_RETURN_ENUM_AS_STRING(ROOT);
4048  GNC_RETURN_ENUM_AS_STRING(TRADING);
4049  GNC_RETURN_ENUM_AS_STRING(CHECKING);
4050  GNC_RETURN_ENUM_AS_STRING(SAVINGS);
4051  GNC_RETURN_ENUM_AS_STRING(MONEYMRKT);
4052  GNC_RETURN_ENUM_AS_STRING(CREDITLINE);
4053  default:
4054  PERR ("asked to translate unknown account type %d.\n", type);
4055  break;
4056  }
4057  return(NULL);
4058 }
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:237

◆ xaccAccountTypesCompatible()

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

4238 {
4239  return ((xaccParentAccountTypesCompatibleWith (parent_type) &
4240  (1 << child_type))
4241  != 0);
4242 }
guint32 xaccParentAccountTypesCompatibleWith(GNCAccountType type)
Return the bitmask of parent account types compatible with a given type.
Definition: Account.c:4189

◆ xaccAccountTypesCompatibleWith()

guint32 xaccAccountTypesCompatibleWith ( GNCAccountType  type)

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

That is, you could switch to any of the account types in the compatible list without unwanted side-effects.

Definition at line 4149 of file Account.c.

4150 {
4151  switch (type)
4152  {
4153  case ACCT_TYPE_BANK:
4154  case ACCT_TYPE_CASH:
4155  case ACCT_TYPE_ASSET:
4156  case ACCT_TYPE_CREDIT:
4157  case ACCT_TYPE_LIABILITY:
4158  case ACCT_TYPE_INCOME:
4159  case ACCT_TYPE_EXPENSE:
4160  case ACCT_TYPE_EQUITY:
4161  return
4162  (1 << ACCT_TYPE_BANK) |
4163  (1 << ACCT_TYPE_CASH) |
4164  (1 << ACCT_TYPE_ASSET) |
4165  (1 << ACCT_TYPE_CREDIT) |
4166  (1 << ACCT_TYPE_LIABILITY) |
4167  (1 << ACCT_TYPE_INCOME) |
4168  (1 << ACCT_TYPE_EXPENSE) |
4169  (1 << ACCT_TYPE_EQUITY);
4170  case ACCT_TYPE_STOCK:
4171  case ACCT_TYPE_MUTUAL:
4172  case ACCT_TYPE_CURRENCY:
4173  return
4174  (1 << ACCT_TYPE_STOCK) |
4175  (1 << ACCT_TYPE_MUTUAL) |
4176  (1 << ACCT_TYPE_CURRENCY);
4177  case ACCT_TYPE_RECEIVABLE:
4178  return (1 << ACCT_TYPE_RECEIVABLE);
4179  case ACCT_TYPE_PAYABLE:
4180  return (1 << ACCT_TYPE_PAYABLE);
4181  case ACCT_TYPE_TRADING:
4182  return (1 << ACCT_TYPE_TRADING);
4183  default:
4184  PERR("bad account type: %d", type);
4185  return 0;
4186  }
4187 }
Expense accounts are used to denote expenses.
Definition: Account.h:143
Mutual Fund accounts will typically be shown in registers which show three columns: price...
Definition: Account.h:125
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:237
The cash account type is used to denote a shoe-box or pillowcase stuffed with * cash.
Definition: Account.h:110
Account used to record multiple commodity transactions.
Definition: Account.h:155
Stock accounts will typically be shown in registers which show three columns: price, number of shares, and value.
Definition: Account.h:122
Income accounts are used to denote income.
Definition: Account.h:140
The bank account type denotes a savings or checking account held at a bank.
Definition: Account.h:107
A/P account type.
Definition: Account.h:151
asset (and liability) accounts indicate generic, generalized accounts that are none of the above...
Definition: Account.h:116
The currency account type indicates that the account is a currency trading account.
Definition: Account.h:129
liability (and asset) accounts indicate generic, generalized accounts that are none of the above...
Definition: Account.h:119
A/R account type.
Definition: Account.h:149
Equity account is used to balance the balance sheet.
Definition: Account.h:146
The Credit card account is used to denote credit (e.g.
Definition: Account.h:113

◆ xaccAccountTypesValid()

guint32 xaccAccountTypesValid ( void  )

Returns the bitmask of the account type enums that are valid.

Deprecated and root account types are stripped.

Definition at line 4245 of file Account.c.

4246 {
4247  guint32 mask = (1 << NUM_ACCOUNT_TYPES) - 1;
4248  mask &= ~((1 << ACCT_TYPE_CURRENCY) | /* DEPRECATED */
4249  (1 << ACCT_TYPE_ROOT)); /* ROOT */
4250 
4251  return mask;
4252 }
stop here; the following types just aren&#39;t ready for prime time
Definition: Account.h:161
The currency account type indicates that the account is a currency trading account.
Definition: Account.h:129
The hidden root account of an account tree.
Definition: Account.h:153

◆ xaccClearMark()

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

1865 {
1866  Account *root;
1867 
1868  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1869 
1870  root = gnc_account_get_root(acc);
1871  xaccClearMarkDown(root ? root : acc, val);
1872 }
STRUCTS.
void xaccClearMarkDown(Account *acc, short val)
The xaccClearMarkDown will clear the mark only in this and in sub-accounts.
Definition: Account.c:1875
Account * gnc_account_get_root(Account *acc)
This routine returns the root account of the account tree that the specified account belongs to...
Definition: Account.c:2630

◆ xaccClearMarkDown()

void xaccClearMarkDown ( Account account,
short  val 
)

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

Definition at line 1875 of file Account.c.

1876 {
1877  AccountPrivate *priv;
1878  GList *node;
1879 
1880  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1881 
1882  priv = GET_PRIVATE(acc);
1883  priv->mark = val;
1884  for (node = priv->children; node; node = node->next)
1885  {
1886  xaccClearMarkDown(node->data, val);
1887  }
1888 }
void xaccClearMarkDown(Account *acc, short val)
The xaccClearMarkDown will clear the mark only in this and in sub-accounts.
Definition: Account.c:1875

◆ xaccParentAccountTypesCompatibleWith()

guint32 xaccParentAccountTypesCompatibleWith ( GNCAccountType  type)

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

Definition at line 4189 of file Account.c.

4190 {
4191  switch (type)
4192  {
4193  case ACCT_TYPE_BANK:
4194  case ACCT_TYPE_CASH:
4195  case ACCT_TYPE_ASSET:
4196  case ACCT_TYPE_STOCK:
4197  case ACCT_TYPE_MUTUAL:
4198  case ACCT_TYPE_CURRENCY:
4199  case ACCT_TYPE_CREDIT:
4200  case ACCT_TYPE_LIABILITY:
4201  case ACCT_TYPE_RECEIVABLE:
4202  case ACCT_TYPE_PAYABLE:
4203  return
4204  (1 << ACCT_TYPE_BANK) |
4205  (1 << ACCT_TYPE_CASH) |
4206  (1 << ACCT_TYPE_ASSET) |
4207  (1 << ACCT_TYPE_STOCK) |
4208  (1 << ACCT_TYPE_MUTUAL) |
4209  (1 << ACCT_TYPE_CURRENCY) |
4210  (1 << ACCT_TYPE_CREDIT) |
4211  (1 << ACCT_TYPE_LIABILITY) |
4212  (1 << ACCT_TYPE_RECEIVABLE) |
4213  (1 << ACCT_TYPE_PAYABLE) |
4214  (1 << ACCT_TYPE_ROOT);
4215  case ACCT_TYPE_INCOME:
4216  case ACCT_TYPE_EXPENSE:
4217  return
4218  (1 << ACCT_TYPE_INCOME) |
4219  (1 << ACCT_TYPE_EXPENSE) |
4220  (1 << ACCT_TYPE_ROOT);
4221  case ACCT_TYPE_EQUITY:
4222  return
4223  (1 << ACCT_TYPE_EQUITY) |
4224  (1 << ACCT_TYPE_ROOT);
4225  case ACCT_TYPE_TRADING:
4226  return
4227  (1 << ACCT_TYPE_TRADING) |
4228  (1 << ACCT_TYPE_ROOT);
4229  default:
4230  PERR("bad account type: %d", type);
4231  return 0;
4232  }
4233 }
Expense accounts are used to denote expenses.
Definition: Account.h:143
Mutual Fund accounts will typically be shown in registers which show three columns: price...
Definition: Account.h:125
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:237
The cash account type is used to denote a shoe-box or pillowcase stuffed with * cash.
Definition: Account.h:110
Account used to record multiple commodity transactions.
Definition: Account.h:155
Stock accounts will typically be shown in registers which show three columns: price, number of shares, and value.
Definition: Account.h:122
Income accounts are used to denote income.
Definition: Account.h:140
The bank account type denotes a savings or checking account held at a bank.
Definition: Account.h:107
A/P account type.
Definition: Account.h:151
asset (and liability) accounts indicate generic, generalized accounts that are none of the above...
Definition: Account.h:116
The currency account type indicates that the account is a currency trading account.
Definition: Account.h:129
liability (and asset) accounts indicate generic, generalized accounts that are none of the above...
Definition: Account.h:119
A/R account type.
Definition: Account.h:149
Equity account is used to balance the balance sheet.
Definition: Account.h:146
The hidden root account of an account tree.
Definition: Account.h:153
The Credit card account is used to denote credit (e.g.
Definition: Account.h:113

◆ xaccTransactionTraverse()

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

4928 {
4929  if (trans == NULL) return FALSE;
4930 
4931  if (trans->marker < stage)
4932  {
4933  trans->marker = stage;
4934  return TRUE;
4935  }
4936 
4937  return FALSE;
4938 }