GnuCash  2.6.16
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 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 1433 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 967 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 1119 of file Account.h.

1120 {
1121  PLACEHOLDER_NONE,
1122  PLACEHOLDER_THIS,
1123  PLACEHOLDER_CHILD,
GNCPlaceholderType
Definition: Account.h:1119

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

4440 {
4441  if (!acc) return NULL;
4442 
4443  if (xaccAccountIsPriced(acc))
4444  {
4445  KvpValue *value = kvp_frame_get_slot(acc->inst.kvp_data, "old-quote-tz");
4446  if (value) return (kvp_value_get_string(value));
4447  }
4448  return NULL;
4449 }
gboolean xaccAccountIsPriced(const Account *acc)
Definition: Account.c:4135
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 4419 of file Account.c.

4420 {
4421  if (!acc) return;
4422 
4423  xaccAccountBeginEdit(acc);
4424  if (xaccAccountIsPriced(acc))
4425  {
4426  kvp_frame_set_slot_nc(acc->inst.kvp_data,
4427  "old-quote-tz",
4428  tz ? kvp_value_new_string(tz) : NULL);
4429  mark_account (acc);
4430  }
4431  qof_instance_set_dirty(&acc->inst);
4432  xaccAccountCommitEdit(acc);
4433 }
gboolean xaccAccountIsPriced(const Account *acc)
Definition: Account.c:4135
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 4701 of file Account.c.

4702 {
4703  GList *descendants;
4704 
4705  descendants = gnc_account_get_descendants(account);
4706  g_list_foreach(descendants, (GFunc)do_one_account, NULL);
4707  g_list_free(descendants);
4708 }
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 4751 of file Account.c.

4755 {
4756  const AccountPrivate *priv;
4757  GList *acc_p, *split_p;
4758  Transaction *trans;
4759  Split *s;
4760  int retval;
4761 
4762  if (!acc) return 0;
4763 
4764  /* depth first traversal */
4765  priv = GET_PRIVATE(acc);
4766  for (acc_p = priv->children; acc_p; acc_p = g_list_next(acc_p))
4767  {
4768  retval = gnc_account_tree_staged_transaction_traversal(acc_p->data, stage,
4769  thunk, cb_data);
4770  if (retval) return retval;
4771  }
4772 
4773  /* Now this account */
4774  for (split_p = priv->splits; split_p; split_p = g_list_next(split_p))
4775  {
4776  s = split_p->data;
4777  trans = s->parent;
4778  if (trans && (trans->marker < stage))
4779  {
4780  trans->marker = stage;
4781  if (thunk)
4782  {
4783  retval = thunk(trans, cb_data);
4784  if (retval) return retval;
4785  }
4786  }
4787  }
4788 
4789  return 0;
4790 }
int gnc_account_tree_staged_transaction_traversal(const Account *acc, unsigned int stage, TransactionCallback thunk, void *cb_data)
Definition: Account.c:4751

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

4664 {
4665  AccountPrivate *priv;
4666 
4667  if (!account)
4668  return;
4669  priv = GET_PRIVATE(account);
4671 }
void xaccSplitsBeginStagedTransactionTraversals(GList *splits)
Definition: Account.c:4647

◆ xaccAccountClearReconcilePostpone()

void xaccAccountClearReconcilePostpone ( Account account)

DOCUMENT ME!

Definition at line 4309 of file Account.c.

4310 {
4311  if (!acc) return;
4312 
4313  xaccAccountBeginEdit (acc);
4314  kvp_frame_set_value (acc->inst.kvp_data, "reconcile-info/postpone", NULL);
4315  mark_account (acc);
4316  xaccAccountCommitEdit (acc);
4317 }
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 4523 of file Account.c.

4524 {
4525  Split *split;
4526 
4527  /* Get the split which has a transaction matching the description. */
4528  finder_help_function(acc, description, &split, NULL);
4529  return split;
4530 }

◆ xaccAccountFindTransByDesc()

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

Returns a pointer to the transaction, not a copy.

Definition at line 4538 of file Account.c.

4539 {
4540  Transaction *trans;
4541 
4542  /* Get the translation matching the description. */
4543  finder_help_function(acc, description, NULL, &trans);
4544  return trans;
4545 }

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

4810 {
4811  if (!acc || !proc) return 0;
4813  return xaccAccountStagedTransactionTraversal(acc, 42, proc, data);
4814 }
void xaccAccountBeginStagedTransactionTraversals(const Account *account)
Definition: Account.c:4663
int xaccAccountStagedTransactionTraversal(const Account *acc, unsigned int stage, TransactionCallback thunk, void *cb_data)
Definition: Account.c:4711

◆ 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:1119
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 4150 of file Account.c.

4151 {
4152  KvpValue *v;
4153 
4154  if (!acc) return FALSE;
4155 
4156  v = kvp_frame_get_value(acc->inst.kvp_data, "reconcile-info/last-date");
4157 
4158  if (!v || kvp_value_get_type(v) != KVP_TYPE_GINT64)
4159  return FALSE;
4160 
4161  if (last_date)
4162  *last_date = kvp_value_get_gint64(v);
4163 
4164  return TRUE;
4165 }
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 4186 of file Account.c.

4188 {
4189  KvpValue *v1, *v2;
4190 
4191  if (!acc) return FALSE;
4192 
4193  v1 = kvp_frame_get_value(acc->inst.kvp_data,
4194  "reconcile-info/last-interval/months");
4195  v2 = kvp_frame_get_value(acc->inst.kvp_data,
4196  "reconcile-info/last-interval/days");
4197  if (!v1 || (kvp_value_get_type (v1) != KVP_TYPE_GINT64) ||
4198  !v2 || (kvp_value_get_type (v2) != KVP_TYPE_GINT64))
4199  return FALSE;
4200 
4201  if (months)
4202  *months = kvp_value_get_gint64 (v1);
4203  if (days)
4204  *days = kvp_value_get_gint64 (v2);
4205  return TRUE;
4206 }
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 4271 of file Account.c.

4273 {
4274  KvpValue *v;
4275 
4276  if (!acc) return FALSE;
4277 
4278  v = kvp_frame_get_value(acc->inst.kvp_data,
4279  "reconcile-info/postpone/balance");
4280  if (!v || kvp_value_get_type (v) != KVP_TYPE_NUMERIC)
4281  return FALSE;
4282 
4283  if (balance)
4284  *balance = kvp_value_get_numeric (v);
4285 
4286  return TRUE;
4287 }

◆ xaccAccountGetReconcilePostponeDate()

gboolean xaccAccountGetReconcilePostponeDate ( const Account account,
time64 postpone_date 
)

DOCUMENT ME!

Definition at line 4234 of file Account.c.

4235 {
4236  KvpValue *v;
4237 
4238  if (!acc) return FALSE;
4239 
4240  v = kvp_frame_get_value(acc->inst.kvp_data, "reconcile-info/postpone/date");
4241  if (!v || kvp_value_get_type (v) != KVP_TYPE_GINT64)
4242  return FALSE;
4243 
4244  if (postpone_date)
4245  *postpone_date = kvp_value_get_gint64 (v);
4246 
4247  return TRUE;
4248 }
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 4111 of file Account.c.

4112 {
4113  switch (t)
4114  {
4115  case ACCT_TYPE_RECEIVABLE:
4116  case ACCT_TYPE_PAYABLE:
4117  return TRUE;
4118  default:
4119  return FALSE;
4120  }
4121 }

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

4099 {
4100  switch (t)
4101  {
4102  case ACCT_TYPE_RECEIVABLE:
4103  case ACCT_TYPE_PAYABLE:
4104  return FALSE;
4105  default:
4108  }
4109 }
gboolean xaccAccountTypesCompatible(GNCAccountType parent_type, GNCAccountType child_type)
Definition: Account.c:4080

◆ xaccAccountIsEquityType()

gboolean xaccAccountIsEquityType ( GNCAccountType  t)

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

Definition at line 4123 of file Account.c.

4124 {
4125  switch (t)
4126  {
4127  case ACCT_TYPE_EQUITY:
4128  return TRUE;
4129  default:
4130  return FALSE;
4131  }
4132 }

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

4172 {
4173  if (!acc) return;
4174 
4175  xaccAccountBeginEdit (acc);
4176  kvp_frame_set_gint64 (acc->inst.kvp_data,
4177  "/reconcile-info/last-date", last_date);
4178  mark_account (acc);
4179  xaccAccountCommitEdit (acc);
4180 }
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 4212 of file Account.c.

4213 {
4214  KvpFrame *frame;
4215  if (!acc) return;
4216 
4217  xaccAccountBeginEdit (acc);
4218 
4219  frame = kvp_frame_get_frame_slash (acc->inst.kvp_data,
4220  "/reconcile-info/last-interval");
4221  g_assert(frame);
4222 
4223  kvp_frame_set_gint64 (frame, "months", months);
4224  kvp_frame_set_gint64 (frame, "days", days);
4225 
4226  mark_account (acc);
4227  xaccAccountCommitEdit (acc);
4228 }
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 4293 of file Account.c.

4294 {
4295  if (!acc) return;
4296 
4297  xaccAccountBeginEdit (acc);
4298  kvp_frame_set_gnc_numeric (acc->inst.kvp_data,
4299  "/reconcile-info/postpone/balance", balance);
4300  mark_account (acc);
4301  xaccAccountCommitEdit (acc);
4302 }
#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 4254 of file Account.c.

4255 {
4256  if (!acc) return;
4257 
4258  xaccAccountBeginEdit (acc);
4259 
4260  /* XXX this should be using timespecs, not gints !! */
4261  kvp_frame_set_gint64 (acc->inst.kvp_data,
4262  "reconcile-info/postpone/date", postpone_date);
4263  mark_account (acc);
4264  xaccAccountCommitEdit (acc);
4265 }
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 4711 of file Account.c.

4715 {
4716  AccountPrivate *priv;
4717  GList *split_p;
4718  GList *next;
4719  Transaction *trans;
4720  Split *s;
4721  int retval;
4722 
4723  if (!acc) return 0;
4724 
4725  priv = GET_PRIVATE(acc);
4726  for (split_p = priv->splits; split_p; split_p = next)
4727  {
4728  /* Get the next element in the split list now, just in case some
4729  * naughty thunk destroys the one we're using. This reduces, but
4730  * does not eliminate, the possibility of undefined results if
4731  * a thunk removes splits from this account. */
4732  next = g_list_next(split_p);
4733 
4734  s = split_p->data;
4735  trans = s->parent;
4736  if (trans && (trans->marker < stage))
4737  {
4738  trans->marker = stage;
4739  if (thunk)
4740  {
4741  retval = thunk(trans, cb_data);
4742  if (retval) return retval;
4743  }
4744  }
4745  }
4746 
4747  return 0;
4748 }

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

4082 {
4083  return ((xaccParentAccountTypesCompatibleWith (parent_type) &
4084  (1 << child_type))
4085  != 0);
4086 }
guint32 xaccParentAccountTypesCompatibleWith(GNCAccountType type)
Definition: Account.c:4033

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

4090 {
4091  guint32 mask = (1 << NUM_ACCOUNT_TYPES) - 1;
4092  mask &= ~((1 << ACCT_TYPE_CURRENCY) | /* DEPRECATED */
4093  (1 << ACCT_TYPE_ROOT)); /* ROOT */
4094 
4095  return mask;
4096 }

◆ 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 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_STOCK:
4041  case ACCT_TYPE_MUTUAL:
4042  case ACCT_TYPE_CURRENCY:
4043  case ACCT_TYPE_CREDIT:
4044  case ACCT_TYPE_LIABILITY:
4045  case ACCT_TYPE_RECEIVABLE:
4046  case ACCT_TYPE_PAYABLE:
4047  return
4048  (1 << ACCT_TYPE_BANK) |
4049  (1 << ACCT_TYPE_CASH) |
4050  (1 << ACCT_TYPE_ASSET) |
4051  (1 << ACCT_TYPE_STOCK) |
4052  (1 << ACCT_TYPE_MUTUAL) |
4053  (1 << ACCT_TYPE_CURRENCY) |
4054  (1 << ACCT_TYPE_CREDIT) |
4055  (1 << ACCT_TYPE_LIABILITY) |
4056  (1 << ACCT_TYPE_RECEIVABLE) |
4057  (1 << ACCT_TYPE_PAYABLE) |
4058  (1 << ACCT_TYPE_ROOT);
4059  case ACCT_TYPE_INCOME:
4060  case ACCT_TYPE_EXPENSE:
4061  return
4062  (1 << ACCT_TYPE_INCOME) |
4063  (1 << ACCT_TYPE_EXPENSE) |
4064  (1 << ACCT_TYPE_ROOT);
4065  case ACCT_TYPE_EQUITY:
4066  return
4067  (1 << ACCT_TYPE_EQUITY) |
4068  (1 << ACCT_TYPE_ROOT);
4069  case ACCT_TYPE_TRADING:
4070  return
4071  (1 << ACCT_TYPE_TRADING) |
4072  (1 << ACCT_TYPE_ROOT);
4073  default:
4074  PERR("bad account type: %d", type);
4075  return 0;
4076  }
4077 }
#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 4647 of file Account.c.

4648 {
4649  GList *lp;
4650 
4651  for (lp = splits; lp; lp = lp->next)
4652  {
4653  Split *s = lp->data;
4654  Transaction *trans = s->parent;
4655 
4656  if (trans)
4657  trans->marker = 0;
4658  }
4659 }

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

4675 {
4676  if (trans == NULL) return FALSE;
4677 
4678  if (trans->marker < stage)
4679  {
4680  trans->marker = stage;
4681  return TRUE;
4682  }
4683 
4684  return FALSE;
4685 }