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

Modules

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

Files

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

Macros

#define ACCOUNT_MATCH_ALL_TYPE   "account-match-all"
 
#define GNC_ID_NONE   QOF_ID_NONE
 IDENTIFIERS GncGUID Identifiers can be used to reference Accounts, Transactions, Splits and other objects. These Gnucash types are referred to as Gnucash entities. GncGUID Identifiers are globally-unique and permanent, i.e., once an entity has been assigned an identifier, it retains that same identifier for its lifetime.

  • Identifiers are 'typed' with strings. The ids used in gnucash are defined below. An id with type GNC_ID_NONE does not refer to any entity, although that may change as new ids are created. An id with type GNC_ID_NULL does not refer to any entity, and will never refer to any entity. An identifier with any other type may refer to an actual entity, but that is not guaranteed. If an id does refer to an entity, the type of the entity will match the type of the identifier.

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

Typedefs

typedef GList AccountList
 
typedef GList LotList
 
typedef GList SplitList
 
typedef GList TransList
 
typedef GList AccountGUIDList
 
typedef GList BookGUIDList
 
typedef void(* EngineCommitErrorCallback) (gpointer data, QofBackendError errcode)
 
typedef gint(* SplitCallback) (Split *s, gpointer data)
 
typedef gint(* TransactionCallback) (Transaction *t, void *data)
 
typedef void(* gnc_engine_init_hook_t) (int, char **)
 

Enumerations

enum  GNCPlaceholderType { PLACEHOLDER_NONE, PLACEHOLDER_THIS, PLACEHOLDER_CHILD }
 

Functions

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

Lookup Accounts and Subaccounts by name or code

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

GNCAccountType conversion/checking

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

Account split/transaction list management

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

Account lots

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

Account Reconciliation information getters/setters

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

Account Placeholder flag

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

Account Hidden flag

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

Account Tax related getters/setters

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

Account marking

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

Staged Traversal

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

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

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

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

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

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

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

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

Deprecated Routines.

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

Account parameter names

#define ACCOUNT_KVP   "kvp"
 
#define ACCOUNT_NAME_   "name"
 
#define ACCOUNT_CODE_   "code"
 
#define ACCOUNT_DESCRIPTION_   "desc"
 
#define ACCOUNT_COLOR_   "color"
 
#define ACCOUNT_FILTER_   "filter"
 
#define ACCOUNT_SORT_ORDER_   "sort-order"
 
#define ACCOUNT_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 1438 of file Account.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 972 of file Account.h.

Typedef Documentation

◆ AccountGUIDList

typedef GList AccountGUIDList

GList of GUIDs of a Account

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

◆ AccountList

typedef GList AccountList

GList of Account

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

◆ BookGUIDList

typedef GList BookGUIDList

GList of GUIDs of a QofBook

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

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

◆ LotList

typedef GList LotList

GList of GNCLots

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

◆ SplitList

typedef GList SplitList

GList of Split

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

◆ TransList

typedef GList TransList

GList of Transaction

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

Enumeration Type Documentation

◆ GNCPlaceholderType

DOCUMENT ME!

Definition at line 1124 of file Account.h.

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

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

3015 {
3016  KvpValue *v;
3017  const char *s;
3018  gnc_commodity_table *table;
3019 
3020  if (!acc) return NULL;
3021 
3022  v = kvp_frame_get_slot(acc->inst.kvp_data, "old-currency");
3023  if (!v) return NULL;
3024 
3025  s = kvp_value_get_string (v);
3026  if (!s) return NULL;
3027 
3029 
3030  return gnc_commodity_table_lookup_unique (table, s);
3031 }
gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book)
QofBook * qof_instance_get_book(gconstpointer inst)
Definition: qofinstance.c:548
char * kvp_value_get_string(const KvpValue *value)
Definition: kvp_frame.c:1146

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

4480 {
4481  if (!acc) return NULL;
4482 
4483  if (xaccAccountIsPriced(acc))
4484  {
4485  KvpValue *value = kvp_frame_get_slot(acc->inst.kvp_data, "old-quote-tz");
4486  if (value) return (kvp_value_get_string(value));
4487  }
4488  return NULL;
4489 }
gboolean xaccAccountIsPriced(const Account *acc)
Definition: Account.c:4175
char * kvp_value_get_string(const KvpValue *value)
Definition: kvp_frame.c:1146

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

2374 {
2375  QofBook *book;
2376  const char *string;
2377  gnc_commodity *commodity;
2378 
2379  if ((!acc) || (!currency)) return;
2380 
2381  xaccAccountBeginEdit(acc);
2382  string = gnc_commodity_get_unique_name (currency);
2383  kvp_frame_set_slot_nc(acc->inst.kvp_data, "old-currency",
2384  kvp_value_new_string(string));
2385  mark_account (acc);
2386  xaccAccountCommitEdit(acc);
2387 
2388  commodity = DxaccAccountGetCurrency (acc);
2389  if (!commodity)
2390  {
2391  book = qof_instance_get_book(acc);
2393  }
2394 }
gnc_commodity * gnc_commodity_table_insert(gnc_commodity_table *table, gnc_commodity *comm)
gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book)
gnc_commodity * DxaccAccountGetCurrency(const Account *acc)
Definition: Account.c:3014
QofBook * qof_instance_get_book(gconstpointer inst)
Definition: qofinstance.c:548
void kvp_frame_set_slot_nc(KvpFrame *frame, const gchar *key, KvpValue *value)
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1143
const char * gnc_commodity_get_unique_name(const gnc_commodity *cm)
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1184

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

4460 {
4461  if (!acc) return;
4462 
4463  xaccAccountBeginEdit(acc);
4464  if (xaccAccountIsPriced(acc))
4465  {
4466  kvp_frame_set_slot_nc(acc->inst.kvp_data,
4467  "old-quote-tz",
4468  tz ? kvp_value_new_string(tz) : NULL);
4469  mark_account (acc);
4470  }
4471  qof_instance_set_dirty(&acc->inst);
4472  xaccAccountCommitEdit(acc);
4473 }
gboolean xaccAccountIsPriced(const Account *acc)
Definition: Account.c:4175
void qof_instance_set_dirty(QofInstance *inst)
Set the dirty flag.
Definition: qofinstance.c:723
void kvp_frame_set_slot_nc(KvpFrame *frame, const gchar *key, KvpValue *value)
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1143
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1184

◆ gnc_account_lookup_by_code()

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

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

Definition at line 2711 of file Account.c.

2712 {
2713  AccountPrivate *cpriv, *ppriv;
2714  Account *child, *result;
2715  GList *node;
2716 
2717  g_return_val_if_fail(GNC_IS_ACCOUNT(parent), NULL);
2718  g_return_val_if_fail(code, NULL);
2719 
2720  /* first, look for accounts hanging off the current node */
2721  ppriv = GET_PRIVATE(parent);
2722  for (node = ppriv->children; node; node = node->next)
2723  {
2724  child = node->data;
2725  cpriv = GET_PRIVATE(child);
2726  if (g_strcmp0(cpriv->accountCode, code) == 0)
2727  return child;
2728  }
2729 
2730  /* if we are still here, then we haven't found the account yet.
2731  * Recursively search each of the child accounts next */
2732  for (node = ppriv->children; node; node = node->next)
2733  {
2734  child = node->data;
2735  result = gnc_account_lookup_by_code (child, code);
2736  if (result)
2737  return result;
2738  }
2739 
2740  return NULL;
2741 }
Account * gnc_account_lookup_by_code(const Account *parent, const char *code)
Definition: Account.c:2711

◆ gnc_account_lookup_by_full_name()

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

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

Definition at line 2790 of file Account.c.

2792 {
2793  const AccountPrivate *rpriv;
2794  const Account *root;
2795  Account *found;
2796  gchar **names;
2797 
2798  g_return_val_if_fail(GNC_IS_ACCOUNT(any_acc), NULL);
2799  g_return_val_if_fail(name, NULL);
2800 
2801  root = any_acc;
2802  rpriv = GET_PRIVATE(root);
2803  while (rpriv->parent)
2804  {
2805  root = rpriv->parent;
2806  rpriv = GET_PRIVATE(root);
2807  }
2808  names = g_strsplit(name, gnc_get_account_separator_string(), -1);
2809  found = gnc_account_lookup_by_full_name_helper(root, names);
2810  g_strfreev(names);
2811  return found;
2812 }
const gchar * gnc_get_account_separator_string(void)
Definition: Account.c:111

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

2679 {
2680  AccountPrivate *cpriv, *ppriv;
2681  Account *child, *result;
2682  GList *node;
2683 
2684  g_return_val_if_fail(GNC_IS_ACCOUNT(parent), NULL);
2685  g_return_val_if_fail(name, NULL);
2686 
2687  /* first, look for accounts hanging off the current node */
2688  ppriv = GET_PRIVATE(parent);
2689  for (node = ppriv->children; node; node = node->next)
2690  {
2691  child = node->data;
2692  cpriv = GET_PRIVATE(child);
2693  if (g_strcmp0(cpriv->accountName, name) == 0)
2694  return child;
2695  }
2696 
2697  /* if we are still here, then we haven't found the account yet.
2698  * Recursively search each of the child accounts next */
2699  for (node = ppriv->children; node; node = node->next)
2700  {
2701  child = node->data;
2702  result = gnc_account_lookup_by_name (child, name);
2703  if (result)
2704  return result;
2705  }
2706 
2707  return NULL;
2708 }
Account * gnc_account_lookup_by_name(const Account *parent, const char *name)
Definition: Account.c:2678

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

4742 {
4743  GList *descendants;
4744 
4745  descendants = gnc_account_get_descendants(account);
4746  g_list_foreach(descendants, (GFunc)do_one_account, NULL);
4747  g_list_free(descendants);
4748 }
GList * gnc_account_get_descendants(const Account *account)
Definition: Account.c:2630

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

4795 {
4796  const AccountPrivate *priv;
4797  GList *acc_p, *split_p;
4798  Transaction *trans;
4799  Split *s;
4800  int retval;
4801 
4802  if (!acc) return 0;
4803 
4804  /* depth first traversal */
4805  priv = GET_PRIVATE(acc);
4806  for (acc_p = priv->children; acc_p; acc_p = g_list_next(acc_p))
4807  {
4808  retval = gnc_account_tree_staged_transaction_traversal(acc_p->data, stage,
4809  thunk, cb_data);
4810  if (retval) return retval;
4811  }
4812 
4813  /* Now this account */
4814  for (split_p = priv->splits; split_p; split_p = g_list_next(split_p))
4815  {
4816  s = split_p->data;
4817  trans = s->parent;
4818  if (trans && (trans->marker < stage))
4819  {
4820  trans->marker = stage;
4821  if (thunk)
4822  {
4823  retval = thunk(trans, cb_data);
4824  if (retval) return retval;
4825  }
4826  }
4827  }
4828 
4829  return 0;
4830 }
int gnc_account_tree_staged_transaction_traversal(const Account *acc, unsigned int stage, TransactionCallback thunk, void *cb_data)
Definition: Account.c:4791

◆ gnc_engine_add_commit_error_callback()

void gnc_engine_add_commit_error_callback ( EngineCommitErrorCallback  cb,
gpointer  data 
)

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

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

197 {
198  g_error_cb = cb;
199  g_error_cb_data = data;
200 }

◆ gnc_engine_add_init_hook()

void gnc_engine_add_init_hook ( gnc_engine_init_hook_t  hook)

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

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

173 {
174  engine_init_hooks = g_list_append(engine_init_hooks, (gpointer)h);
175 }

◆ 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 - see also qof_init for a method that does not require Guile.

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

139 {
140  gnc_engine_init_part1();
141  gnc_engine_init_part2();
142  gnc_engine_init_part3(argc, argv);
143 }

◆ 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 identically to that function except that it doesn't load the loadable shared module, which means this function will not load the "(gnucash engine)" scheme module.

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

147 {
148  gnc_engine_init_part1();
149  gnc_engine_init_part3(argc, argv);
150 }

◆ gnc_engine_is_initialized()

gboolean gnc_engine_is_initialized ( void  )

check the engine is fully initialized

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

179 {
180  return (engine_is_initialized == 1) ? TRUE : FALSE;
181 }

◆ gnc_engine_shutdown()

void gnc_engine_shutdown ( void  )

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

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

160 {
162  qof_close();
163  engine_is_initialized = 0;
164 }
void qof_log_shutdown(void)
Definition: qoflog.c:198
void qof_close(void)
Safely close down the Query Object Framework.
Definition: qofutil.c:273

◆ gnc_log_default()

void gnc_log_default ( void  )

enable default log modules

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

189 {
190  qof_log_set_default(QOF_LOG_WARNING);
191  qof_log_set_level(GNC_MOD_ROOT, QOF_LOG_WARNING);
192  qof_log_set_level(GNC_MOD_TEST, QOF_LOG_DEBUG);
193 }
void qof_log_set_level(QofLogModule log_module, QofLogLevel level)
Definition: qoflog.c:226
void qof_log_set_default(QofLogLevel log_level)
Definition: qoflog.c:412

◆ xaccAccountBeginStagedTransactionTraversals()

void xaccAccountBeginStagedTransactionTraversals ( const Account account)

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

Definition at line 4703 of file Account.c.

4704 {
4705  AccountPrivate *priv;
4706 
4707  if (!account)
4708  return;
4709  priv = GET_PRIVATE(account);
4711 }
void xaccSplitsBeginStagedTransactionTraversals(GList *splits)
Definition: Account.c:4687

◆ xaccAccountClearReconcilePostpone()

void xaccAccountClearReconcilePostpone ( Account account)

DOCUMENT ME!

Definition at line 4349 of file Account.c.

4350 {
4351  if (!acc) return;
4352 
4353  xaccAccountBeginEdit (acc);
4354  kvp_frame_set_value (acc->inst.kvp_data, "reconcile-info/postpone", NULL);
4355  mark_account (acc);
4356  xaccAccountCommitEdit (acc);
4357 }
KvpFrame * kvp_frame_set_value(KvpFrame *frame, const gchar *path, const KvpValue *value)
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1143
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1184

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

3612 {
3613  gint64 nr, i;
3614 
3615  nr = 0;
3616  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), 0);
3617 
3618  nr = g_list_length(xaccAccountGetSplitList(acc));
3619  if (include_children && (gnc_account_n_children(acc) != 0))
3620  {
3621  for (i=0; i < gnc_account_n_children(acc); i++)
3622  {
3623  nr += xaccAccountCountSplits(gnc_account_nth_child(acc, i), TRUE);
3624  }
3625  }
3626  return nr;
3627 }
SplitList * xaccAccountGetSplitList(const Account *acc)
Definition: Account.c:3603
gint gnc_account_n_children(const Account *account)
Definition: Account.c:2551
gint64 xaccAccountCountSplits(const Account *acc, gboolean include_children)
Definition: Account.c:3611
Account * gnc_account_nth_child(const Account *parent, gint num)
Definition: Account.c:2566

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

3641 {
3642  AccountPrivate *priv;
3643  GList *lot_list;
3644  GList *retval = NULL;
3645 
3646  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
3647 
3648  priv = GET_PRIVATE(acc);
3649  for (lot_list = priv->lots; lot_list; lot_list = lot_list->next)
3650  {
3651  GNCLot *lot = lot_list->data;
3652 
3653  /* If this lot is closed, then ignore it */
3654  if (gnc_lot_is_closed (lot))
3655  continue;
3656 
3657  if (match_func && !(match_func)(lot, user_data))
3658  continue;
3659 
3660  /* Ok, this is a valid lot. Add it to our list of lots */
3661  if (sort_func)
3662  retval = g_list_insert_sorted (retval, lot, sort_func);
3663  else
3664  retval = g_list_prepend (retval, lot);
3665  }
3666 
3667  return retval;
3668 }
gboolean gnc_lot_is_closed(GNCLot *lot)
Definition: gnc-lot.c:301

◆ xaccAccountFindSplitByDesc()

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

Returns a pointer to the split, not a copy.

Definition at line 4563 of file Account.c.

4564 {
4565  Split *split;
4566 
4567  /* Get the split which has a transaction matching the description. */
4568  finder_help_function(acc, description, &split, NULL);
4569  return split;
4570 }

◆ xaccAccountFindTransByDesc()

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

Returns a pointer to the transaction, not a copy.

Definition at line 4578 of file Account.c.

4579 {
4580  Transaction *trans;
4581 
4582  /* Get the translation matching the description. */
4583  finder_help_function(acc, description, NULL, &trans);
4584  return trans;
4585 }

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

4850 {
4851  if (!acc || !proc) return 0;
4853  return xaccAccountStagedTransactionTraversal(acc, 42, proc, data);
4854 }
void xaccAccountBeginStagedTransactionTraversals(const Account *account)
Definition: Account.c:4703
int xaccAccountStagedTransactionTraversal(const Account *acc, unsigned int stage, TransactionCallback thunk, void *cb_data)
Definition: Account.c:4751

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

3822 {
3823  GList *descendants, *node;
3824  GNCPlaceholderType ret = PLACEHOLDER_NONE;
3825 
3826  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), PLACEHOLDER_NONE);
3827  if (xaccAccountGetPlaceholder(acc)) return PLACEHOLDER_THIS;
3828 
3829  descendants = gnc_account_get_descendants(acc);
3830  for (node = descendants; node; node = node->next)
3831  if (xaccAccountGetPlaceholder((Account *) node->data))
3832  {
3833  ret = PLACEHOLDER_CHILD;
3834  break;
3835  }
3836 
3837  g_list_free(descendants);
3838  return ret;
3839 }
GList * gnc_account_get_descendants(const Account *account)
Definition: Account.c:2630
GNCPlaceholderType
Definition: Account.h:1124
gboolean xaccAccountGetPlaceholder(const Account *acc)
Definition: Account.c:3798

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

3846 {
3847  const char *str;
3848 
3849  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
3850 
3851  str = kvp_frame_get_string(acc->inst.kvp_data, "hidden");
3852  return (str && !strcmp(str, "true"));
3853 }

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

3631 {
3632  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
3633  return g_list_copy(GET_PRIVATE(acc)->lots);
3634 }

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

3799 {
3800  const char *str;
3801 
3802  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
3803 
3804  str = kvp_frame_get_string(acc->inst.kvp_data, "placeholder");
3805  return (str && !strcmp(str, "true"));
3806 }

◆ xaccAccountGetReconcileLastDate()

gboolean xaccAccountGetReconcileLastDate ( const Account account,
time64 last_date 
)

DOCUMENT ME!

Definition at line 4190 of file Account.c.

4191 {
4192  KvpValue *v;
4193 
4194  if (!acc) return FALSE;
4195 
4196  v = kvp_frame_get_value(acc->inst.kvp_data, "reconcile-info/last-date");
4197 
4198  if (!v || kvp_value_get_type(v) != KVP_TYPE_GINT64)
4199  return FALSE;
4200 
4201  if (last_date)
4202  *last_date = kvp_value_get_gint64(v);
4203 
4204  return TRUE;
4205 }
gint64 kvp_value_get_gint64(const KvpValue *value)
Definition: kvp_frame.c:1104

◆ xaccAccountGetReconcileLastInterval()

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

DOCUMENT ME!

Definition at line 4226 of file Account.c.

4228 {
4229  KvpValue *v1, *v2;
4230 
4231  if (!acc) return FALSE;
4232 
4233  v1 = kvp_frame_get_value(acc->inst.kvp_data,
4234  "reconcile-info/last-interval/months");
4235  v2 = kvp_frame_get_value(acc->inst.kvp_data,
4236  "reconcile-info/last-interval/days");
4237  if (!v1 || (kvp_value_get_type (v1) != KVP_TYPE_GINT64) ||
4238  !v2 || (kvp_value_get_type (v2) != KVP_TYPE_GINT64))
4239  return FALSE;
4240 
4241  if (months)
4242  *months = kvp_value_get_gint64 (v1);
4243  if (days)
4244  *days = kvp_value_get_gint64 (v2);
4245  return TRUE;
4246 }
gint64 kvp_value_get_gint64(const KvpValue *value)
Definition: kvp_frame.c:1104

◆ xaccAccountGetReconcilePostponeBalance()

gboolean xaccAccountGetReconcilePostponeBalance ( const Account account,
gnc_numeric *  balance 
)

DOCUMENT ME!

Definition at line 4311 of file Account.c.

4313 {
4314  KvpValue *v;
4315 
4316  if (!acc) return FALSE;
4317 
4318  v = kvp_frame_get_value(acc->inst.kvp_data,
4319  "reconcile-info/postpone/balance");
4320  if (!v || kvp_value_get_type (v) != KVP_TYPE_NUMERIC)
4321  return FALSE;
4322 
4323  if (balance)
4324  *balance = kvp_value_get_numeric (v);
4325 
4326  return TRUE;
4327 }

◆ xaccAccountGetReconcilePostponeDate()

gboolean xaccAccountGetReconcilePostponeDate ( const Account account,
time64 postpone_date 
)

DOCUMENT ME!

Definition at line 4274 of file Account.c.

4275 {
4276  KvpValue *v;
4277 
4278  if (!acc) return FALSE;
4279 
4280  v = kvp_frame_get_value(acc->inst.kvp_data, "reconcile-info/postpone/date");
4281  if (!v || kvp_value_get_type (v) != KVP_TYPE_GINT64)
4282  return FALSE;
4283 
4284  if (postpone_date)
4285  *postpone_date = kvp_value_get_gint64 (v);
4286 
4287  return TRUE;
4288 }
gint64 kvp_value_get_gint64(const KvpValue *value)
Definition: kvp_frame.c:1104

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

3604 {
3605  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
3606  xaccAccountSortSplits((Account*)acc, FALSE); // normally a noop
3607  return GET_PRIVATE(acc)->splits;
3608 }
void xaccAccountSortSplits(Account *acc, gboolean force)
Definition: Account.c:1644

◆ xaccAccountGetTaxRelated()

gboolean xaccAccountGetTaxRelated ( const Account account)

DOCUMENT ME!

Definition at line 3694 of file Account.c.

3695 {
3696  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
3697  return kvp_frame_get_gint64(acc->inst.kvp_data, "tax-related");
3698 }

◆ xaccAccountGetTaxUSCode()

const char* xaccAccountGetTaxUSCode ( const Account account)

DOCUMENT ME!

Definition at line 3719 of file Account.c.

3720 {
3721  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
3722  return kvp_frame_get_string(acc->inst.kvp_data, "tax-US/code");
3723 }

◆ xaccAccountGetTaxUSCopyNumber()

gint64 xaccAccountGetTaxUSCopyNumber ( const Account account)

DOCUMENT ME!

Definition at line 3762 of file Account.c.

3763 {
3764  gint64 copy_number;
3765 
3766  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), 1);
3767  copy_number = kvp_frame_get_gint64(acc->inst.kvp_data,
3768  "tax-US/copy-number");
3769  return (copy_number == 0) ? 1 : copy_number;
3770 }

◆ xaccAccountGetTaxUSPayerNameSource()

const char* xaccAccountGetTaxUSPayerNameSource ( const Account account)

DOCUMENT ME!

Definition at line 3742 of file Account.c.

3743 {
3744  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
3745  return kvp_frame_get_string(acc->inst.kvp_data,
3746  "tax-US/payer-name-source");
3747 }

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

4024 {
4025  if (type < 0 || NUM_ACCOUNT_TYPES <= type ) return "";
4026  return _(account_type_name [type]);
4027 }

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

1784 {
1785  AccountPrivate *priv, *opriv;
1786  Account * old_acc = NULL;
1787  Account* lot_account;
1788 
1789  /* errors */
1790  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1791  g_return_if_fail(GNC_IS_LOT(lot));
1792 
1793  /* optimizations */
1794  lot_account = gnc_lot_get_account(lot);
1795  if (lot_account == acc)
1796  return;
1797 
1798  ENTER ("(acc=%p, lot=%p)", acc, lot);
1799 
1800  /* pull it out of the old account */
1801  if (lot_account)
1802  {
1803  old_acc = lot_account;
1804  opriv = GET_PRIVATE(old_acc);
1805  opriv->lots = g_list_remove(opriv->lots, lot);
1806  }
1807 
1808  priv = GET_PRIVATE(acc);
1809  priv->lots = g_list_prepend(priv->lots, lot);
1810  gnc_lot_set_account(lot, acc);
1811 
1812  /* Don't move the splits to the new account. The caller will do this
1813  * if appropriate, and doing it here will not work if we are being
1814  * called from gnc_book_close_period since xaccAccountInsertSplit
1815  * will try to balance capital gains and things aren't ready for that. */
1816 
1817  qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_ADD, NULL);
1818  qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, NULL);
1819 
1820  LEAVE ("(acc=%p, lot=%p)", acc, lot);
1821 }
#define ENTER(format, args...)
Definition: qoflog.h:256
#define LEAVE(format, args...)
Definition: qoflog.h:266
Account * gnc_lot_get_account(const GNCLot *lot)
Definition: gnc-lot.c:311
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition: qofevent.c:230

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

4152 {
4153  switch (t)
4154  {
4155  case ACCT_TYPE_RECEIVABLE:
4156  case ACCT_TYPE_PAYABLE:
4157  return TRUE;
4158  default:
4159  return FALSE;
4160  }
4161 }

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

4139 {
4140  switch (t)
4141  {
4142  case ACCT_TYPE_RECEIVABLE:
4143  case ACCT_TYPE_PAYABLE:
4144  return FALSE;
4145  default:
4148  }
4149 }
gboolean xaccAccountTypesCompatible(GNCAccountType parent_type, GNCAccountType child_type)
Definition: Account.c:4120

◆ xaccAccountIsEquityType()

gboolean xaccAccountIsEquityType ( GNCAccountType  t)

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

Definition at line 4163 of file Account.c.

4164 {
4165  switch (t)
4166  {
4167  case ACCT_TYPE_EQUITY:
4168  return TRUE;
4169  default:
4170  return FALSE;
4171  }
4172 }

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

3869 {
3870  AccountPrivate *priv;
3871 
3872  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
3873 
3874  if (xaccAccountGetHidden(acc))
3875  return TRUE;
3876  priv = GET_PRIVATE(acc);
3877  while ((acc = priv->parent) != NULL)
3878  {
3879  priv = GET_PRIVATE(acc);
3880  if (xaccAccountGetHidden(acc))
3881  return TRUE;
3882  }
3883  return FALSE;
3884 }
gboolean xaccAccountGetHidden(const Account *acc)
Definition: Account.c:3845

◆ xaccAccountMoveAllSplits()

void xaccAccountMoveAllSplits ( Account accfrom,
Account accto 
)

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

Definition at line 1843 of file Account.c.

1844 {
1845  AccountPrivate *from_priv;
1846 
1847  /* errors */
1848  g_return_if_fail(GNC_IS_ACCOUNT(accfrom));
1849  g_return_if_fail(GNC_IS_ACCOUNT(accto));
1850 
1851  /* optimizations */
1852  from_priv = GET_PRIVATE(accfrom);
1853  if (!from_priv->splits || accfrom == accto)
1854  return;
1855 
1856  /* check for book mix-up */
1857  g_return_if_fail (qof_instance_books_equal(accfrom, accto));
1858  ENTER ("(accfrom=%p, accto=%p)", accfrom, accto);
1859 
1860  xaccAccountBeginEdit(accfrom);
1861  xaccAccountBeginEdit(accto);
1862  /* Begin editing both accounts and all transactions in accfrom. */
1863  g_list_foreach(from_priv->splits, (GFunc)xaccPreSplitMove, NULL);
1864 
1865  /* Concatenate accfrom's lists of splits and lots to accto's lists. */
1866  //to_priv->splits = g_list_concat(to_priv->splits, from_priv->splits);
1867  //to_priv->lots = g_list_concat(to_priv->lots, from_priv->lots);
1868 
1869  /* Set appropriate flags. */
1870  //from_priv->balance_dirty = TRUE;
1871  //from_priv->sort_dirty = FALSE;
1872  //to_priv->balance_dirty = TRUE;
1873  //to_priv->sort_dirty = TRUE;
1874 
1875  /*
1876  * Change each split's account back pointer to accto.
1877  * Convert each split's amount to accto's commodity.
1878  * Commit to editing each transaction.
1879  */
1880  g_list_foreach(from_priv->splits, (GFunc)xaccPostSplitMove, (gpointer)accto);
1881 
1882  /* Finally empty accfrom. */
1883  g_assert(from_priv->splits == NULL);
1884  g_assert(from_priv->lots == NULL);
1885  xaccAccountCommitEdit(accfrom);
1886  xaccAccountCommitEdit(accto);
1887 
1888  LEAVE ("(accfrom=%p, accto=%p)", accfrom, accto);
1889 }
#define ENTER(format, args...)
Definition: qoflog.h:256
gboolean qof_instance_books_equal(gconstpointer ptr1, gconstpointer ptr2)
Definition: qofinstance.c:572
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1143
#define LEAVE(format, args...)
Definition: qoflog.h:266
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1184

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

3857 {
3858  g_return_if_fail(GNC_IS_ACCOUNT(acc));
3859 
3860  xaccAccountBeginEdit (acc);
3861  kvp_frame_set_string (acc->inst.kvp_data, "hidden",
3862  val ? "true" : NULL);
3863  mark_account (acc);
3864  xaccAccountCommitEdit (acc);
3865 }
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1143
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1184
void kvp_frame_set_string(KvpFrame *frame, const gchar *path, const gchar *str)
Store a copy of the string at the indicated path.

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

1703 {
1704  AccountPrivate *priv;
1705 
1706  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1707 
1708  priv = GET_PRIVATE(acc);
1709  priv->mark = m;
1710 }

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

3810 {
3811  g_return_if_fail(GNC_IS_ACCOUNT(acc));
3812 
3813  xaccAccountBeginEdit (acc);
3814  kvp_frame_set_string (acc->inst.kvp_data,
3815  "placeholder", val ? "true" : NULL);
3816  mark_account (acc);
3817  xaccAccountCommitEdit (acc);
3818 }
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1143
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1184
void kvp_frame_set_string(KvpFrame *frame, const gchar *path, const gchar *str)
Store a copy of the string at the indicated path.

◆ xaccAccountSetReconcileLastDate()

void xaccAccountSetReconcileLastDate ( Account account,
time64  last_date 
)

DOCUMENT ME!

Definition at line 4211 of file Account.c.

4212 {
4213  if (!acc) return;
4214 
4215  xaccAccountBeginEdit (acc);
4216  kvp_frame_set_gint64 (acc->inst.kvp_data,
4217  "/reconcile-info/last-date", last_date);
4218  mark_account (acc);
4219  xaccAccountCommitEdit (acc);
4220 }
void kvp_frame_set_gint64(KvpFrame *frame, const gchar *path, gint64 ival)
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1143
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1184

◆ xaccAccountSetReconcileLastInterval()

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

DOCUMENT ME!

Definition at line 4252 of file Account.c.

4253 {
4254  KvpFrame *frame;
4255  if (!acc) return;
4256 
4257  xaccAccountBeginEdit (acc);
4258 
4259  frame = kvp_frame_get_frame_slash (acc->inst.kvp_data,
4260  "/reconcile-info/last-interval");
4261  g_assert(frame);
4262 
4263  kvp_frame_set_gint64 (frame, "months", months);
4264  kvp_frame_set_gint64 (frame, "days", days);
4265 
4266  mark_account (acc);
4267  xaccAccountCommitEdit (acc);
4268 }
void kvp_frame_set_gint64(KvpFrame *frame, const gchar *path, gint64 ival)
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1143
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1184

◆ xaccAccountSetReconcilePostponeBalance()

void xaccAccountSetReconcilePostponeBalance ( Account account,
gnc_numeric  balance 
)

DOCUMENT ME!

Definition at line 4333 of file Account.c.

4334 {
4335  if (!acc) return;
4336 
4337  xaccAccountBeginEdit (acc);
4338  kvp_frame_set_gnc_numeric (acc->inst.kvp_data,
4339  "/reconcile-info/postpone/balance", balance);
4340  mark_account (acc);
4341  xaccAccountCommitEdit (acc);
4342 }
#define kvp_frame_set_gnc_numeric
Definition: kvp_frame.h:156
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1143
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1184

◆ xaccAccountSetReconcilePostponeDate()

void xaccAccountSetReconcilePostponeDate ( Account account,
time64  postpone_date 
)

DOCUMENT ME!

Definition at line 4294 of file Account.c.

4295 {
4296  if (!acc) return;
4297 
4298  xaccAccountBeginEdit (acc);
4299 
4300  /* XXX this should be using timespecs, not gints !! */
4301  kvp_frame_set_gint64 (acc->inst.kvp_data,
4302  "reconcile-info/postpone/date", postpone_date);
4303  mark_account (acc);
4304  xaccAccountCommitEdit (acc);
4305 }
void kvp_frame_set_gint64(KvpFrame *frame, const gchar *path, gint64 ival)
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1143
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1184

◆ xaccAccountSetTaxRelated()

void xaccAccountSetTaxRelated ( Account account,
gboolean  tax_related 
)

DOCUMENT ME!

Definition at line 3701 of file Account.c.

3702 {
3703  KvpValue *new_value;
3704 
3705  g_return_if_fail(GNC_IS_ACCOUNT(acc));
3706 
3707  if (tax_related)
3708  new_value = kvp_value_new_gint64 (tax_related);
3709  else
3710  new_value = NULL;
3711 
3712  xaccAccountBeginEdit (acc);
3713  kvp_frame_set_slot_nc(acc->inst.kvp_data, "tax-related", new_value);
3714  mark_account (acc);
3715  xaccAccountCommitEdit (acc);
3716 }
void kvp_frame_set_slot_nc(KvpFrame *frame, const gchar *key, KvpValue *value)
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1143
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1184

◆ xaccAccountSetTaxUSCode()

void xaccAccountSetTaxUSCode ( Account account,
const char *  code 
)

DOCUMENT ME!

Definition at line 3726 of file Account.c.

3727 {
3728  g_return_if_fail(GNC_IS_ACCOUNT(acc));
3729 
3730  xaccAccountBeginEdit (acc);
3731  kvp_frame_set_string (acc->inst.kvp_data, "/tax-US/code", code);
3732  if (!code)
3733  {
3734  KvpFrame *frame = NULL;
3735  kvp_frame_set_frame (acc->inst.kvp_data, "/tax-US", frame);
3736  }
3737  mark_account (acc);
3738  xaccAccountCommitEdit (acc);
3739 }
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1143
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1184
void kvp_frame_set_string(KvpFrame *frame, const gchar *path, const gchar *str)
Store a copy of the string at the indicated path.

◆ xaccAccountSetTaxUSCopyNumber()

void xaccAccountSetTaxUSCopyNumber ( Account account,
gint64  copy_number 
)

DOCUMENT ME!

Definition at line 3773 of file Account.c.

3774 {
3775  g_return_if_fail(GNC_IS_ACCOUNT(acc));
3776 
3777  xaccAccountBeginEdit (acc);
3778  if (copy_number != 0)
3779  kvp_frame_set_gint64 (acc->inst.kvp_data, "/tax-US/copy-number", copy_number);
3780  else
3781  {
3782  KvpFrame * frame;
3783  KvpValue *value;
3784 
3785  value = NULL;
3786  frame = kvp_frame_set_value_nc (acc->inst.kvp_data,
3787  "/tax-US/copy-number", value);
3788  if (!frame) kvp_value_delete (value);
3789  }
3790  mark_account (acc);
3791  xaccAccountCommitEdit (acc);
3792 }
void kvp_frame_set_gint64(KvpFrame *frame, const gchar *path, gint64 ival)
KvpFrame * kvp_frame_set_value_nc(KvpFrame *frame, const gchar *path, KvpValue *value)
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1143
void kvp_value_delete(KvpValue *value)
Definition: kvp_frame.c:1064
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1184

◆ xaccAccountSetTaxUSPayerNameSource()

void xaccAccountSetTaxUSPayerNameSource ( Account account,
const char *  source 
)

DOCUMENT ME!

Definition at line 3750 of file Account.c.

3751 {
3752  g_return_if_fail(GNC_IS_ACCOUNT(acc));
3753 
3754  xaccAccountBeginEdit (acc);
3755  kvp_frame_set_string (acc->inst.kvp_data,
3756  "/tax-US/payer-name-source", source);
3757  mark_account (acc);
3758  xaccAccountCommitEdit (acc);
3759 }
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1143
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1184
void kvp_frame_set_string(KvpFrame *frame, const gchar *path, const gchar *str)
Store a copy of the string at the indicated path.

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

4755 {
4756  AccountPrivate *priv;
4757  GList *split_p;
4758  GList *next;
4759  Transaction *trans;
4760  Split *s;
4761  int retval;
4762 
4763  if (!acc) return 0;
4764 
4765  priv = GET_PRIVATE(acc);
4766  for (split_p = priv->splits; split_p; split_p = next)
4767  {
4768  /* Get the next element in the split list now, just in case some
4769  * naughty thunk destroys the one we're using. This reduces, but
4770  * does not eliminate, the possibility of undefined results if
4771  * a thunk removes splits from this account. */
4772  next = g_list_next(split_p);
4773 
4774  s = split_p->data;
4775  trans = s->parent;
4776  if (trans && (trans->marker < stage))
4777  {
4778  trans->marker = stage;
4779  if (thunk)
4780  {
4781  retval = thunk(trans, cb_data);
4782  if (retval) return retval;
4783  }
4784  }
4785  }
4786 
4787  return 0;
4788 }

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

3985 {
3986  GNCAccountType type;
3987  gboolean rc;
3988  rc = xaccAccountStringToType(str, &type);
3989  if (FALSE == rc) return ACCT_TYPE_INVALID;
3990  return type;
3991 }
gboolean xaccAccountStringToType(const char *str, GNCAccountType *type)
Definition: Account.c:3950
GNCAccountType
Definition: Account.h:96

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

3951 {
3952 
3953  GNC_RETURN_ON_MATCH(NONE);
3954  GNC_RETURN_ON_MATCH(BANK);
3955  GNC_RETURN_ON_MATCH(CASH);
3956  GNC_RETURN_ON_MATCH(CREDIT);
3957  GNC_RETURN_ON_MATCH(ASSET);
3958  GNC_RETURN_ON_MATCH(LIABILITY);
3959  GNC_RETURN_ON_MATCH(STOCK);
3960  GNC_RETURN_ON_MATCH(MUTUAL);
3961  GNC_RETURN_ON_MATCH(CURRENCY);
3962  GNC_RETURN_ON_MATCH(INCOME);
3963  GNC_RETURN_ON_MATCH(EXPENSE);
3964  GNC_RETURN_ON_MATCH(EQUITY);
3965  GNC_RETURN_ON_MATCH(RECEIVABLE);
3966  GNC_RETURN_ON_MATCH(PAYABLE);
3967  GNC_RETURN_ON_MATCH(ROOT);
3968  GNC_RETURN_ON_MATCH(TRADING);
3969  GNC_RETURN_ON_MATCH(CHECKING);
3970  GNC_RETURN_ON_MATCH(SAVINGS);
3971  GNC_RETURN_ON_MATCH(MONEYMRKT);
3972  GNC_RETURN_ON_MATCH(CREDITLINE);
3973 
3974  PERR("asked to translate unknown account type string %s.\n",
3975  str ? str : "(null)");
3976 
3977  return(FALSE);
3978 }
#define PERR(format, args...)
Definition: qoflog.h:232

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

3914 {
3915  switch (type)
3916  {
3917  GNC_RETURN_ENUM_AS_STRING(NONE);
3918  GNC_RETURN_ENUM_AS_STRING(BANK);
3919  GNC_RETURN_ENUM_AS_STRING(CASH);
3920  GNC_RETURN_ENUM_AS_STRING(CREDIT);
3921  GNC_RETURN_ENUM_AS_STRING(ASSET);
3922  GNC_RETURN_ENUM_AS_STRING(LIABILITY);
3923  GNC_RETURN_ENUM_AS_STRING(STOCK);
3924  GNC_RETURN_ENUM_AS_STRING(MUTUAL);
3925  GNC_RETURN_ENUM_AS_STRING(CURRENCY);
3926  GNC_RETURN_ENUM_AS_STRING(INCOME);
3927  GNC_RETURN_ENUM_AS_STRING(EXPENSE);
3928  GNC_RETURN_ENUM_AS_STRING(EQUITY);
3929  GNC_RETURN_ENUM_AS_STRING(RECEIVABLE);
3930  GNC_RETURN_ENUM_AS_STRING(PAYABLE);
3931  GNC_RETURN_ENUM_AS_STRING(ROOT);
3932  GNC_RETURN_ENUM_AS_STRING(TRADING);
3933  GNC_RETURN_ENUM_AS_STRING(CHECKING);
3934  GNC_RETURN_ENUM_AS_STRING(SAVINGS);
3935  GNC_RETURN_ENUM_AS_STRING(MONEYMRKT);
3936  GNC_RETURN_ENUM_AS_STRING(CREDITLINE);
3937  default:
3938  PERR ("asked to translate unknown account type %d.\n", type);
3939  break;
3940  }
3941  return(NULL);
3942 }
#define PERR(format, args...)
Definition: qoflog.h:232

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

4122 {
4123  return ((xaccParentAccountTypesCompatibleWith (parent_type) &
4124  (1 << child_type))
4125  != 0);
4126 }
guint32 xaccParentAccountTypesCompatibleWith(GNCAccountType type)
Definition: Account.c:4073

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

4034 {
4035  switch (type)
4036  {
4037  case ACCT_TYPE_BANK:
4038  case ACCT_TYPE_CASH:
4039  case ACCT_TYPE_ASSET:
4040  case ACCT_TYPE_CREDIT:
4041  case ACCT_TYPE_LIABILITY:
4042  case ACCT_TYPE_INCOME:
4043  case ACCT_TYPE_EXPENSE:
4044  case ACCT_TYPE_EQUITY:
4045  return
4046  (1 << ACCT_TYPE_BANK) |
4047  (1 << ACCT_TYPE_CASH) |
4048  (1 << ACCT_TYPE_ASSET) |
4049  (1 << ACCT_TYPE_CREDIT) |
4050  (1 << ACCT_TYPE_LIABILITY) |
4051  (1 << ACCT_TYPE_INCOME) |
4052  (1 << ACCT_TYPE_EXPENSE) |
4053  (1 << ACCT_TYPE_EQUITY);
4054  case ACCT_TYPE_STOCK:
4055  case ACCT_TYPE_MUTUAL:
4056  case ACCT_TYPE_CURRENCY:
4057  return
4058  (1 << ACCT_TYPE_STOCK) |
4059  (1 << ACCT_TYPE_MUTUAL) |
4060  (1 << ACCT_TYPE_CURRENCY);
4061  case ACCT_TYPE_RECEIVABLE:
4062  return (1 << ACCT_TYPE_RECEIVABLE);
4063  case ACCT_TYPE_PAYABLE:
4064  return (1 << ACCT_TYPE_PAYABLE);
4065  case ACCT_TYPE_TRADING:
4066  return (1 << ACCT_TYPE_TRADING);
4067  default:
4068  PERR("bad account type: %d", type);
4069  return 0;
4070  }
4071 }
#define PERR(format, args...)
Definition: qoflog.h:232

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

4130 {
4131  guint32 mask = (1 << NUM_ACCOUNT_TYPES) - 1;
4132  mask &= ~((1 << ACCT_TYPE_CURRENCY) | /* DEPRECATED */
4133  (1 << ACCT_TYPE_ROOT)); /* ROOT */
4134 
4135  return mask;
4136 }

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

1714 {
1715  Account *root;
1716 
1717  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1718 
1719  root = gnc_account_get_root(acc);
1720  xaccClearMarkDown(root ? root : acc, val);
1721 }
void xaccClearMarkDown(Account *acc, short val)
Definition: Account.c:1724
Account * gnc_account_get_root(Account *acc)
Definition: Account.c:2505

◆ xaccClearMarkDown()

void xaccClearMarkDown ( Account account,
short  val 
)

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

Definition at line 1724 of file Account.c.

1725 {
1726  AccountPrivate *priv;
1727  GList *node;
1728 
1729  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1730 
1731  priv = GET_PRIVATE(acc);
1732  priv->mark = val;
1733  for (node = priv->children; node; node = node->next)
1734  {
1735  xaccClearMarkDown(node->data, val);
1736  }
1737 }
void xaccClearMarkDown(Account *acc, short val)
Definition: Account.c:1724

◆ xaccParentAccountTypesCompatibleWith()

guint32 xaccParentAccountTypesCompatibleWith ( GNCAccountType  type)

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

Definition at line 4073 of file Account.c.

4074 {
4075  switch (type)
4076  {
4077  case ACCT_TYPE_BANK:
4078  case ACCT_TYPE_CASH:
4079  case ACCT_TYPE_ASSET:
4080  case ACCT_TYPE_STOCK:
4081  case ACCT_TYPE_MUTUAL:
4082  case ACCT_TYPE_CURRENCY:
4083  case ACCT_TYPE_CREDIT:
4084  case ACCT_TYPE_LIABILITY:
4085  case ACCT_TYPE_RECEIVABLE:
4086  case ACCT_TYPE_PAYABLE:
4087  return
4088  (1 << ACCT_TYPE_BANK) |
4089  (1 << ACCT_TYPE_CASH) |
4090  (1 << ACCT_TYPE_ASSET) |
4091  (1 << ACCT_TYPE_STOCK) |
4092  (1 << ACCT_TYPE_MUTUAL) |
4093  (1 << ACCT_TYPE_CURRENCY) |
4094  (1 << ACCT_TYPE_CREDIT) |
4095  (1 << ACCT_TYPE_LIABILITY) |
4096  (1 << ACCT_TYPE_RECEIVABLE) |
4097  (1 << ACCT_TYPE_PAYABLE) |
4098  (1 << ACCT_TYPE_ROOT);
4099  case ACCT_TYPE_INCOME:
4100  case ACCT_TYPE_EXPENSE:
4101  return
4102  (1 << ACCT_TYPE_INCOME) |
4103  (1 << ACCT_TYPE_EXPENSE) |
4104  (1 << ACCT_TYPE_ROOT);
4105  case ACCT_TYPE_EQUITY:
4106  return
4107  (1 << ACCT_TYPE_EQUITY) |
4108  (1 << ACCT_TYPE_ROOT);
4109  case ACCT_TYPE_TRADING:
4110  return
4111  (1 << ACCT_TYPE_TRADING) |
4112  (1 << ACCT_TYPE_ROOT);
4113  default:
4114  PERR("bad account type: %d", type);
4115  return 0;
4116  }
4117 }
#define PERR(format, args...)
Definition: qoflog.h:232

◆ xaccSplitsBeginStagedTransactionTraversals()

void xaccSplitsBeginStagedTransactionTraversals ( SplitList splits)

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

Definition at line 4687 of file Account.c.

4688 {
4689  GList *lp;
4690 
4691  for (lp = splits; lp; lp = lp->next)
4692  {
4693  Split *s = lp->data;
4694  Transaction *trans = s->parent;
4695 
4696  if (trans)
4697  trans->marker = 0;
4698  }
4699 }

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

4715 {
4716  if (trans == NULL) return FALSE;
4717 
4718  if (trans->marker < stage)
4719  {
4720  trans->marker = stage;
4721  return TRUE;
4722  }
4723 
4724  return FALSE;
4725 }