GnuCash  4.8a-176-g88ecf8dd1
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_by_code() subroutine works like gnc_account_lookup_by_name, but uses the account code.
 
Accountgnc_account_lookup_by_opening_balance (Account *account, gnc_commodity *commodity)
 Find the opening balance account for the currency. More...
 
GList * gnc_account_lookup_by_type_and_commodity (Account *root, const char *name, GNCAccountType acctype, gnc_commodity *commodity)
 Find a direct child account matching name, GNCAccountType, and/or commodity. More...
 

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...
 
GNCAccountType xaccAccountTypeGetFundamental (GNCAccountType t)
 Convenience function to return the fundamental type asset/liability/income/expense/equity given an account type. 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...
 
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...
 
gboolean xaccAccountGetIsOpeningBalance (const Account *account)
 Get the "opening-balance" flag for an account. More...
 
void xaccAccountSetIsOpeningBalance (Account *account, gboolean val)
 Set the "opening-balance" 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 Auto Interest flag

gboolean xaccAccountGetAutoInterest (const Account *acc)
 Get the "auto interest" flag for an account. More...
 
void xaccAccountSetAutoInterest (Account *acc, gboolean val)
 Set the "auto interest" flag for an account. 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 type debit/credit string getters

@ { *

const char * gnc_account_get_debit_string (GNCAccountType acct_type)
 Get the debit string associated with this account type.
 
const char * gnc_account_get_credit_string (GNCAccountType acct_type)
 Get the credit string associated with this account type.
 

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 *head, const char *category)
 Returns the text string pointed to by head and category for the Account, free the returned text.
 
void gnc_account_delete_map_entry (Account *acc, char *head, char *category, char *match_string, gboolean empty)
 Delete the entry for Account pointed to by head,category and match_string, if empty is TRUE then use delete if empty.
 
void gnc_account_delete_all_bayes_maps (Account *acc)
 Delete all bayes entries for Account.
 
void gnc_account_reset_convert_bayes_to_flat (void)
 Reset the flag that indicates the function imap_convert_bayes_to_flat has been run.
 

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_NOCLOSING_   "noclosing"
 
#define ACCOUNT_OPENING_BALANCE_   "opening-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_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 1617 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 95 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 1038 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 225 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 3383 of file Account.cpp.

3384 {
3385  GValue v = G_VALUE_INIT;
3386  const char *s = NULL;
3387  gnc_commodity_table *table;
3388  gnc_commodity *retval = NULL;
3389 
3390  if (!acc) return NULL;
3391  qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, {"old-currency"});
3392  if (G_VALUE_HOLDS_STRING (&v))
3393  s = g_value_get_string (&v);
3394  if (s)
3395  {
3397  retval = gnc_commodity_table_lookup_unique (table, s);
3398  }
3399  g_value_unset (&v);
3400 
3401  return retval;
3402 }
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. This function uses a static char*.

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

Definition at line 5004 of file Account.cpp.

5005 {
5006  static char *quote_tz = nullptr;
5007  if (!acc) return NULL;
5008  if (!xaccAccountIsPriced(acc)) return NULL;
5009  g_free (quote_tz);
5010  quote_tz = get_kvp_string_tag (acc, "old-quote-tz");
5011  return quote_tz;
5012 }
gboolean xaccAccountIsPriced(const Account *acc)
Returns true if the account is a stock, mutual fund or currency, otherwise false. ...
Definition: Account.cpp:4637

◆ 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 2722 of file Account.cpp.

2723 {
2724  QofBook *book;
2725  GValue v = G_VALUE_INIT;
2726  const char *s = gnc_commodity_get_unique_name (currency);
2727  gnc_commodity *commodity;
2728  gnc_commodity_table *table;
2729 
2730  if ((!acc) || (!currency)) return;
2731  g_value_init (&v, G_TYPE_STRING);
2732  g_value_set_string (&v, s);
2733  qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {"old-currency"});
2734  mark_account (acc);
2735  xaccAccountCommitEdit(acc);
2736  g_value_unset (&v);
2737 
2739  commodity = gnc_commodity_table_lookup_unique (table, s);
2740 
2741  if (!commodity)
2742  {
2743  book = qof_instance_get_book(acc);
2745  currency);
2746  }
2747 }
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 xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.cpp:1471

◆ 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 4993 of file Account.cpp.

4994 {
4995  if (!acc) return;
4996  if (!xaccAccountIsPriced(acc)) return;
4997  set_kvp_string_tag (acc, "old-quote-tz", tz);
4998 }
gboolean xaccAccountIsPriced(const Account *acc)
Returns true if the account is a stock, mutual fund or currency, otherwise false. ...
Definition: Account.cpp:4637

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

Definition at line 5772 of file Account.cpp.

5773 {
5774  if (!imap)
5775  return nullptr;
5776  check_import_map_data (imap->book);
5777  auto first_pass = get_first_pass_probabilities(imap, tokens);
5778  if (!first_pass.size())
5779  return nullptr;
5780  auto final_probabilities = build_probabilities(first_pass);
5781  if (!final_probabilities.size())
5782  return nullptr;
5783  auto best = highest_probability(final_probabilities);
5784  if (best.account_guid == "")
5785  return nullptr;
5786  if (best.probability < threshold)
5787  return nullptr;
5788  gnc::GUID guid;
5789  try {
5790  guid = gnc::GUID::from_string(best.account_guid);
5791  } catch (gnc::guid_syntax_exception&) {
5792  return nullptr;
5793  }
5794  auto account = xaccAccountLookup (reinterpret_cast<GncGUID*>(&guid), imap->book);
5795  return account;
5796 }
Account * xaccAccountLookup(const GncGUID *guid, QofBook *book)
The xaccAccountLookup() subroutine will return the account associated with the given id...
Definition: Account.cpp:2031

◆ 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 3040 of file Account.cpp.

3041 {
3042  return (Account*)gnc_account_foreach_descendant_until (parent, is_acct_name, (char*)name);
3043 }
gpointer gnc_account_foreach_descendant_until(const Account *acc, AccountCb2 thunk, gpointer user_data)
This method will traverse all children of this accounts and their descendants, calling &#39;func&#39; on each...
Definition: Account.cpp:3210

◆ gnc_account_lookup_by_opening_balance()

Account* gnc_account_lookup_by_opening_balance ( Account account,
gnc_commodity *  commodity 
)

Find the opening balance account for the currency.

Parameters
accountThe account of which the sought-for account is a descendant.
commodityThe commodity in which the account should be denominated
Returns
The descendant account of EQUITY_TYPE_OPENING_BALANCE or NULL if one doesn't exist.

Definition at line 3068 of file Account.cpp.

3069 {
3070  return (Account *)gnc_account_foreach_descendant_until (account, is_opening_balance_account, commodity);
3071 }
gpointer gnc_account_foreach_descendant_until(const Account *acc, AccountCb2 thunk, gpointer user_data)
This method will traverse all children of this accounts and their descendants, calling &#39;func&#39; on each...
Definition: Account.cpp:3210

◆ gnc_account_lookup_by_type_and_commodity()

GList* gnc_account_lookup_by_type_and_commodity ( Account root,
const char *  name,
GNCAccountType  acctype,
gnc_commodity *  commodity 
)

Find a direct child account matching name, GNCAccountType, and/or commodity.

Name and commodity may be nullptr in which case the accounts in the list may have any value for those properties. Note that commodity matching is by equivalence: If the mnemonic/symbol and namespace are the same, it matches.

Parameters
rootThe account among whose children one expects to find the account.
nameThe name of the account to look for or nullptr.
acctypeThe GNCAccountType to match.
commodityThe commodity in which the account should be denominated or nullptr.
Returns
A GList of children matching the supplied parameters.

Definition at line 3145 of file Account.cpp.

3149 {
3150  GList *retval{};
3151  auto rpriv{GET_PRIVATE(root)};
3152  for (auto node = rpriv->children; node; node = node->next)
3153  {
3154  auto account{static_cast<Account*>(node->data)};
3155  if (xaccAccountGetType (account) == acctype)
3156  {
3157  if (commodity &&
3159  commodity))
3160  continue;
3161 
3162  if (name && strcmp(name, xaccAccountGetName(account)))
3163  continue;
3164 
3165  retval = g_list_prepend(retval, account);
3166  }
3167  }
3168 
3169  if (!retval) // Recurse through the children
3170  for (auto node = rpriv->children; node; node = node->next)
3171  {
3172  auto account{static_cast<Account*>(node->data)};
3173  auto result = gnc_account_lookup_by_type_and_commodity(account,
3174  name,
3175  acctype,
3176  commodity);
3177  if (result)
3178  retval = g_list_concat(result, retval);
3179  }
3180  return retval;
3181 }
GNCAccountType xaccAccountGetType(const Account *acc)
Returns the account&#39;s account type.
Definition: Account.cpp:3236
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account&#39;s commodity.
Definition: Account.cpp:3405
const char * xaccAccountGetName(const Account *acc)
Get the account&#39;s name.
Definition: Account.cpp:3258
gboolean gnc_commodity_equiv(const gnc_commodity *a, const gnc_commodity *b)
This routine returns TRUE if the two commodities are equivalent.
GList * gnc_account_lookup_by_type_and_commodity(Account *root, const char *name, GNCAccountType acctype, gnc_commodity *commodity)
Find a direct child account matching name, GNCAccountType, and/or commodity.
Definition: Account.cpp:3145

◆ 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 5276 of file Account.cpp.

5277 {
5278  GList *descendants;
5279 
5280  descendants = gnc_account_get_descendants(account);
5281  g_list_foreach(descendants, (GFunc)do_one_account, NULL);
5282  g_list_free(descendants);
5283 }
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.cpp:3017

◆ 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 5326 of file Account.cpp.

5330 {
5331  const AccountPrivate *priv;
5332  GList *acc_p, *split_p;
5333  Transaction *trans;
5334  Split *s;
5335  int retval;
5336 
5337  if (!acc) return 0;
5338 
5339  /* depth first traversal */
5340  priv = GET_PRIVATE(acc);
5341  for (acc_p = priv->children; acc_p; acc_p = g_list_next(acc_p))
5342  {
5343  retval = gnc_account_tree_staged_transaction_traversal(static_cast <Account*> (acc_p->data),
5344  stage, thunk, cb_data);
5345  if (retval) return retval;
5346  }
5347 
5348  /* Now this account */
5349  for (split_p = priv->splits; split_p; split_p = g_list_next(split_p))
5350  {
5351  s = static_cast <Split*> (split_p->data);
5352  trans = s->parent;
5353  if (trans && (trans->marker < stage))
5354  {
5355  trans->marker = stage;
5356  if (thunk)
5357  {
5358  retval = thunk(trans, cb_data);
5359  if (retval) return retval;
5360  }
5361  }
5362  }
5363 
5364  return 0;
5365 }
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.cpp:5326

◆ 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:268
void qof_close(void)
Safely close down the Query Object Framework.
Definition: qofutil.cpp:269

◆ 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 3994 of file Account.cpp.

3998 {
3999  AccountPrivate *priv;
4000  GList *lot_list;
4001  GList *retval = NULL;
4002 
4003  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
4004 
4005  priv = GET_PRIVATE(acc);
4006  for (lot_list = priv->lots; lot_list; lot_list = lot_list->next)
4007  {
4008  GNCLot *lot = static_cast<GNCLot*>(lot_list->data);
4009 
4010  /* If this lot is closed, then ignore it */
4011  if (gnc_lot_is_closed (lot))
4012  continue;
4013 
4014  if (match_func && !(match_func)(lot, user_data))
4015  continue;
4016 
4017  /* Ok, this is a valid lot. Add it to our list of lots */
4018  retval = g_list_prepend (retval, lot);
4019  }
4020 
4021  if (sort_func)
4022  retval = g_list_sort (retval, sort_func);
4023 
4024  return retval;
4025 }
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:382

◆ xaccAccountFindSplitByDesc()

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

Returns a pointer to the split, not a copy.

Definition at line 5098 of file Account.cpp.

5099 {
5100  Split *split;
5101 
5102  /* Get the split which has a transaction matching the description. */
5103  finder_help_function(acc, description, &split, NULL);
5104  return split;
5105 }

◆ xaccAccountFindTransByDesc()

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

Returns a pointer to the transaction, not a copy.

Definition at line 5113 of file Account.cpp.

5114 {
5115  Transaction *trans;
5116 
5117  /* Get the translation matching the description. */
5118  finder_help_function(acc, description, NULL, &trans);
5119  return trans;
5120 }

◆ 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 5383 of file Account.cpp.

5385 {
5386  if (!acc || !proc) return 0;
5388  return xaccAccountStagedTransactionTraversal(acc, 42, proc, data);
5389 }
void xaccAccountBeginStagedTransactionTraversals(const Account *account)
xaccAccountBeginStagedTransactionTraversals() resets the traversal marker for each transaction which ...
Definition: Account.cpp:5238
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.cpp:5286

◆ xaccAccountGetAutoInterest()

gboolean xaccAccountGetAutoInterest ( const Account acc)

Get the "auto interest" flag for an account.

If this flag is set then the account (and any children) will trigger an interest transfer after reconciling.

Parameters
accThe account whose flag should be retrieved.
Returns
The current state of the account's "auto interest" flag.

Definition at line 4261 of file Account.cpp.

4262 {
4263  return boolean_from_key (acc, {KEY_RECONCILE_INFO, "auto-interest-transfer"});
4264 }

◆ 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 4237 of file Account.cpp.

4238 {
4239  GList *descendants, *node;
4240  GNCPlaceholderType ret = PLACEHOLDER_NONE;
4241 
4242  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), PLACEHOLDER_NONE);
4243  if (xaccAccountGetPlaceholder(acc)) return PLACEHOLDER_THIS;
4244 
4245  descendants = gnc_account_get_descendants(acc);
4246  for (node = descendants; node; node = node->next)
4247  if (xaccAccountGetPlaceholder((Account *) node->data))
4248  {
4249  ret = PLACEHOLDER_CHILD;
4250  break;
4251  }
4252 
4253  g_list_free(descendants);
4254  return ret;
4255 }
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.cpp:3017
GNCPlaceholderType
DOCUMENT ME!
Definition: Account.h:1181
gboolean xaccAccountGetPlaceholder(const Account *acc)
Get the "placeholder" flag for an account.
Definition: Account.cpp:4199

◆ 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 4276 of file Account.cpp.

4277 {
4278  return boolean_from_key (acc, {"hidden"});
4279 }

◆ xaccAccountGetIsOpeningBalance()

gboolean xaccAccountGetIsOpeningBalance ( const Account account)

Get the "opening-balance" flag for an account.

If this flag is set then the account is used for opening balance transactions.

Parameters
accountThe account whose flag should be retrieved.
Returns
The current state of the account's "opening-balance" flag.

Definition at line 4211 of file Account.cpp.

4212 {
4213  if (GET_PRIVATE(acc)->type != ACCT_TYPE_EQUITY)
4214  return false;
4215  auto priv = GET_PRIVATE(acc);
4216  if (priv->equity_type == TriState::Unset)
4217  {
4218  auto equity_type = get_kvp_string_tag (acc, "equity-type");
4219  priv->equity_type = g_strcmp0 (equity_type, "opening-balance") ?
4220  TriState::False : TriState::True;
4221  g_free (equity_type);
4222  }
4223  return (priv->equity_type == TriState::True);
4224 }
Equity account is used to balance the balance sheet.
Definition: Account.h:149

◆ 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 3987 of file Account.cpp.

3988 {
3989  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
3990  return g_list_copy(GET_PRIVATE(acc)->lots);
3991 }

◆ 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 4199 of file Account.cpp.

4200 {
4201  return boolean_from_key(acc, {"placeholder"});
4202 }

◆ 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 3964 of file Account.cpp.

3965 {
3966  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
3967  xaccAccountSortSplits((Account*)acc, FALSE); // normally a noop
3968  return GET_PRIVATE(acc)->splits;
3969 }
void xaccAccountSortSplits(Account *acc, gboolean force)
The xaccAccountSortSplits() routine will resort the account&#39;s splits if the sort is dirty...
Definition: Account.cpp:1985

◆ 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 4443 of file Account.cpp.

4444 {
4445  if (type < 0 || NUM_ACCOUNT_TYPES <= type ) return "";
4446  return _(account_type_name [type]);
4447 }
stop here; the following types just aren&#39;t ready for prime time
Definition: Account.h:164

◆ 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 2124 of file Account.cpp.

2125 {
2126  AccountPrivate *priv, *opriv;
2127  Account * old_acc = NULL;
2128  Account* lot_account;
2129 
2130  /* errors */
2131  g_return_if_fail(GNC_IS_ACCOUNT(acc));
2132  g_return_if_fail(GNC_IS_LOT(lot));
2133 
2134  /* optimizations */
2135  lot_account = gnc_lot_get_account(lot);
2136  if (lot_account == acc)
2137  return;
2138 
2139  ENTER ("(acc=%p, lot=%p)", acc, lot);
2140 
2141  /* pull it out of the old account */
2142  if (lot_account)
2143  {
2144  old_acc = lot_account;
2145  opriv = GET_PRIVATE(old_acc);
2146  opriv->lots = g_list_remove(opriv->lots, lot);
2147  }
2148 
2149  priv = GET_PRIVATE(acc);
2150  priv->lots = g_list_prepend(priv->lots, lot);
2151  gnc_lot_set_account(lot, acc);
2152 
2153  /* Don't move the splits to the new account. The caller will do this
2154  * if appropriate, and doing it here will not work if we are being
2155  * called from gnc_book_close_period since xaccAccountInsertSplit
2156  * will try to balance capital gains and things aren't ready for that. */
2157 
2158  qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_ADD, NULL);
2159  qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, NULL);
2160 
2161  LEAVE ("(acc=%p, lot=%p)", acc, lot);
2162 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
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:392
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition: qofevent.cpp:231

◆ 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 4613 of file Account.cpp.

4614 {
4615  switch (t)
4616  {
4617  case ACCT_TYPE_RECEIVABLE:
4618  case ACCT_TYPE_PAYABLE:
4619  return TRUE;
4620  default:
4621  return FALSE;
4622  }
4623 }
A/P account type.
Definition: Account.h:154
A/R account type.
Definition: Account.h:152

◆ 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 4567 of file Account.cpp.

4568 {
4569  switch (t)
4570  {
4571  case ACCT_TYPE_RECEIVABLE:
4572  case ACCT_TYPE_PAYABLE:
4573  return FALSE;
4574  default:
4577  }
4578 }
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.cpp:4540
A/P account type.
Definition: Account.h:154
asset (and liability) accounts indicate generic, generalized accounts that are none of the above...
Definition: Account.h:119
liability (and asset) accounts indicate generic, generalized accounts that are none of the above...
Definition: Account.h:122
A/R account type.
Definition: Account.h:152

◆ xaccAccountIsEquityType()

gboolean xaccAccountIsEquityType ( GNCAccountType  t)

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

Definition at line 4625 of file Account.cpp.

4626 {
4627  switch (t)
4628  {
4629  case ACCT_TYPE_EQUITY:
4630  return TRUE;
4631  default:
4632  return FALSE;
4633  }
4634 }
Equity account is used to balance the balance sheet.
Definition: Account.h:149

◆ 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 4288 of file Account.cpp.

4289 {
4290  AccountPrivate *priv;
4291 
4292  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
4293 
4294  if (xaccAccountGetHidden(acc))
4295  return TRUE;
4296  priv = GET_PRIVATE(acc);
4297  while ((acc = priv->parent) != NULL)
4298  {
4299  priv = GET_PRIVATE(acc);
4300  if (xaccAccountGetHidden(acc))
4301  return TRUE;
4302  }
4303  return FALSE;
4304 }
gboolean xaccAccountGetHidden(const Account *acc)
Get the "hidden" flag for an account.
Definition: Account.cpp:4276

◆ xaccAccountMoveAllSplits()

void xaccAccountMoveAllSplits ( Account accfrom,
Account accto 
)

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

Definition at line 2184 of file Account.cpp.

2185 {
2186  AccountPrivate *from_priv;
2187 
2188  /* errors */
2189  g_return_if_fail(GNC_IS_ACCOUNT(accfrom));
2190  g_return_if_fail(GNC_IS_ACCOUNT(accto));
2191 
2192  /* optimizations */
2193  from_priv = GET_PRIVATE(accfrom);
2194  if (!from_priv->splits || accfrom == accto)
2195  return;
2196 
2197  /* check for book mix-up */
2198  g_return_if_fail (qof_instance_books_equal(accfrom, accto));
2199  ENTER ("(accfrom=%p, accto=%p)", accfrom, accto);
2200 
2201  xaccAccountBeginEdit(accfrom);
2202  xaccAccountBeginEdit(accto);
2203  /* Begin editing both accounts and all transactions in accfrom. */
2204  g_list_foreach(from_priv->splits, (GFunc)xaccPreSplitMove, NULL);
2205 
2206  /* Concatenate accfrom's lists of splits and lots to accto's lists. */
2207  //to_priv->splits = g_list_concat(to_priv->splits, from_priv->splits);
2208  //to_priv->lots = g_list_concat(to_priv->lots, from_priv->lots);
2209 
2210  /* Set appropriate flags. */
2211  //from_priv->balance_dirty = TRUE;
2212  //from_priv->sort_dirty = FALSE;
2213  //to_priv->balance_dirty = TRUE;
2214  //to_priv->sort_dirty = TRUE;
2215 
2216  /*
2217  * Change each split's account back pointer to accto.
2218  * Convert each split's amount to accto's commodity.
2219  * Commit to editing each transaction.
2220  */
2221  g_list_foreach(from_priv->splits, (GFunc)xaccPostSplitMove, (gpointer)accto);
2222 
2223  /* Finally empty accfrom. */
2224  g_assert(from_priv->splits == NULL);
2225  g_assert(from_priv->lots == NULL);
2226  xaccAccountCommitEdit(accfrom);
2227  xaccAccountCommitEdit(accto);
2228 
2229  LEAVE ("(accfrom=%p, accto=%p)", accfrom, accto);
2230 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
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.cpp:1430
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.cpp:1471

◆ xaccAccountSetAutoInterest()

void xaccAccountSetAutoInterest ( Account acc,
gboolean  val 
)

Set the "auto interest" flag for an account.

If this flag is set then the account (and any children) will trigger an interest transfer after reconciling.

Parameters
accThe account whose flag should be retrieved.
valThe new state for the account's "auto interest" flag.

Definition at line 4267 of file Account.cpp.

4268 {
4269  set_boolean_key (acc, {KEY_RECONCILE_INFO, "auto-interest-transfer"}, val);
4270 }

◆ 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 4282 of file Account.cpp.

4283 {
4284  set_boolean_key (acc, {"hidden"}, val);
4285 }

◆ xaccAccountSetIsOpeningBalance()

void xaccAccountSetIsOpeningBalance ( Account account,
gboolean  val 
)

Set the "opening-balance" flag for an account.

If this flag is set then the account is used for opening balance transactions.

Parameters
accountThe account whose flag should be set.
valThe new state for the account's "opening-balance" flag.

Definition at line 4227 of file Account.cpp.

4228 {
4229  if (GET_PRIVATE(acc)->type != ACCT_TYPE_EQUITY)
4230  return;
4231  auto priv = GET_PRIVATE (acc);
4232  priv->equity_type = val ? TriState::True : TriState::False;
4233  set_kvp_string_tag(acc, "equity-type", val ? "opening-balance" : nullptr);
4234 }
Equity account is used to balance the balance sheet.
Definition: Account.h:149

◆ 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 2043 of file Account.cpp.

2044 {
2045  AccountPrivate *priv;
2046 
2047  g_return_if_fail(GNC_IS_ACCOUNT(acc));
2048 
2049  priv = GET_PRIVATE(acc);
2050  priv->mark = m;
2051 }

◆ 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 4205 of file Account.cpp.

4206 {
4207  set_boolean_key(acc, {"placeholder"}, val);
4208 }

◆ 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 5286 of file Account.cpp.

5290 {
5291  AccountPrivate *priv;
5292  GList *split_p;
5293  GList *next;
5294  Transaction *trans;
5295  Split *s;
5296  int retval;
5297 
5298  if (!acc) return 0;
5299 
5300  priv = GET_PRIVATE(acc);
5301  for (split_p = priv->splits; split_p; split_p = next)
5302  {
5303  /* Get the next element in the split list now, just in case some
5304  * naughty thunk destroys the one we're using. This reduces, but
5305  * does not eliminate, the possibility of undefined results if
5306  * a thunk removes splits from this account. */
5307  next = g_list_next(split_p);
5308 
5309  s = static_cast <Split*> (split_p->data);
5310  trans = s->parent;
5311  if (trans && (trans->marker < stage))
5312  {
5313  trans->marker = stage;
5314  if (thunk)
5315  {
5316  retval = thunk(trans, cb_data);
5317  if (retval) return retval;
5318  }
5319  }
5320  }
5321 
5322  return 0;
5323 }

◆ 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 4404 of file Account.cpp.

4405 {
4406  GNCAccountType type;
4407  gboolean rc;
4408  rc = xaccAccountStringToType(str, &type);
4409  if (FALSE == rc) return ACCT_TYPE_INVALID;
4410  return type;
4411 }
gboolean xaccAccountStringToType(const char *str, GNCAccountType *type)
Conversion routines for the account types to/from strings that are used in persistent storage...
Definition: Account.cpp:4370
GNCAccountType
The account types are used to determine how the transaction data in the account is displayed...
Definition: Account.h:105
Not a type.
Definition: Account.h:107

◆ 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 4370 of file Account.cpp.

4371 {
4372 
4373  GNC_RETURN_ON_MATCH(NONE);
4374  GNC_RETURN_ON_MATCH(BANK);
4375  GNC_RETURN_ON_MATCH(CASH);
4376  GNC_RETURN_ON_MATCH(CREDIT);
4377  GNC_RETURN_ON_MATCH(ASSET);
4378  GNC_RETURN_ON_MATCH(LIABILITY);
4379  GNC_RETURN_ON_MATCH(STOCK);
4380  GNC_RETURN_ON_MATCH(MUTUAL);
4381  GNC_RETURN_ON_MATCH(CURRENCY);
4382  GNC_RETURN_ON_MATCH(INCOME);
4383  GNC_RETURN_ON_MATCH(EXPENSE);
4384  GNC_RETURN_ON_MATCH(EQUITY);
4385  GNC_RETURN_ON_MATCH(RECEIVABLE);
4386  GNC_RETURN_ON_MATCH(PAYABLE);
4387  GNC_RETURN_ON_MATCH(ROOT);
4388  GNC_RETURN_ON_MATCH(TRADING);
4389  GNC_RETURN_ON_MATCH(CHECKING);
4390  GNC_RETURN_ON_MATCH(SAVINGS);
4391  GNC_RETURN_ON_MATCH(MONEYMRKT);
4392  GNC_RETURN_ON_MATCH(CREDITLINE);
4393 
4394  PERR("asked to translate unknown account type string %s.\n",
4395  str ? str : "(null)");
4396 
4397  return(FALSE);
4398 }
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:244

◆ 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 4333 of file Account.cpp.

4334 {
4335  switch (type)
4336  {
4337  GNC_RETURN_ENUM_AS_STRING(NONE);
4338  GNC_RETURN_ENUM_AS_STRING(BANK);
4339  GNC_RETURN_ENUM_AS_STRING(CASH);
4340  GNC_RETURN_ENUM_AS_STRING(CREDIT);
4341  GNC_RETURN_ENUM_AS_STRING(ASSET);
4342  GNC_RETURN_ENUM_AS_STRING(LIABILITY);
4343  GNC_RETURN_ENUM_AS_STRING(STOCK);
4344  GNC_RETURN_ENUM_AS_STRING(MUTUAL);
4345  GNC_RETURN_ENUM_AS_STRING(CURRENCY);
4346  GNC_RETURN_ENUM_AS_STRING(INCOME);
4347  GNC_RETURN_ENUM_AS_STRING(EXPENSE);
4348  GNC_RETURN_ENUM_AS_STRING(EQUITY);
4349  GNC_RETURN_ENUM_AS_STRING(RECEIVABLE);
4350  GNC_RETURN_ENUM_AS_STRING(PAYABLE);
4351  GNC_RETURN_ENUM_AS_STRING(ROOT);
4352  GNC_RETURN_ENUM_AS_STRING(TRADING);
4353  GNC_RETURN_ENUM_AS_STRING(CHECKING);
4354  GNC_RETURN_ENUM_AS_STRING(SAVINGS);
4355  GNC_RETURN_ENUM_AS_STRING(MONEYMRKT);
4356  GNC_RETURN_ENUM_AS_STRING(CREDITLINE);
4357  default:
4358  PERR ("asked to translate unknown account type %d.\n", type);
4359  break;
4360  }
4361  return(NULL);
4362 }
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:244

◆ xaccAccountTypeGetFundamental()

GNCAccountType xaccAccountTypeGetFundamental ( GNCAccountType  t)

Convenience function to return the fundamental type asset/liability/income/expense/equity given an account type.

Definition at line 4581 of file Account.cpp.

4582 {
4583  switch (t)
4584  {
4585  case ACCT_TYPE_BANK:
4586  case ACCT_TYPE_STOCK:
4587  case ACCT_TYPE_MONEYMRKT:
4588  case ACCT_TYPE_CHECKING:
4589  case ACCT_TYPE_SAVINGS:
4590  case ACCT_TYPE_MUTUAL:
4591  case ACCT_TYPE_CURRENCY:
4592  case ACCT_TYPE_CASH:
4593  case ACCT_TYPE_ASSET:
4594  case ACCT_TYPE_RECEIVABLE:
4595  return ACCT_TYPE_ASSET;
4596  case ACCT_TYPE_CREDIT:
4597  case ACCT_TYPE_LIABILITY:
4598  case ACCT_TYPE_PAYABLE:
4599  case ACCT_TYPE_CREDITLINE:
4600  return ACCT_TYPE_LIABILITY;
4601  case ACCT_TYPE_INCOME:
4602  return ACCT_TYPE_INCOME;
4603  case ACCT_TYPE_EXPENSE:
4604  return ACCT_TYPE_EXPENSE;
4605  case ACCT_TYPE_EQUITY:
4606  return ACCT_TYPE_EQUITY;
4607  case ACCT_TYPE_TRADING:
4608  default:
4609  return ACCT_TYPE_NONE;
4610  }
4611 }
Expense accounts are used to denote expenses.
Definition: Account.h:146
Mutual Fund accounts will typically be shown in registers which show three columns: price...
Definition: Account.h:128
The cash account type is used to denote a shoe-box or pillowcase stuffed with * cash.
Definition: Account.h:113
Account used to record multiple commodity transactions.
Definition: Account.h:158
Stock accounts will typically be shown in registers which show three columns: price, number of shares, and value.
Definition: Account.h:125
bank account type – don&#39;t use this for now, see NUM_ACCOUNT_TYPES
Definition: Account.h:168
Income accounts are used to denote income.
Definition: Account.h:143
line of credit – don&#39;t use this for now, see NUM_ACCOUNT_TYPES
Definition: Account.h:174
The bank account type denotes a savings or checking account held at a bank.
Definition: Account.h:110
A/P account type.
Definition: Account.h:154
bank account type – don&#39;t use this for now, see NUM_ACCOUNT_TYPES
Definition: Account.h:170
asset (and liability) accounts indicate generic, generalized accounts that are none of the above...
Definition: Account.h:119
The currency account type indicates that the account is a currency trading account.
Definition: Account.h:132
liability (and asset) accounts indicate generic, generalized accounts that are none of the above...
Definition: Account.h:122
A/R account type.
Definition: Account.h:152
bank account type – don&#39;t use this for now, see NUM_ACCOUNT_TYPES
Definition: Account.h:172
Equity account is used to balance the balance sheet.
Definition: Account.h:149
Not a type.
Definition: Account.h:108
The Credit card account is used to denote credit (e.g.
Definition: Account.h:116

◆ 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 4540 of file Account.cpp.

4542 {
4543  /* ACCT_TYPE_NONE isn't compatible with anything, even ACCT_TYPE_NONE. */
4544  if (parent_type == ACCT_TYPE_NONE || child_type == ACCT_TYPE_NONE)
4545  return FALSE;
4546 
4547  /* ACCT_TYPE_ROOT can't have a parent account, and asking will raise
4548  * an error. */
4549  if (child_type == ACCT_TYPE_ROOT)
4550  return FALSE;
4551 
4552  return ((xaccParentAccountTypesCompatibleWith (child_type) &
4553  (1 << parent_type))
4554  != 0);
4555 }
guint32 xaccParentAccountTypesCompatibleWith(GNCAccountType type)
Return the bitmask of parent account types compatible with a given type.
Definition: Account.cpp:4493
Not a type.
Definition: Account.h:108
The hidden root account of an account tree.
Definition: Account.h:156

◆ 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 4453 of file Account.cpp.

4454 {
4455  switch (type)
4456  {
4457  case ACCT_TYPE_BANK:
4458  case ACCT_TYPE_CASH:
4459  case ACCT_TYPE_ASSET:
4460  case ACCT_TYPE_CREDIT:
4461  case ACCT_TYPE_LIABILITY:
4462  case ACCT_TYPE_INCOME:
4463  case ACCT_TYPE_EXPENSE:
4464  case ACCT_TYPE_EQUITY:
4465  return
4466  (1 << ACCT_TYPE_BANK) |
4467  (1 << ACCT_TYPE_CASH) |
4468  (1 << ACCT_TYPE_ASSET) |
4469  (1 << ACCT_TYPE_CREDIT) |
4470  (1 << ACCT_TYPE_LIABILITY) |
4471  (1 << ACCT_TYPE_INCOME) |
4472  (1 << ACCT_TYPE_EXPENSE) |
4473  (1 << ACCT_TYPE_EQUITY);
4474  case ACCT_TYPE_STOCK:
4475  case ACCT_TYPE_MUTUAL:
4476  case ACCT_TYPE_CURRENCY:
4477  return
4478  (1 << ACCT_TYPE_STOCK) |
4479  (1 << ACCT_TYPE_MUTUAL) |
4480  (1 << ACCT_TYPE_CURRENCY);
4481  case ACCT_TYPE_RECEIVABLE:
4482  return (1 << ACCT_TYPE_RECEIVABLE);
4483  case ACCT_TYPE_PAYABLE:
4484  return (1 << ACCT_TYPE_PAYABLE);
4485  case ACCT_TYPE_TRADING:
4486  return (1 << ACCT_TYPE_TRADING);
4487  default:
4488  PERR("bad account type: %d", type);
4489  return 0;
4490  }
4491 }
Expense accounts are used to denote expenses.
Definition: Account.h:146
Mutual Fund accounts will typically be shown in registers which show three columns: price...
Definition: Account.h:128
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:244
The cash account type is used to denote a shoe-box or pillowcase stuffed with * cash.
Definition: Account.h:113
Account used to record multiple commodity transactions.
Definition: Account.h:158
Stock accounts will typically be shown in registers which show three columns: price, number of shares, and value.
Definition: Account.h:125
Income accounts are used to denote income.
Definition: Account.h:143
The bank account type denotes a savings or checking account held at a bank.
Definition: Account.h:110
A/P account type.
Definition: Account.h:154
asset (and liability) accounts indicate generic, generalized accounts that are none of the above...
Definition: Account.h:119
The currency account type indicates that the account is a currency trading account.
Definition: Account.h:132
liability (and asset) accounts indicate generic, generalized accounts that are none of the above...
Definition: Account.h:122
A/R account type.
Definition: Account.h:152
Equity account is used to balance the balance sheet.
Definition: Account.h:149
The Credit card account is used to denote credit (e.g.
Definition: Account.h:116

◆ 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 4558 of file Account.cpp.

4559 {
4560  guint32 mask = (1 << NUM_ACCOUNT_TYPES) - 1;
4561  mask &= ~((1 << ACCT_TYPE_CURRENCY) | /* DEPRECATED */
4562  (1 << ACCT_TYPE_ROOT)); /* ROOT */
4563 
4564  return mask;
4565 }
stop here; the following types just aren&#39;t ready for prime time
Definition: Account.h:164
The currency account type indicates that the account is a currency trading account.
Definition: Account.h:132
The hidden root account of an account tree.
Definition: Account.h:156

◆ 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 2054 of file Account.cpp.

2055 {
2056  Account *root;
2057 
2058  g_return_if_fail(GNC_IS_ACCOUNT(acc));
2059 
2060  root = gnc_account_get_root(acc);
2061  xaccClearMarkDown(root ? root : acc, val);
2062 }
void xaccClearMarkDown(Account *acc, short val)
The xaccClearMarkDown will clear the mark only in this and in sub-accounts.
Definition: Account.cpp:2065
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.cpp:2887

◆ xaccClearMarkDown()

void xaccClearMarkDown ( Account account,
short  val 
)

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

Definition at line 2065 of file Account.cpp.

2066 {
2067  AccountPrivate *priv;
2068  GList *node;
2069 
2070  g_return_if_fail(GNC_IS_ACCOUNT(acc));
2071 
2072  priv = GET_PRIVATE(acc);
2073  priv->mark = val;
2074  for (node = priv->children; node; node = node->next)
2075  {
2076  xaccClearMarkDown(static_cast<Account*>(node->data), val);
2077  }
2078 }
void xaccClearMarkDown(Account *acc, short val)
The xaccClearMarkDown will clear the mark only in this and in sub-accounts.
Definition: Account.cpp:2065

◆ xaccParentAccountTypesCompatibleWith()

guint32 xaccParentAccountTypesCompatibleWith ( GNCAccountType  type)

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

Definition at line 4493 of file Account.cpp.

4494 {
4495  switch (type)
4496  {
4497  case ACCT_TYPE_BANK:
4498  case ACCT_TYPE_CASH:
4499  case ACCT_TYPE_ASSET:
4500  case ACCT_TYPE_STOCK:
4501  case ACCT_TYPE_MUTUAL:
4502  case ACCT_TYPE_CURRENCY:
4503  case ACCT_TYPE_CREDIT:
4504  case ACCT_TYPE_LIABILITY:
4505  case ACCT_TYPE_RECEIVABLE:
4506  case ACCT_TYPE_PAYABLE:
4507  return
4508  (1 << ACCT_TYPE_BANK) |
4509  (1 << ACCT_TYPE_CASH) |
4510  (1 << ACCT_TYPE_ASSET) |
4511  (1 << ACCT_TYPE_STOCK) |
4512  (1 << ACCT_TYPE_MUTUAL) |
4513  (1 << ACCT_TYPE_CURRENCY) |
4514  (1 << ACCT_TYPE_CREDIT) |
4515  (1 << ACCT_TYPE_LIABILITY) |
4516  (1 << ACCT_TYPE_RECEIVABLE) |
4517  (1 << ACCT_TYPE_PAYABLE) |
4518  (1 << ACCT_TYPE_ROOT);
4519  case ACCT_TYPE_INCOME:
4520  case ACCT_TYPE_EXPENSE:
4521  return
4522  (1 << ACCT_TYPE_INCOME) |
4523  (1 << ACCT_TYPE_EXPENSE) |
4524  (1 << ACCT_TYPE_ROOT);
4525  case ACCT_TYPE_EQUITY:
4526  return
4527  (1 << ACCT_TYPE_EQUITY) |
4528  (1 << ACCT_TYPE_ROOT);
4529  case ACCT_TYPE_TRADING:
4530  return
4531  (1 << ACCT_TYPE_TRADING) |
4532  (1 << ACCT_TYPE_ROOT);
4533  default:
4534  PERR("bad account type: %d", type);
4535  return 0;
4536  }
4537 }
Expense accounts are used to denote expenses.
Definition: Account.h:146
Mutual Fund accounts will typically be shown in registers which show three columns: price...
Definition: Account.h:128
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:244
The cash account type is used to denote a shoe-box or pillowcase stuffed with * cash.
Definition: Account.h:113
Account used to record multiple commodity transactions.
Definition: Account.h:158
Stock accounts will typically be shown in registers which show three columns: price, number of shares, and value.
Definition: Account.h:125
Income accounts are used to denote income.
Definition: Account.h:143
The bank account type denotes a savings or checking account held at a bank.
Definition: Account.h:110
A/P account type.
Definition: Account.h:154
asset (and liability) accounts indicate generic, generalized accounts that are none of the above...
Definition: Account.h:119
The currency account type indicates that the account is a currency trading account.
Definition: Account.h:132
liability (and asset) accounts indicate generic, generalized accounts that are none of the above...
Definition: Account.h:122
A/R account type.
Definition: Account.h:152
Equity account is used to balance the balance sheet.
Definition: Account.h:149
The hidden root account of an account tree.
Definition: Account.h:156
The Credit card account is used to denote credit (e.g.
Definition: Account.h:116

◆ 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 5249 of file Account.cpp.

5250 {
5251  if (trans == NULL) return FALSE;
5252 
5253  if (trans->marker < stage)
5254  {
5255  trans->marker = stage;
5256  return TRUE;
5257  }
5258 
5259  return FALSE;
5260 }