GnuCash  2.7.0
Files | Data Structures | Macros | Typedefs | Enumerations | Functions

Splits are grouped into Accounts which are also known as "Ledgers" in accounting practice. More...

Files

file  Account.h
 Account handling public routines.
 

Data Structures

struct  AccountClass
 
struct  GncImportMatchMap
 

Macros

#define GNC_TYPE_ACCOUNT   (gnc_account_get_type ())
 
#define GNC_ACCOUNT(o)   (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_ACCOUNT, Account))
 
#define GNC_ACCOUNT_CLASS(k)   (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_ACCOUNT, AccountClass))
 
#define GNC_IS_ACCOUNT(o)   (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_ACCOUNT))
 
#define GNC_IS_ACCOUNT_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_ACCOUNT))
 
#define GNC_ACCOUNT_GET_CLASS(o)   (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_ACCOUNT, AccountClass))
 

Typedefs

typedef gnc_numeric(* xaccGetBalanceFn) (const Account *account)
 
typedef gnc_numeric(* xaccGetBalanceInCurrencyFn) (const Account *account, const gnc_commodity *report_commodity, gboolean include_children)
 
typedef gnc_numeric(* xaccGetBalanceAsOfDateFn) (Account *account, time64 date)
 
typedef void(* AccountCb) (Account *a, gpointer data)
 
typedef gpointer(* AccountCb2) (Account *a, gpointer data)
 

Enumerations

enum  GNCAccountType {
  ACCT_TYPE_INVALID = -1, ACCT_TYPE_NONE = -1, ACCT_TYPE_BANK = 0, ACCT_TYPE_CASH = 1,
  ACCT_TYPE_CREDIT = 3, ACCT_TYPE_ASSET = 2, ACCT_TYPE_LIABILITY = 4, ACCT_TYPE_STOCK = 5,
  ACCT_TYPE_MUTUAL = 6, ACCT_TYPE_CURRENCY = 7, ACCT_TYPE_INCOME = 8, ACCT_TYPE_EXPENSE = 9,
  ACCT_TYPE_EQUITY = 10, ACCT_TYPE_RECEIVABLE = 11, ACCT_TYPE_PAYABLE = 12, ACCT_TYPE_ROOT = 13,
  ACCT_TYPE_TRADING = 14, NUM_ACCOUNT_TYPES = 15, ACCT_TYPE_CHECKING = 15, ACCT_TYPE_SAVINGS = 16,
  ACCT_TYPE_MONEYMRKT = 17, ACCT_TYPE_CREDITLINE = 18, ACCT_TYPE_LAST
}
 The account types are used to determine how the transaction data in the account is displayed. More...
 

Functions

GType gnc_account_get_type (void)
 Returns the GType type system description of the Account class. More...
 
gchar * gnc_account_name_violations_errmsg (const gchar *separator, GList *invalid_account_names)
 Composes a translatable error message showing which account names clash with the current account separator. More...
 
GList * gnc_account_list_name_violations (QofBook *book, const gchar *separator)
 Runs through all the accounts and returns a list of account names that contain the provided separator character. More...
 
void xaccAccountSetReconcileChildrenStatus (Account *account, gboolean status)
 DOCUMENT ME!
 
gboolean xaccAccountGetReconcileChildrenStatus (const Account *account)
 DOCUMENT ME!
 
gboolean xaccAccountHasAncestor (const Account *acc, const Account *ancestor)
 Returns true if the account is 'ancestor' or has 'ancestor' as an ancestor. More...
 

Account Constructors, Edit/Commit, Comparison

AccountxaccMallocAccount (QofBook *book)
 Constructor.
 
Accountgnc_account_create_root (QofBook *book)
 Create a new root level account. More...
 
AccountxaccCloneAccount (const Account *source, QofBook *book)
 The xaccCloneAccount() routine makes a simple copy of the indicated account, placing it in the indicated book. More...
 
void xaccAccountBeginEdit (Account *account)
 The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account updates. More...
 
void xaccAccountCommitEdit (Account *account)
 ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account updates. More...
 
void xaccAccountDestroy (Account *account)
 The xaccAccountDestroy() routine can be used to get rid of an account. More...
 
gboolean xaccAccountEqual (const Account *a, const Account *b, gboolean check_guids)
 Compare two accounts for equality - this is a deep compare. More...
 
int xaccAccountOrder (const Account *account_1, const Account *account_2)
 The xaccAccountOrder() subroutine defines a sorting order on accounts. More...
 

Account lookup and GncGUID routines

const gchar * gnc_get_account_separator_string (void)
 Returns the account separation character chosen by the user. More...
 
gunichar gnc_get_account_separator (void)
 
void gnc_set_account_separator (const gchar *separator)
 
Accountgnc_book_get_root_account (QofBook *book)
 
void gnc_book_set_root_account (QofBook *book, Account *root)
 
AccountxaccAccountLookup (const GncGUID *guid, QofBook *book)
 The xaccAccountLookup() subroutine will return the account associated with the given id, or NULL if there is no such account. More...
 
#define xaccAccountGetGUID(X)   qof_entity_get_guid(QOF_INSTANCE(X))
 
#define xaccAccountReturnGUID(X)   (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
 
#define xaccAccountLookupDirect(g, b)   xaccAccountLookup(&(g),b)
 

Account general setters/getters

QofBook * gnc_account_get_book (const Account *account)
 
void xaccAccountSetType (Account *account, GNCAccountType)
 Set the account's type.
 
void xaccAccountSetName (Account *account, const char *name)
 Set the account's name.
 
void xaccAccountSetCode (Account *account, const char *code)
 Set the account's accounting code.
 
void xaccAccountSetDescription (Account *account, const char *desc)
 Set the account's description.
 
void xaccAccountSetColor (Account *account, const char *color)
 Set the account's Color.
 
void xaccAccountSetFilter (Account *account, const char *filter)
 Set the account's Filter.
 
void xaccAccountSetSortOrder (Account *account, const char *sortorder)
 Set the account's Sort Order.
 
void xaccAccountSetSortReversed (Account *account, gboolean sortreversed)
 Set the account's Sort Order direction.
 
void xaccAccountSetNotes (Account *account, const char *notes)
 Set the account's notes.
 
void xaccAccountSetLastNum (Account *account, const char *num)
 Set the last num field of an Account.
 
void gnc_account_set_policy (Account *account, GNCPolicy *policy)
 Set the account's lot order policy.
 
GNCAccountType xaccAccountGetType (const Account *account)
 Returns the account's account type. More...
 
gboolean xaccAccountIsPriced (const Account *acc)
 Returns true if the account is a stock, mutual fund or currency, otherwise false. More...
 
void gnc_account_set_start_balance (Account *acc, const gnc_numeric start_baln)
 This function will set the starting commodity balance for this account. More...
 
void gnc_account_set_start_cleared_balance (Account *acc, const gnc_numeric start_baln)
 This function will set the starting cleared commodity balance for this account. More...
 
void gnc_account_set_start_reconciled_balance (Account *acc, const gnc_numeric start_baln)
 This function will set the starting reconciled commodity balance for this account. More...
 
void gnc_account_set_balance_dirty (Account *acc)
 Tell the account that the running balances may be incorrect and need to be recomputed. More...
 
void gnc_account_set_sort_dirty (Account *acc)
 Tell the account believes that the splits may be incorrectly sorted and need to be resorted. More...
 
gboolean gnc_account_insert_split (Account *acc, Split *s)
 Insert the given split from an account. More...
 
gboolean gnc_account_remove_split (Account *acc, Split *s)
 Remove the given split from an account. More...
 
const char * xaccAccountGetName (const Account *account)
 Get the account's name.
 
const char * xaccAccountGetCode (const Account *account)
 Get the account's accounting code.
 
const char * xaccAccountGetDescription (const Account *account)
 Get the account's description.
 
const char * xaccAccountGetColor (const Account *account)
 Get the account's color.
 
const char * xaccAccountGetFilter (const Account *account)
 Get the account's filter.
 
const char * xaccAccountGetSortOrder (const Account *account)
 Get the account's Sort Order.
 
gboolean xaccAccountGetSortReversed (const Account *account)
 Get the account's Sort Order direction.
 
const char * xaccAccountGetNotes (const Account *account)
 Get the account's notes.
 
const char * xaccAccountGetLastNum (const Account *account)
 Get the last num field of an Account.
 
GNCPolicy * gnc_account_get_policy (Account *account)
 Get the account's lot order policy.
 
void xaccAccountRecomputeBalance (Account *)
 The following recompute the partial balances (stored with the transaction) and the total balance, for this account.
 
void xaccAccountSortSplits (Account *acc, gboolean force)
 The xaccAccountSortSplits() routine will resort the account's splits if the sort is dirty. More...
 
gchar * gnc_account_get_full_name (const Account *account)
 The gnc_account_get_full_name routine returns the fully qualified name of the account using the given separator char. More...
 
AccountxaccAccountGainsAccount (Account *acc, gnc_commodity *curr)
 Retrieve the gains account used by this account for the indicated currency, creating and recording a new one if necessary. More...
 
void dxaccAccountSetPriceSrc (Account *account, const char *src)
 Set a string that identifies the Finance::Quote backend that should be used to retrieve online prices. More...
 
const char * dxaccAccountGetPriceSrc (const Account *account)
 Get a string that identifies the Finance::Quote backend that should be used to retrieve online prices. More...
 
gboolean xaccAccountGetAutoInterestXfer (const Account *account, gboolean default_value)
 Returns a per-account flag: Prior to reconciling an account which charges or pays interest, this flag tells whether to prompt the user to enter a transaction for the interest charge or payment. More...
 
void xaccAccountSetAutoInterestXfer (Account *account, gboolean value)
 Sets a per-account flag: Prior to reconciling an account which charges or pays interest, this flag tells whether to prompt the user to enter a transaction for the interest charge or payment. More...
 

Account Commodity setters/getters

Accounts are used to store an amount of 'something', that 'something'
is called the 'commodity'.

An account can only hold one kind of commodity. The following are used to get and set the commodity, and also to set the SCU, the 'Smallest Commodity Unit'.

Note that when we say that a 'split' holds an 'amount', that amount is denominated in the account commodity. Do not confuse 'amount' and 'value'. The 'value' of a split is the value of the amount expressed in the currency of the transaction. Thus, for example, the 'amount' may be 12 apples, where the account commodity is 'apples'. The value of these 12 apples may be 12 dollars, where the transaction currency is 'dollars'.

The SCU is the 'Smallest Commodity Unit', signifying the smallest non-zero amount that can be stored in the account. It is represented as the integer denominator of a fraction. Thus, for example, a SCU of 12 means that 1/12 of something is the smallest amount that can be stored in the account. SCU's can be any value; they do not need to be decimal. This allows the use of accounts with unusual, non-decimal commodities and currencies.

Normally, the SCU is determined by the commodity of the account. However, this default SCU can be over-ridden and set to an account-specific value. This is account-specific value is called the 'non-standard' value in the documentation below.

void xaccAccountSetCommodity (Account *account, gnc_commodity *comm)
 Set the account's commodity.
 
gnc_commodity * xaccAccountGetCommodity (const Account *account)
 Get the account's commodity.
 
gnc_commodity * gnc_account_get_currency_or_parent (const Account *account)
 Returns a gnc_commodity that is a currency, suitable for being a Transaction's currency. More...
 
int xaccAccountGetCommoditySCU (const Account *account)
 Return the SCU for the account. More...
 
int xaccAccountGetCommoditySCUi (const Account *account)
 Return the 'internal' SCU setting. More...
 
void xaccAccountSetCommoditySCU (Account *account, int frac)
 Set the SCU for the account. More...
 
void xaccAccountSetNonStdSCU (Account *account, gboolean flag)
 Set the flag indicating that this account uses a non-standard SCU. More...
 
gboolean xaccAccountGetNonStdSCU (const Account *account)
 Return boolean, indicating whether this account uses a non-standard SCU. More...
 

Account Balance

gnc_numeric xaccAccountGetBalance (const Account *account)
 Get the current balance of the account, which may include future splits.
 
gnc_numeric xaccAccountGetClearedBalance (const Account *account)
 Get the current balance of the account, only including cleared transactions.
 
gnc_numeric xaccAccountGetReconciledBalance (const Account *account)
 Get the current balance of the account, only including reconciled transactions.
 
gnc_numeric xaccAccountGetPresentBalance (const Account *account)
 
gnc_numeric xaccAccountGetProjectedMinimumBalance (const Account *account)
 
gnc_numeric xaccAccountGetBalanceAsOfDate (Account *account, time64 date)
 Get the balance of the account as of the date specified.
 
gnc_numeric xaccAccountConvertBalanceToCurrency (const Account *account, gnc_numeric balance, const gnc_commodity *balance_currency, const gnc_commodity *new_currency)
 
gnc_numeric xaccAccountConvertBalanceToCurrencyAsOfDate (const Account *account, gnc_numeric balance, gnc_commodity *balance_currency, gnc_commodity *new_currency, time64 date)
 
gnc_numeric xaccAccountGetBalanceInCurrency (const Account *account, const gnc_commodity *report_commodity, gboolean include_children)
 
gnc_numeric xaccAccountGetClearedBalanceInCurrency (const Account *account, const gnc_commodity *report_commodity, gboolean include_children)
 
gnc_numeric xaccAccountGetReconciledBalanceInCurrency (const Account *account, const gnc_commodity *report_commodity, gboolean include_children)
 
gnc_numeric xaccAccountGetPresentBalanceInCurrency (const Account *account, const gnc_commodity *report_commodity, gboolean include_children)
 
gnc_numeric xaccAccountGetProjectedMinimumBalanceInCurrency (const Account *account, const gnc_commodity *report_commodity, gboolean include_children)
 
gnc_numeric xaccAccountGetBalanceAsOfDateInCurrency (Account *account, time64 date, gnc_commodity *report_commodity, gboolean include_children)
 
gnc_numeric xaccAccountGetBalanceChangeForPeriod (Account *acc, time64 date1, time64 date2, gboolean recurse)
 

Account Children and Parents.

The set of accounts is represented as a doubly-linked tree, so that given any account, both its parent and its children can be easily found.

At the top of the tree hierarchy lies a single root node, the root account.

The account tree hierarchy is unique, in that a given account can have only one parent account.

void gnc_account_append_child (Account *new_parent, Account *child)
 This function will remove from the child account any pre-existing parent relationship, and will then add the account as a child of the new parent. More...
 
void gnc_account_remove_child (Account *parent, Account *child)
 This function will remove the specified child account from the specified parent account. More...
 
Accountgnc_account_get_parent (const Account *account)
 This routine returns a pointer to the parent of the specified account. More...
 
Accountgnc_account_get_root (Account *account)
 This routine returns the root account of the account tree that the specified account belongs to. More...
 
gboolean gnc_account_is_root (const Account *account)
 This routine indicates whether the specified account is the root node of an account tree. More...
 
GList * gnc_account_get_children (const Account *account)
 This routine returns a GList of all children accounts of the specified account. More...
 
GList * gnc_account_get_children_sorted (const Account *account)
 This routine returns a GList of all children accounts of the specified account, ordered by xaccAccountOrder(). More...
 
gint gnc_account_n_children (const Account *account)
 Return the number of children of the specified account. More...
 
gint gnc_account_child_index (const Account *parent, const Account *child)
 Return the index of the specified child within the list of the parent's children. More...
 
Accountgnc_account_nth_child (const Account *parent, gint num)
 Return the n'th child account of the specified parent account. More...
 
GList * gnc_account_get_descendants (const Account *account)
 This routine returns a flat list of all of the accounts that are descendants of the specified account. More...
 
GList * gnc_account_get_descendants_sorted (const Account *account)
 This function returns a GList containing all the descendants of the specified account, sorted at each level. More...
 
gint gnc_account_n_descendants (const Account *account)
 Return the number of descendants of the specified account. More...
 
gint gnc_account_get_current_depth (const Account *account)
 Return the number of levels of this account below the root account. More...
 
gint gnc_account_get_tree_depth (const Account *account)
 Return the number of levels of descendants accounts below the specified account. More...
 

ForEach

void gnc_account_foreach_child (const Account *account, AccountCb func, gpointer user_data)
 This method will traverse the immediate children of this accounts, calling 'func' on each account. More...
 
void gnc_account_foreach_descendant (const Account *account, AccountCb func, gpointer user_data)
 This method will traverse all children of this accounts and their descendants, calling 'func' on each account. More...
 
gpointer gnc_account_foreach_descendant_until (const Account *account, AccountCb2 func, gpointer user_data)
 This method will traverse all children of this accounts and their descendants, calling 'func' on each account. More...
 

Concatenation, Merging

void gnc_account_join_children (Account *to_parent, Account *from_parent)
 The gnc_account_join_children() subroutine will move (reparent) all child accounts from the from_parent account to the to_parent account, preserving the account hierarchy. More...
 
void gnc_account_merge_children (Account *parent)
 The gnc_account_merge_children() subroutine will go through an account, merging all child accounts that have the same name and description. More...
 

Detailed Description

Splits are grouped into Accounts which are also known as "Ledgers" in accounting practice.

Each Account consists of a list of Splits that debit that Account. To ensure consistency, if a Split points to an Account, then the Account must point to the Split, and vice-versa. A Split can belong to at most one Account. Besides merely containing a list of Splits, the Account structure also gives the Account a name, a code number, description and notes fields, a key-value frame, a pointer to the commodity that is used for all splits in this account. The commodity can be the name of anything traded and tradeable: a stock (e.g. "IBM", "McDonald's"), a currency (e.g. "USD", "GBP"), or anything added to the commodity table.

Accounts can be arranged in a hierarchical tree. By accounting convention, the value of an Account is equal to the value of all of its Splits plus the value of all of its sub-Accounts.

Macro Definition Documentation

◆ xaccAccountGetGUID

#define xaccAccountGetGUID (   X)    qof_entity_get_guid(QOF_INSTANCE(X))
Deprecated:

Definition at line 245 of file Account.h.

Enumeration Type Documentation

◆ GNCAccountType

The account types are used to determine how the transaction data in the account is displayed.

These values can be safely changed from one release to the next. Note that if values are added, the file IO translation routines need to be updated. Note also that GUI code depends on these numbers.

Note
IMPORTANT: If you do change the enumeration names (not the numbers), you need to update xaccAccountTypeEnumAsString — used for text file exports
Enumerator
ACCT_TYPE_INVALID 

Not a type.

ACCT_TYPE_NONE 

Not a type.

ACCT_TYPE_BANK 

The bank account type denotes a savings or checking account held at a bank.

Often interest bearing.

ACCT_TYPE_CASH 

The cash account type is used to denote a shoe-box or pillowcase stuffed with * cash.

ACCT_TYPE_CREDIT 

The Credit card account is used to denote credit (e.g.

amex) and debit (e.g. visa, mastercard) card accounts

ACCT_TYPE_ASSET 

asset (and liability) accounts indicate generic, generalized accounts that are none of the above.

ACCT_TYPE_LIABILITY 

liability (and asset) accounts indicate generic, generalized accounts that are none of the above.

ACCT_TYPE_STOCK 

Stock accounts will typically be shown in registers which show three columns: price, number of shares, and value.

ACCT_TYPE_MUTUAL 

Mutual Fund accounts will typically be shown in registers which show three columns: price, number of shares, and value.

ACCT_TYPE_CURRENCY 

The currency account type indicates that the account is a currency trading account.

In many ways, a currency trading account is like a stock * trading account. It is shown in the register with three columns: price, number of shares, and value. Note: Since version 1.7.0, this account is * no longer needed to exchange currencies between accounts, so this type is DEPRECATED.

ACCT_TYPE_INCOME 

Income accounts are used to denote income.

ACCT_TYPE_EXPENSE 

Expense accounts are used to denote expenses.

ACCT_TYPE_EQUITY 

Equity account is used to balance the balance sheet.

ACCT_TYPE_RECEIVABLE 

A/R account type.

ACCT_TYPE_PAYABLE 

A/P account type.

ACCT_TYPE_ROOT 

The hidden root account of an account tree.

ACCT_TYPE_TRADING 

Account used to record multiple commodity transactions.

This is not the same as ACCT_TYPE_CURRENCY above. Multiple commodity transactions have splits in these accounts to make the transaction balance in each commodity as well as in total value.

NUM_ACCOUNT_TYPES 

stop here; the following types just aren't ready for prime time

ACCT_TYPE_CHECKING 

bank account type – don't use this for now, see NUM_ACCOUNT_TYPES

ACCT_TYPE_SAVINGS 

bank account type – don't use this for now, see NUM_ACCOUNT_TYPES

ACCT_TYPE_MONEYMRKT 

bank account type – don't use this for now, see NUM_ACCOUNT_TYPES

ACCT_TYPE_CREDITLINE 

line of credit – don't use this for now, see NUM_ACCOUNT_TYPES

Definition at line 102 of file Account.h.

103 {
104  ACCT_TYPE_INVALID = -1,
105  ACCT_TYPE_NONE = -1,
107  ACCT_TYPE_BANK = 0,
110  ACCT_TYPE_CASH = 1,
113  ACCT_TYPE_CREDIT = 3,
116  ACCT_TYPE_ASSET = 2,
122  ACCT_TYPE_STOCK = 5,
125  ACCT_TYPE_MUTUAL = 6,
129  ACCT_TYPE_CURRENCY = 7,
140  ACCT_TYPE_INCOME = 8,
143  ACCT_TYPE_EXPENSE = 9,
146  ACCT_TYPE_EQUITY = 10,
151  ACCT_TYPE_PAYABLE = 12,
153  ACCT_TYPE_ROOT = 13,
155  ACCT_TYPE_TRADING = 14,
161  NUM_ACCOUNT_TYPES = 15,
164  /* bank account types */
165  ACCT_TYPE_CHECKING = 15,
167  ACCT_TYPE_SAVINGS = 16,
169  ACCT_TYPE_MONEYMRKT = 17,
171  ACCT_TYPE_CREDITLINE = 18,
173  ACCT_TYPE_LAST
Expense accounts are used to denote expenses.
Definition: Account.h:143
Mutual Fund accounts will typically be shown in registers which show three columns: price...
Definition: Account.h:125
stop here; the following types just aren't ready for prime time
Definition: Account.h:161
The cash account type is used to denote a shoe-box or pillowcase stuffed with * cash.
Definition: Account.h:110
Account used to record multiple commodity transactions.
Definition: Account.h:155
Stock accounts will typically be shown in registers which show three columns: price, number of shares, and value.
Definition: Account.h:122
bank account type – don't use this for now, see NUM_ACCOUNT_TYPES
Definition: Account.h:165
Income accounts are used to denote income.
Definition: Account.h:140
line of credit – don't use this for now, see NUM_ACCOUNT_TYPES
Definition: Account.h:171
The bank account type denotes a savings or checking account held at a bank.
Definition: Account.h:107
A/P account type.
Definition: Account.h:151
bank account type – don't use this for now, see NUM_ACCOUNT_TYPES
Definition: Account.h:167
asset (and liability) accounts indicate generic, generalized accounts that are none of the above...
Definition: Account.h:116
The currency account type indicates that the account is a currency trading account.
Definition: Account.h:129
GNCAccountType
The account types are used to determine how the transaction data in the account is displayed...
Definition: Account.h:102
Not a type.
Definition: Account.h:104
liability (and asset) accounts indicate generic, generalized accounts that are none of the above...
Definition: Account.h:119
A/R account type.
Definition: Account.h:149
bank account type – don't use this for now, see NUM_ACCOUNT_TYPES
Definition: Account.h:169
Equity account is used to balance the balance sheet.
Definition: Account.h:146
Not a type.
Definition: Account.h:105
The hidden root account of an account tree.
Definition: Account.h:153
The Credit card account is used to denote credit (e.g.
Definition: Account.h:113

Function Documentation

◆ dxaccAccountGetPriceSrc()

const char* dxaccAccountGetPriceSrc ( const Account account)

Get a string that identifies the Finance::Quote backend that should be used to retrieve online prices.

See price-quotes.scm for more information.

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

Definition at line 4655 of file Account.c.

4656 {
4657  GValue v = G_VALUE_INIT;
4658  if (!acc) return NULL;
4659 
4660  if (!xaccAccountIsPriced(acc)) return NULL;
4661 
4662  qof_instance_get_kvp (QOF_INSTANCE(acc), "old-price-source", &v);
4663  return G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL;
4664 }
void qof_instance_get_kvp(const QofInstance *inst, const gchar *key, GValue *value)
Retrieves the contents of a KVP slot into a provided GValue.
gboolean xaccAccountIsPriced(const Account *acc)
Returns true if the account is a stock, mutual fund or currency, otherwise false. ...
Definition: Account.c:4291

◆ dxaccAccountSetPriceSrc()

void dxaccAccountSetPriceSrc ( Account account,
const char *  src 
)

Set a string that identifies the Finance::Quote backend that should be used to retrieve online prices.

See price-quotes.scm for more information

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

Definition at line 4628 of file Account.c.

4629 {
4630  if (!acc) return;
4631 
4632  if (xaccAccountIsPriced(acc))
4633  {
4634  xaccAccountBeginEdit(acc);
4635  if (src)
4636  {
4637  GValue v = G_VALUE_INIT;
4638  g_value_init (&v, G_TYPE_STRING);
4639  g_value_set_string (&v, src);
4640  qof_instance_set_kvp (QOF_INSTANCE(acc),
4641  "old-price-source", &v);
4642  }
4643  else
4644  qof_instance_set_kvp (QOF_INSTANCE(acc), "old-price-source", NULL);
4645 
4646  mark_account (acc);
4647  xaccAccountCommitEdit(acc);
4648  }
4649 }
gboolean xaccAccountIsPriced(const Account *acc)
Returns true if the account is a stock, mutual fund or currency, otherwise false. ...
Definition: Account.c:4291
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition: Account.c:1294
void qof_instance_set_kvp(QofInstance *inst, const gchar *key, const GValue *value)
Sets a KVP slot to a value from a GValue.
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.c:1335

◆ gnc_account_append_child()

void gnc_account_append_child ( Account new_parent,
Account child 
)

This function will remove from the child account any pre-existing parent relationship, and will then add the account as a child of the new parent.

The exception to this is when the old and new parent accounts are the same, in which case this function does nothing.

If the child account belongs to a different book than the specified new parent account, the child will be removed from the other book (and thus, the other book's entity tables, generating a destroy event), and will be added to the new book (generating a create event).

Parameters
new_parentThe new parent account to which the child should be attached.
childThe account to attach.

Definition at line 2525 of file Account.c.

2526 {
2527  AccountPrivate *ppriv, *cpriv;
2528  Account *old_parent;
2529  QofCollection *col;
2530 
2531  /* errors */
2532  g_assert(GNC_IS_ACCOUNT(new_parent));
2533  g_assert(GNC_IS_ACCOUNT(child));
2534 
2535  /* optimizations */
2536  ppriv = GET_PRIVATE(new_parent);
2537  cpriv = GET_PRIVATE(child);
2538  old_parent = cpriv->parent;
2539  if (old_parent == new_parent)
2540  return;
2541 
2542  // xaccAccountBeginEdit(new_parent);
2543  xaccAccountBeginEdit(child);
2544  if (old_parent)
2545  {
2546  gnc_account_remove_child(old_parent, child);
2547 
2548  if (!qof_instance_books_equal(old_parent, new_parent))
2549  {
2550  /* hack alert -- this implementation is not exactly correct.
2551  * If the entity tables are not identical, then the 'from' book
2552  * may have a different backend than the 'to' book. This means
2553  * that we should get the 'from' backend to destroy this account,
2554  * and the 'to' backend to save it. Right now, this is broken.
2555  *
2556  * A 'correct' implementation similar to this is in Period.c
2557  * except its for transactions ...
2558  *
2559  * Note also, we need to reparent the children to the new book as well.
2560  */
2561  PWARN ("reparenting accounts across books is not correctly supported\n");
2562 
2563  qof_event_gen (&child->inst, QOF_EVENT_DESTROY, NULL);
2565  GNC_ID_ACCOUNT);
2566  qof_collection_insert_entity (col, &child->inst);
2567  qof_event_gen (&child->inst, QOF_EVENT_CREATE, NULL);
2568  }
2569  }
2570  cpriv->parent = new_parent;
2571  ppriv->children = g_list_append(ppriv->children, child);
2572  qof_instance_set_dirty(&new_parent->inst);
2573  qof_instance_set_dirty(&child->inst);
2574 
2575  /* Send events data. Warning: The call to commit_edit is also going
2576  * to send a MODIFY event. If the gtktreemodelfilter code gets the
2577  * MODIFY before it gets the ADD, it gets very confused and thinks
2578  * that two nodes have been added. */
2579  qof_event_gen (&child->inst, QOF_EVENT_ADD, NULL);
2580  // qof_event_gen (&new_parent->inst, QOF_EVENT_MODIFY, NULL);
2581 
2582  xaccAccountCommitEdit (child);
2583  // xaccAccountCommitEdit(new_parent);
2584 }
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.
STRUCTS.
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:243
void gnc_account_remove_child(Account *parent, Account *child)
This function will remove the specified child account from the specified parent account.
Definition: Account.c:2587
void qof_collection_insert_entity(QofCollection *, QofInstance *)
Take entity, remove it from whatever collection its currently in, and place it in a new collection...
Definition: qofid.cpp:97
gboolean qof_instance_books_equal(gconstpointer ptr1, gconstpointer ptr2)
See if two QofInstances share the same book.
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition: Account.c:1294
QofCollection * qof_book_get_collection(const QofBook *book, QofIdType entity_type)
Return The table of entities of the given type.
Definition: qofbook.cpp:599
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition: qofevent.cpp:234
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.c:1335

◆ gnc_account_child_index()

gint gnc_account_child_index ( const Account parent,
const Account child 
)

Return the index of the specified child within the list of the parent's children.

The first child index is 0. This function returns -1 if the parent account is NULL of if the specified child does not belong to the parent account.

Parameters
parentThe parent account to check.
childThe child account to find.
Returns
The index of the child account within the specified parent, or -1.

Definition at line 2683 of file Account.c.

2684 {
2685  g_return_val_if_fail(GNC_IS_ACCOUNT(parent), -1);
2686  g_return_val_if_fail(GNC_IS_ACCOUNT(child), -1);
2687  return g_list_index(GET_PRIVATE(parent)->children, child);
2688 }

◆ gnc_account_create_root()

Account* gnc_account_create_root ( QofBook *  book)

Create a new root level account.

Definition at line 1112 of file Account.c.

1113 {
1114  Account *root;
1115  AccountPrivate *rpriv;
1116 
1117  root = xaccMallocAccount(book);
1118  rpriv = GET_PRIVATE(root);
1119  xaccAccountBeginEdit(root);
1120  rpriv->type = ACCT_TYPE_ROOT;
1121  CACHE_REPLACE(rpriv->accountName, "Root Account");
1122  mark_account (root);
1123  xaccAccountCommitEdit(root);
1124  gnc_book_set_root_account(book, root);
1125  return root;
1126 }
STRUCTS.
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition: Account.c:1294
Account * xaccMallocAccount(QofBook *book)
Constructor.
Definition: Account.c:1098
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.c:1335
The hidden root account of an account tree.
Definition: Account.h:153

◆ gnc_account_foreach_child()

void gnc_account_foreach_child ( const Account account,
AccountCb  func,
gpointer  user_data 
)

This method will traverse the immediate children of this accounts, calling 'func' on each account.

This function traverses all children nodes. To traverse only a subset of the child nodes use the gnc_account_foreach_child_until() function.

Parameters
accountA pointer to the account on whose children the function should be called.
funcA function taking two arguments, an Account and a gpointer.
user_dataThis data will be passed to each call of func.

Definition at line 2940 of file Account.c.

2943 {
2944  const AccountPrivate *priv;
2945  GList *node;
2946 
2947  g_return_if_fail(GNC_IS_ACCOUNT(acc));
2948  g_return_if_fail(thunk);
2949 
2950  priv = GET_PRIVATE(acc);
2951  for (node = priv->children; node; node = node->next)
2952  {
2953  thunk (node->data, user_data);
2954  }
2955 }

◆ gnc_account_foreach_descendant()

void gnc_account_foreach_descendant ( const Account account,
AccountCb  func,
gpointer  user_data 
)

This method will traverse all children of this accounts and their descendants, calling 'func' on each account.

This function traverses all descendant nodes. To traverse only a subset of the descendant nodes use the gnc_account_foreach_descendant_until() function.

Parameters
accountA pointer to the account on whose descendants the function should be called.
funcA function taking two arguments, an Account and a gpointer.
user_dataThis data will be passed to each call of func.

Definition at line 2958 of file Account.c.

2961 {
2962  const AccountPrivate *priv;
2963  GList *node;
2964  Account *child;
2965 
2966  g_return_if_fail(GNC_IS_ACCOUNT(acc));
2967  g_return_if_fail(thunk);
2968 
2969  priv = GET_PRIVATE(acc);
2970  for (node = priv->children; node; node = node->next)
2971  {
2972  child = node->data;
2973  thunk(child, user_data);
2974  gnc_account_foreach_descendant(child, thunk, user_data);
2975  }
2976 }
void gnc_account_foreach_descendant(const Account *acc, AccountCb thunk, gpointer user_data)
This method will traverse all children of this accounts and their descendants, calling 'func' on each...
Definition: Account.c:2958
STRUCTS.

◆ gnc_account_foreach_descendant_until()

gpointer gnc_account_foreach_descendant_until ( const Account account,
AccountCb2  func,
gpointer  user_data 
)

This method will traverse all children of this accounts and their descendants, calling 'func' on each account.

Traversal will stop when func returns a non-null value, and the routine will return with that value. Therefore, this function will return null if func returns null for every account. For a simpler function that always traverses all children nodes, use the gnc_account_foreach_descendant() function.

Parameters
accountA pointer to the account on whose descendants the function should be called.
funcA function taking two arguments, an Account and a gpointer.
user_dataThis data will be passed to each call of func.

Definition at line 2979 of file Account.c.

2982 {
2983  const AccountPrivate *priv;
2984  GList *node;
2985  Account *child;
2986  gpointer result;
2987 
2988  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
2989  g_return_val_if_fail(thunk, NULL);
2990 
2991  priv = GET_PRIVATE(acc);
2992  for (node = priv->children; node; node = node->next)
2993  {
2994  child = node->data;
2995  result = thunk(child, user_data);
2996  if (result)
2997  return(result);
2998 
2999  result = gnc_account_foreach_descendant_until(child, thunk, user_data);
3000  if (result)
3001  return(result);
3002  }
3003 
3004  return NULL;
3005 }
STRUCTS.
gpointer gnc_account_foreach_descendant_until(const Account *acc, AccountCb2 thunk, gpointer user_data)
This method will traverse all children of this accounts and their descendants, calling 'func' on each...
Definition: Account.c:2979

◆ gnc_account_get_children()

GList* gnc_account_get_children ( const Account account)

This routine returns a GList of all children accounts of the specified account.

This function only returns the immediate children of the specified account. For a list of all descendant accounts, use the gnc_account_get_descendants() function.

If you are looking for the splits of this account, use xaccAccountGetSplitList() instead. This function here deals with children accounts inside the account tree.

Parameters
accountThe account whose children should be returned.
Returns
A GList of account pointers, or NULL if there are no children accounts. It is the callers responsibility to free any returned list with the g_list_free() function.

Definition at line 2654 of file Account.c.

2655 {
2656  g_return_val_if_fail(GNC_IS_ACCOUNT(account), NULL);
2657  return g_list_copy(GET_PRIVATE(account)->children);
2658 }

◆ gnc_account_get_children_sorted()

GList* gnc_account_get_children_sorted ( const Account account)

This routine returns a GList of all children accounts of the specified account, ordered by xaccAccountOrder().

See also
gnc_account_get_children()

Definition at line 2661 of file Account.c.

2662 {
2663  AccountPrivate *priv;
2664 
2665  /* errors */
2666  g_return_val_if_fail(GNC_IS_ACCOUNT(account), NULL);
2667 
2668  /* optimizations */
2669  priv = GET_PRIVATE(account);
2670  if (!priv->children)
2671  return NULL;
2672  return g_list_sort(g_list_copy(priv->children), (GCompareFunc)xaccAccountOrder);
2673 }
int xaccAccountOrder(const Account *aa, const Account *ab)
The xaccAccountOrder() subroutine defines a sorting order on accounts.
Definition: Account.c:2146

◆ gnc_account_get_currency_or_parent()

gnc_commodity* gnc_account_get_currency_or_parent ( const Account account)

Returns a gnc_commodity that is a currency, suitable for being a Transaction's currency.

The gnc_commodity is taken either from the current account, or from the next parent account that has a gnc_commodity that is a currency. If neither this account nor any of its parent has such a commodity that is a currency, NULL is returned. In that case, you can use gnc_default_currency() but you might want to show a warning dialog first.

Definition at line 3161 of file Account.c.

3162 {
3163  gnc_commodity * commodity;
3164  g_assert(account);
3165 
3166  commodity = xaccAccountGetCommodity (account);
3167  if (gnc_commodity_is_currency(commodity))
3168  return commodity;
3169  else
3170  {
3171  const Account *parent_account = account;
3172  /* Account commodity is not a currency, walk up the tree until
3173  * we find a parent account that is a currency account and use
3174  * it's currency.
3175  */
3176  do
3177  {
3178  parent_account = gnc_account_get_parent (parent_account);
3179  if (parent_account)
3180  {
3181  commodity = xaccAccountGetCommodity (parent_account);
3182  if (gnc_commodity_is_currency(commodity))
3183  {
3184  return commodity;
3185  //break;
3186  }
3187  }
3188  }
3189  while (parent_account);
3190  }
3191  return NULL; // no suitable commodity found.
3192 }
Account * gnc_account_get_parent(const Account *acc)
This routine returns a pointer to the parent of the specified account.
Definition: Account.c:2623
gboolean gnc_commodity_is_currency(const gnc_commodity *cm)
Checks to see if the specified commodity is an ISO 4217 recognized currency or a legacy currency...
STRUCTS.
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity.
Definition: Account.c:3154

◆ gnc_account_get_current_depth()

gint gnc_account_get_current_depth ( const Account account)

Return the number of levels of this account below the root account.

Parameters
accountThe account to query.
Returns
The number of levels below the root.

Definition at line 2715 of file Account.c.

2716 {
2717  AccountPrivate *priv;
2718  int depth = 0;
2719 
2720  g_return_val_if_fail(GNC_IS_ACCOUNT(account), 0);
2721 
2722  priv = GET_PRIVATE(account);
2723  while (priv->parent && (priv->type != ACCT_TYPE_ROOT))
2724  {
2725  account = priv->parent;
2726  priv = GET_PRIVATE(account);
2727  depth++;
2728  }
2729 
2730  return depth;
2731 }
The hidden root account of an account tree.
Definition: Account.h:153

◆ gnc_account_get_descendants()

GList* gnc_account_get_descendants ( const Account account)

This routine returns a flat list of all of the accounts that are descendants of the specified account.

This includes not only the the children, but the children of the children, etc. For a list of only the immediate child accounts, use the gnc_account_get_children() function. Within each set of child accounts, the accounts returned by this function are unordered. For a list of descendants where each set of children is sorted via the standard account sort function, use the gnc_account_get_descendants_sorted() function.

Parameters
accountThe account whose descendants should be returned.
Returns
A GList of account pointers, or NULL if there are no descendants. It is the callers responsibility to free any returned list with the g_list_free() function.

Definition at line 2755 of file Account.c.

2756 {
2757  AccountPrivate *priv;
2758  GList *child, *descendants;
2759 
2760  g_return_val_if_fail(GNC_IS_ACCOUNT(account), NULL);
2761 
2762  priv = GET_PRIVATE(account);
2763  if (!priv->children)
2764  return NULL;
2765 
2766  descendants = NULL;
2767  for (child = priv->children; child; child = g_list_next(child))
2768  {
2769  descendants = g_list_append(descendants, child->data);
2770  descendants = g_list_concat(descendants,
2771  gnc_account_get_descendants(child->data));
2772  }
2773  return descendants;
2774 }
GList * gnc_account_get_descendants(const Account *account)
This routine returns a flat list of all of the accounts that are descendants of the specified account...
Definition: Account.c:2755

◆ gnc_account_get_descendants_sorted()

GList* gnc_account_get_descendants_sorted ( const Account account)

This function returns a GList containing all the descendants of the specified account, sorted at each level.

This includes not only the the children, but the children of the children, etc. Within each set of child accounts, the accounts returned by this function are ordered via the standard account sort function. For a list of descendants where each set of children is unordered, use the gnc_account_get_descendants() function.

Note: Use this function where the results are intended for display to the user. If the results are internal to GnuCash or will be resorted at som later point in time you should use the gnc_account_get_descendants() function.

Parameters
accountThe account whose descendants should be returned.
Returns
A GList of account pointers, or NULL if there are no descendants. It is the callers responsibility to free any returned list with the g_list_free() function.

Definition at line 2777 of file Account.c.

2778 {
2779  AccountPrivate *priv;
2780  GList *child, *children, *descendants;
2781 
2782  /* errors */
2783  g_return_val_if_fail(GNC_IS_ACCOUNT(account), NULL);
2784 
2785  /* optimizations */
2786  priv = GET_PRIVATE(account);
2787  if (!priv->children)
2788  return NULL;
2789 
2790  descendants = NULL;
2791  children = g_list_sort(g_list_copy(priv->children), (GCompareFunc)xaccAccountOrder);
2792  for (child = children; child; child = g_list_next(child))
2793  {
2794  descendants = g_list_append(descendants, child->data);
2795  descendants = g_list_concat(descendants,
2796  gnc_account_get_descendants_sorted(child->data));
2797  }
2798  g_list_free(children);
2799  return descendants;
2800 }
GList * gnc_account_get_descendants_sorted(const Account *account)
This function returns a GList containing all the descendants of the specified account, sorted at each level.
Definition: Account.c:2777
int xaccAccountOrder(const Account *aa, const Account *ab)
The xaccAccountOrder() subroutine defines a sorting order on accounts.
Definition: Account.c:2146

◆ gnc_account_get_full_name()

gchar* gnc_account_get_full_name ( const Account account)

The gnc_account_get_full_name routine returns the fully qualified name of the account using the given separator char.

The name must be g_free'd after use. The fully qualified name of an account is the concatenation of the names of the account and all its ancestor accounts starting with the topmost account and ending with the given account. Each name is separated by the given character.

Note
: WAKE UP! Unlike all other gets, the string returned by gnc_account_get_full_name() must be freed by you the user !!! hack alert – since it breaks the rule of string allocation, maybe this routine should not be in this library, but some utility library?

Definition at line 3038 of file Account.c.

3039 {
3040  AccountPrivate *priv;
3041  const Account *a;
3042  char *fullname;
3043  gchar **names;
3044  int level;
3045 
3046  /* So much for hardening the API. Too many callers to this function don't
3047  * bother to check if they have a non-NULL pointer before calling. */
3048  if (NULL == account)
3049  return g_strdup("");
3050 
3051  /* errors */
3052  g_return_val_if_fail(GNC_IS_ACCOUNT(account), g_strdup(""));
3053 
3054  /* optimizations */
3055  priv = GET_PRIVATE(account);
3056  if (!priv->parent)
3057  return g_strdup("");
3058 
3059  /* Figure out how much space is needed by counting the nodes up to
3060  * the root. */
3061  level = 0;
3062  for (a = account; a; a = priv->parent)
3063  {
3064  priv = GET_PRIVATE(a);
3065  level++;
3066  }
3067 
3068  /* Get all the pointers in the right order. The root node "entry"
3069  * becomes the terminating NULL pointer for the array of strings. */
3070  names = g_malloc(level * sizeof(gchar *));
3071  names[--level] = NULL;
3072  for (a = account; level > 0; a = priv->parent)
3073  {
3074  priv = GET_PRIVATE(a);
3075  names[--level] = priv->accountName;
3076  }
3077 
3078  /* Build the full name */
3079  fullname = g_strjoinv(account_separator, names);
3080  g_free(names);
3081 
3082  return fullname;
3083 }
STRUCTS.

◆ gnc_account_get_parent()

Account* gnc_account_get_parent ( const Account account)

This routine returns a pointer to the parent of the specified account.

If the account has no parent, i.e it is either the root node or is a disconnected account, then its parent will be NULL.

Parameters
accountA pointer to any exiting account.
Returns
A pointer to the parent account node, or NULL if there is no parent account.

Definition at line 2623 of file Account.c.

2624 {
2625  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
2626  return GET_PRIVATE(acc)->parent;
2627 }

◆ gnc_account_get_root()

Account* gnc_account_get_root ( Account account)

This routine returns the root account of the account tree that the specified account belongs to.

It is the equivalent of repeatedly calling the gnc_account_get_parent() routine until that routine returns NULL.

Parameters
accountA pointer to any existing account.
Returns
The root node of the account tree to which this account belongs. NULL if the account is not part of any account tree.

Definition at line 2630 of file Account.c.

2631 {
2632  AccountPrivate *priv;
2633 
2634  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
2635 
2636  priv = GET_PRIVATE(acc);
2637  while (priv->parent)
2638  {
2639  acc = priv->parent;
2640  priv = GET_PRIVATE(acc);
2641  }
2642 
2643  return acc;
2644 }

◆ gnc_account_get_tree_depth()

gint gnc_account_get_tree_depth ( const Account account)

Return the number of levels of descendants accounts below the specified account.

The returned number does not include the specified account itself.

Parameters
accountThe account to query.
Returns
The number of levels of descendants.

Definition at line 2734 of file Account.c.

2735 {
2736  AccountPrivate *priv;
2737  GList *node;
2738  gint depth = 0, child_depth;
2739 
2740  g_return_val_if_fail(GNC_IS_ACCOUNT(account), 0);
2741 
2742  priv = GET_PRIVATE(account);
2743  if (!priv->children)
2744  return 1;
2745 
2746  for (node = priv->children; node; node = g_list_next(node))
2747  {
2748  child_depth = gnc_account_get_tree_depth(node->data);
2749  depth = MAX(depth, child_depth);
2750  }
2751  return depth + 1;
2752 }
gint gnc_account_get_tree_depth(const Account *account)
Return the number of levels of descendants accounts below the specified account.
Definition: Account.c:2734

◆ gnc_account_get_type()

GType gnc_account_get_type ( void  )

Returns the GType type system description of the Account class.

This must not be confused with the GNCAccountType as returned by xaccAccountGetType().

◆ gnc_account_insert_split()

gboolean gnc_account_insert_split ( Account acc,
Split *  s 
)

Insert the given split from an account.

Parameters
accThe account to which the split should be added.
sThe split to be added.
Returns
TRUE is the split is successfully added to the set of splits in the account. FALSE if the addition fails for any reason (including that the split is already in the account).

Definition at line 1734 of file Account.c.

1735 {
1736  AccountPrivate *priv;
1737  GList *node;
1738 
1739  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
1740  g_return_val_if_fail(GNC_IS_SPLIT(s), FALSE);
1741 
1742  priv = GET_PRIVATE(acc);
1743  node = g_list_find(priv->splits, s);
1744  if (node)
1745  return FALSE;
1746 
1747  if (qof_instance_get_editlevel(acc) == 0)
1748  {
1749  priv->splits = g_list_insert_sorted(priv->splits, s,
1750  (GCompareFunc)xaccSplitOrder);
1751  }
1752  else
1753  {
1754  priv->splits = g_list_prepend(priv->splits, s);
1755  priv->sort_dirty = TRUE;
1756  }
1757 
1758  //FIXME: find better event
1759  qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, NULL);
1760  /* Also send an event based on the account */
1761  qof_event_gen(&acc->inst, GNC_EVENT_ITEM_ADDED, s);
1762 
1763  priv->balance_dirty = TRUE;
1764 // DRH: Should the below be added? It is present in the delete path.
1765 // xaccAccountRecomputeBalance(acc);
1766  return TRUE;
1767 }
gint xaccSplitOrder(const Split *sa, const Split *sb)
The xaccSplitOrder(sa,sb) method is useful for sorting.
Definition: Split.c:1485
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition: qofevent.cpp:234
#define GNC_EVENT_ITEM_ADDED
These events are used when a split is added to an account.
Definition: gnc-event.h:45

◆ gnc_account_is_root()

gboolean gnc_account_is_root ( const Account account)

This routine indicates whether the specified account is the root node of an account tree.

Parameters
accountA pointer to any account.
Returns
TRUE if this account is of type ROOT. FALSE otherwise.

Definition at line 2647 of file Account.c.

2648 {
2649  g_return_val_if_fail(GNC_IS_ACCOUNT(account), FALSE);
2650  return (GET_PRIVATE(account)->parent == NULL);
2651 }

◆ gnc_account_join_children()

void gnc_account_join_children ( Account to_parent,
Account from_parent 
)

The gnc_account_join_children() subroutine will move (reparent) all child accounts from the from_parent account to the to_parent account, preserving the account hierarchy.

It will also take care that the moved accounts will have the to_parent's book parent as well.

Definition at line 4804 of file Account.c.

4805 {
4806  AccountPrivate *from_priv;
4807  GList *children, *node;
4808 
4809  /* errors */
4810  g_return_if_fail(GNC_IS_ACCOUNT(to_parent));
4811  g_return_if_fail(GNC_IS_ACCOUNT(from_parent));
4812 
4813  /* optimizations */
4814  from_priv = GET_PRIVATE(from_parent);
4815  if (!from_priv->children)
4816  return;
4817 
4818  ENTER (" ");
4819  children = g_list_copy(from_priv->children);
4820  for (node = children; node; node = g_list_next(node))
4821  gnc_account_append_child(to_parent, node->data);
4822  g_list_free(children);
4823  LEAVE (" ");
4824 }
void gnc_account_append_child(Account *new_parent, Account *child)
This function will remove from the child account any pre-existing parent relationship, and will then add the account as a child of the new parent.
Definition: Account.c:2525
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:261
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:271

◆ gnc_account_list_name_violations()

GList* gnc_account_list_name_violations ( QofBook *  book,
const gchar *  separator 
)

Runs through all the accounts and returns a list of account names that contain the provided separator character.

This can be used to check if certain account names are invalid.

Parameters
bookPointer to the book with accounts to verify
separatorThe separator character to verify against
Returns
A GList of invalid account names. Should be freed with g_list_free if no longer needed.

Definition at line 199 of file Account.c.

200 {
201  Account *root_account = gnc_book_get_root_account(book);
202  GList *accounts, *node;
203  GList *invalid_list = NULL;
204 
205  g_return_val_if_fail (separator != NULL, NULL);
206 
207  if (root_account == NULL)
208  return NULL;
209 
210  accounts = gnc_account_get_descendants (root_account);
211  for (node = accounts; node; node = g_list_next(node))
212  {
213  Account *acct = (Account*)node->data;
214  gchar *acct_name = g_strdup ( xaccAccountGetName ( acct ) );
215 
216  if ( g_strstr_len ( acct_name, -1, separator ) )
217  invalid_list = g_list_prepend ( invalid_list, (gpointer) acct_name );
218  else
219  g_free ( acct_name );
220  }
221  if (accounts != NULL)
222  {
223  g_list_free(accounts);
224  }
225 
226  return invalid_list;
227 }
STRUCTS.
GList * gnc_account_get_descendants(const Account *account)
This routine returns a flat list of all of the accounts that are descendants of the specified account...
Definition: Account.c:2755
const char * xaccAccountGetName(const Account *acc)
Get the account's name.
Definition: Account.c:3031

◆ gnc_account_merge_children()

void gnc_account_merge_children ( Account parent)

The gnc_account_merge_children() subroutine will go through an account, merging all child accounts that have the same name and description.

This function is useful when importing Quicken(TM) files.

Definition at line 4829 of file Account.c.

4830 {
4831  AccountPrivate *ppriv, *priv_a, *priv_b;
4832  GList *node_a, *node_b, *work, *worker;
4833 
4834  g_return_if_fail(GNC_IS_ACCOUNT(parent));
4835 
4836  ppriv = GET_PRIVATE(parent);
4837  for (node_a = ppriv->children; node_a; node_a = node_a->next)
4838  {
4839  Account *acc_a = node_a->data;
4840 
4841  priv_a = GET_PRIVATE(acc_a);
4842  for (node_b = node_a->next; node_b; node_b = g_list_next(node_b))
4843  {
4844  Account *acc_b = node_b->data;
4845 
4846  priv_b = GET_PRIVATE(acc_b);
4847  if (0 != null_strcmp(priv_a->accountName, priv_b->accountName))
4848  continue;
4849  if (0 != null_strcmp(priv_a->accountCode, priv_b->accountCode))
4850  continue;
4851  if (0 != null_strcmp(priv_a->description, priv_b->description))
4852  continue;
4853  if (0 != null_strcmp(xaccAccountGetColor(acc_a),
4854  xaccAccountGetColor(acc_b)))
4855  continue;
4856  if (!gnc_commodity_equiv(priv_a->commodity, priv_b->commodity))
4857  continue;
4858  if (0 != null_strcmp(xaccAccountGetNotes(acc_a),
4859  xaccAccountGetNotes(acc_b)))
4860  continue;
4861  if (priv_a->type != priv_b->type)
4862  continue;
4863 
4864  /* consolidate children */
4865  if (priv_b->children)
4866  {
4867  work = g_list_copy(priv_b->children);
4868  for (worker = work; worker; worker = g_list_next(worker))
4869  gnc_account_append_child (acc_a, (Account *)worker->data);
4870  g_list_free(work);
4871 
4872  qof_event_gen (&acc_a->inst, QOF_EVENT_MODIFY, NULL);
4873  qof_event_gen (&acc_b->inst, QOF_EVENT_MODIFY, NULL);
4874  }
4875 
4876  /* recurse to do the children's children */
4878 
4879  /* consolidate transactions */
4880  while (priv_b->splits)
4881  xaccSplitSetAccount (priv_b->splits->data, acc_a);
4882 
4883  /* move back one before removal. next iteration around the loop
4884  * will get the node after node_b */
4885  node_b = g_list_previous(node_b);
4886 
4887  /* The destroy function will remove from list -- node_a is ok,
4888  * it's before node_b */
4889  xaccAccountBeginEdit (acc_b);
4890  xaccAccountDestroy (acc_b);
4891  }
4892  }
4893 }
void gnc_account_append_child(Account *new_parent, Account *child)
This function will remove from the child account any pre-existing parent relationship, and will then add the account as a child of the new parent.
Definition: Account.c:2525
STRUCTS.
void xaccAccountDestroy(Account *acc)
The xaccAccountDestroy() routine can be used to get rid of an account.
Definition: Account.c:1414
const char * xaccAccountGetColor(const Account *acc)
Get the account's color.
Definition: Account.c:3100
gint null_strcmp(const gchar *da, const gchar *db)
The null_strcmp compares strings a and b the same way that strcmp() does, except that either may be n...
Definition: qofutil.cpp:123
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition: Account.c:1294
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition: qofevent.cpp:234
gboolean gnc_commodity_equiv(const gnc_commodity *a, const gnc_commodity *b)
This routine returns TRUE if the two commodities are equivalent.
void gnc_account_merge_children(Account *parent)
The gnc_account_merge_children() subroutine will go through an account, merging all child accounts th...
Definition: Account.c:4829
const char * xaccAccountGetNotes(const Account *acc)
Get the account's notes.
Definition: Account.c:3129

◆ gnc_account_n_children()

gint gnc_account_n_children ( const Account account)

Return the number of children of the specified account.

The returned number does not include the account itself.

Parameters
accountThe account to query.
Returns
The number of children of the specified account.

Definition at line 2676 of file Account.c.

2677 {
2678  g_return_val_if_fail(GNC_IS_ACCOUNT(account), 0);
2679  return g_list_length(GET_PRIVATE(account)->children);
2680 }

◆ gnc_account_n_descendants()

gint gnc_account_n_descendants ( const Account account)

Return the number of descendants of the specified account.

The returned number does not include the account itself.

Parameters
accountThe account to query.
Returns
The number of descendants of the specified account.

Definition at line 2698 of file Account.c.

2699 {
2700  AccountPrivate *priv;
2701  GList *node;
2702  gint count = 0;
2703 
2704  g_return_val_if_fail(GNC_IS_ACCOUNT(account), 0);
2705 
2706  priv = GET_PRIVATE(account);
2707  for (node = priv->children; node; node = g_list_next(node))
2708  {
2709  count += gnc_account_n_descendants(node->data) + 1;
2710  }
2711  return count;
2712 }
gint gnc_account_n_descendants(const Account *account)
Return the number of descendants of the specified account.
Definition: Account.c:2698

◆ gnc_account_name_violations_errmsg()

gchar* gnc_account_name_violations_errmsg ( const gchar *  separator,
GList *  invalid_account_names 
)

Composes a translatable error message showing which account names clash with the current account separator.

Can be called after gnc_account_list_name_violations to have a consistent error message in different parts of GnuCash

Parameters
separatorThe separator character that was verified against
invalid_account_namesA GList of invalid account names.
Returns
An error message that can be displayed to the user or logged. This message string should be freed with g_free when no longer needed.

Definition at line 162 of file Account.c.

163 {
164  GList *node;
165  gchar *message = NULL;
166  gchar *account_list = NULL;
167 
168  if ( !invalid_account_names )
169  return NULL;
170 
171  for ( node = invalid_account_names; node; node = g_list_next(node))
172  {
173  if ( !account_list )
174  account_list = node->data;
175  else
176  {
177  gchar *tmp_list = NULL;
178 
179  tmp_list = g_strconcat (account_list, "\n", node->data, NULL );
180  g_free ( account_list );
181  account_list = tmp_list;
182  }
183  }
184 
185  /* Translators: The first %s will be the account separator character,
186  the second %s is a list of account names.
187  The resulting string will be displayed to the user if there are
188  account names containing the separator character. */
189  message = g_strdup_printf(
190  _("The separator character \"%s\" is used in one or more account names.\n\n"
191  "This will result in unexpected behaviour. "
192  "Either change the account names or choose another separator character.\n\n"
193  "Below you will find the list of invalid account names:\n"
194  "%s"), separator, account_list );
195  g_free ( account_list );
196  return message;
197 }

◆ gnc_account_nth_child()

Account* gnc_account_nth_child ( const Account parent,
gint  num 
)

Return the n'th child account of the specified parent account.

If the parent account is not specified or the child index number is invalid, this function returns NULL.

Parameters
parentThe parent account to check.
numThe index number of the child account that should be returned.
Returns
A pointer to the specified child account, or NULL

Definition at line 2691 of file Account.c.

2692 {
2693  g_return_val_if_fail(GNC_IS_ACCOUNT(parent), NULL);
2694  return g_list_nth_data(GET_PRIVATE(parent)->children, num);
2695 }

◆ gnc_account_remove_child()

void gnc_account_remove_child ( Account parent,
Account child 
)

This function will remove the specified child account from the specified parent account.

It will NOT free the associated memory or otherwise alter the account: the account can now be reparented to a new location. Note, however, that it will mark the old parents as having been modified.

Parameters
parentThe parent account from which the child should be removed.
childThe child account to remove.

Definition at line 2587 of file Account.c.

2588 {
2589  AccountPrivate *ppriv, *cpriv;
2590  GncEventData ed;
2591 
2592  if (!child) return;
2593 
2594  /* Note this routine might be called on accounts which
2595  * are not yet parented. */
2596  if (!parent) return;
2597 
2598  ppriv = GET_PRIVATE(parent);
2599  cpriv = GET_PRIVATE(child);
2600 
2601  if (cpriv->parent != parent)
2602  {
2603  PERR ("account not a child of parent");
2604  return;
2605  }
2606 
2607  /* Gather event data */
2608  ed.node = parent;
2609  ed.idx = g_list_index(ppriv->children, child);
2610 
2611  ppriv->children = g_list_remove(ppriv->children, child);
2612 
2613  /* Now send the event. */
2614  qof_event_gen(&child->inst, QOF_EVENT_REMOVE, &ed);
2615 
2616  /* clear the account's parent pointer after REMOVE event generation. */
2617  cpriv->parent = NULL;
2618 
2619  qof_event_gen (&parent->inst, QOF_EVENT_MODIFY, NULL);
2620 }
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:237
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition: qofevent.cpp:234

◆ gnc_account_remove_split()

gboolean gnc_account_remove_split ( Account acc,
Split *  s 
)

Remove the given split from an account.

Parameters
accThe account from which the split should be removed.
sThe split to be removed.
Returns
TRUE is the split is successfully removed from the set of splits in the account. FALSE if the removal fails for any reason.

Definition at line 1770 of file Account.c.

1771 {
1772  AccountPrivate *priv;
1773  GList *node;
1774 
1775  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
1776  g_return_val_if_fail(GNC_IS_SPLIT(s), FALSE);
1777 
1778  priv = GET_PRIVATE(acc);
1779  node = g_list_find(priv->splits, s);
1780  if (NULL == node)
1781  return FALSE;
1782 
1783  priv->splits = g_list_delete_link(priv->splits, node);
1784  //FIXME: find better event type
1785  qof_event_gen(&acc->inst, QOF_EVENT_MODIFY, NULL);
1786  // And send the account-based event, too
1787  qof_event_gen(&acc->inst, GNC_EVENT_ITEM_REMOVED, s);
1788 
1789  priv->balance_dirty = TRUE;
1791  return TRUE;
1792 }
void xaccAccountRecomputeBalance(Account *acc)
The following recompute the partial balances (stored with the transaction) and the total balance...
Definition: Account.c:2072
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition: qofevent.cpp:234

◆ gnc_account_set_balance_dirty()

void gnc_account_set_balance_dirty ( Account acc)

Tell the account that the running balances may be incorrect and need to be recomputed.

Parameters
accSet the flag on this account.

Definition at line 1717 of file Account.c.

1718 {
1719  AccountPrivate *priv;
1720 
1721  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1722 
1723  if (qof_instance_get_destroying(acc))
1724  return;
1725 
1726  priv = GET_PRIVATE(acc);
1727  priv->balance_dirty = TRUE;
1728 }
gboolean qof_instance_get_destroying(gconstpointer ptr)
Retrieve the flag that indicates whether or not this object is about to be destroyed.

◆ gnc_account_set_sort_dirty()

void gnc_account_set_sort_dirty ( Account acc)

Tell the account believes that the splits may be incorrectly sorted and need to be resorted.

Parameters
accSet the flag on this account.

Definition at line 1703 of file Account.c.

1704 {
1705  AccountPrivate *priv;
1706 
1707  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1708 
1709  if (qof_instance_get_destroying(acc))
1710  return;
1711 
1712  priv = GET_PRIVATE(acc);
1713  priv->sort_dirty = TRUE;
1714 }
gboolean qof_instance_get_destroying(gconstpointer ptr)
Retrieve the flag that indicates whether or not this object is about to be destroyed.

◆ gnc_account_set_start_balance()

void gnc_account_set_start_balance ( Account acc,
const gnc_numeric  start_baln 
)

This function will set the starting commodity balance for this account.

This routine is intended for use with backends that do not return the complete list of splits for an account, but rather return a partial list. In such a case, the backend will typically return all of the splits after some certain date, and the 'starting balance' will represent the summation of the splits up to that date.

Definition at line 3197 of file Account.c.

3198 {
3199  AccountPrivate *priv;
3200 
3201  g_return_if_fail(GNC_IS_ACCOUNT(acc));
3202 
3203  priv = GET_PRIVATE(acc);
3204  priv->starting_balance = start_baln;
3205  priv->balance_dirty = TRUE;
3206 }

◆ gnc_account_set_start_cleared_balance()

void gnc_account_set_start_cleared_balance ( Account acc,
const gnc_numeric  start_baln 
)

This function will set the starting cleared commodity balance for this account.

This routine is intended for use with backends that do not return the complete list of splits for an account, but rather return a partial list. In such a case, the backend will typically return all of the splits after some certain date, and the 'starting balance' will represent the summation of the splits up to that date.

Definition at line 3209 of file Account.c.

3211 {
3212  AccountPrivate *priv;
3213 
3214  g_return_if_fail(GNC_IS_ACCOUNT(acc));
3215 
3216  priv = GET_PRIVATE(acc);
3217  priv->starting_cleared_balance = start_baln;
3218  priv->balance_dirty = TRUE;
3219 }

◆ gnc_account_set_start_reconciled_balance()

void gnc_account_set_start_reconciled_balance ( Account acc,
const gnc_numeric  start_baln 
)

This function will set the starting reconciled commodity balance for this account.

This routine is intended for use with backends that do not return the complete list of splits for an account, but rather return a partial list. In such a case, the backend will typically return all of the splits after some certain date, and the 'starting balance' will represent the summation of the splits up to that date.

Definition at line 3222 of file Account.c.

3224 {
3225  AccountPrivate *priv;
3226 
3227  g_return_if_fail(GNC_IS_ACCOUNT(acc));
3228 
3229  priv = GET_PRIVATE(acc);
3230  priv->starting_reconciled_balance = start_baln;
3231  priv->balance_dirty = TRUE;
3232 }

◆ gnc_get_account_separator_string()

const gchar* gnc_get_account_separator_string ( void  )

Returns the account separation character chosen by the user.

Returns
The character to use.

Definition at line 132 of file Account.c.

133 {
134  return account_separator;
135 }

◆ xaccAccountBeginEdit()

void xaccAccountBeginEdit ( Account account)

The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account updates.

Definition at line 1294 of file Account.c.

1295 {
1296  g_return_if_fail(acc);
1297  qof_begin_edit(&acc->inst);
1298 }
gboolean qof_begin_edit(QofInstance *inst)
begin_edit

◆ xaccAccountCommitEdit()

void xaccAccountCommitEdit ( Account account)

ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account updates.

Definition at line 1335 of file Account.c.

1336 {
1337  AccountPrivate *priv;
1338  QofBook *book;
1339 
1340  g_return_if_fail(acc);
1341  if (!qof_commit_edit(&acc->inst)) return;
1342 
1343  /* If marked for deletion, get rid of subaccounts first,
1344  * and then the splits ... */
1345  priv = GET_PRIVATE(acc);
1346  if (qof_instance_get_destroying(acc))
1347  {
1348  GList *lp, *slist;
1349  QofCollection *col;
1350 
1351  qof_instance_increase_editlevel(acc);
1352 
1353  /* First, recursively free children */
1354  xaccFreeAccountChildren(acc);
1355 
1356  PINFO ("freeing splits for account %p (%s)",
1357  acc, priv->accountName ? priv->accountName : "(null)");
1358 
1359  book = qof_instance_get_book(acc);
1360 
1361  /* If book is shutting down, just clear the split list. The splits
1362  themselves will be destroyed by the transaction code */
1363  if (!qof_book_shutting_down(book))
1364  {
1365  slist = g_list_copy(priv->splits);
1366  for (lp = slist; lp; lp = lp->next)
1367  {
1368  Split *s = lp->data;
1369  xaccSplitDestroy (s);
1370  }
1371  g_list_free(slist);
1372  }
1373  else
1374  {
1375  g_list_free(priv->splits);
1376  priv->splits = NULL;
1377  }
1378 
1379  /* It turns out there's a case where this assertion does not hold:
1380  When the user tries to delete an Imbalance account, while also
1381  deleting all the splits in it. The splits will just get
1382  recreated and put right back into the same account!
1383 
1384  g_assert(priv->splits == NULL || qof_book_shutting_down(acc->inst.book));
1385  */
1386 
1387  if (!qof_book_shutting_down(book))
1388  {
1389  col = qof_book_get_collection(book, GNC_ID_TRANS);
1390  qof_collection_foreach(col, destroy_pending_splits_for_account, acc);
1391 
1392  /* the lots should be empty by now */
1393  for (lp = priv->lots; lp; lp = lp->next)
1394  {
1395  GNCLot *lot = lp->data;
1396  gnc_lot_destroy (lot);
1397  }
1398  }
1399  g_list_free(priv->lots);
1400  priv->lots = NULL;
1401 
1402  qof_instance_set_dirty(&acc->inst);
1403  qof_instance_decrease_editlevel(acc);
1404  }
1405  else
1406  {
1407  xaccAccountBringUpToDate(acc);
1408  }
1409 
1410  qof_commit_edit_part2(&acc->inst, on_err, on_done, acc_free);
1411 }
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.
#define PINFO(format, args...)
Print an informational note.
Definition: qoflog.h:249
gboolean xaccSplitDestroy(Split *split)
Destructor.
Definition: Split.c:1456
gboolean qof_instance_get_destroying(gconstpointer ptr)
Retrieve the flag that indicates whether or not this object is about to be destroyed.
gboolean qof_commit_edit(QofInstance *inst)
commit_edit helpers
void qof_collection_foreach(const QofCollection *col, QofInstanceForeachCB cb_func, gpointer user_data)
Call the callback for each entity in the collection.
Definition: qofid.cpp:321
gboolean qof_commit_edit_part2(QofInstance *inst, void(*on_error)(QofInstance *, QofBackendError), void(*on_done)(QofInstance *), void(*on_free)(QofInstance *))
part2 – deal with the backend
QofCollection * qof_book_get_collection(const QofBook *book, QofIdType entity_type)
Return The table of entities of the given type.
Definition: qofbook.cpp:599
gboolean qof_book_shutting_down(const QofBook *book)
Is the book shutting down?
Definition: qofbook.cpp:535

◆ xaccAccountDestroy()

void xaccAccountDestroy ( Account account)

The xaccAccountDestroy() routine can be used to get rid of an account.

The account should have been opened for editing (by calling xaccAccountBeginEdit()) before calling this routine.

Definition at line 1414 of file Account.c.

1415 {
1416  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1417 
1418  qof_instance_set_destroying(acc, TRUE);
1419 
1420  xaccAccountCommitEdit (acc);
1421 }
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.c:1335

◆ xaccAccountEqual()

gboolean xaccAccountEqual ( const Account a,
const Account b,
gboolean  check_guids 
)

Compare two accounts for equality - this is a deep compare.

Definition at line 1489 of file Account.c.

1490 {
1491  AccountPrivate *priv_aa, *priv_ab;
1492 
1493  if (!aa && !ab) return TRUE;
1494 
1495  g_return_val_if_fail(GNC_IS_ACCOUNT(aa), FALSE);
1496  g_return_val_if_fail(GNC_IS_ACCOUNT(ab), FALSE);
1497 
1498  priv_aa = GET_PRIVATE(aa);
1499  priv_ab = GET_PRIVATE(ab);
1500  if (priv_aa->type != priv_ab->type)
1501  {
1502  PWARN ("types differ: %d vs %d", priv_aa->type, priv_ab->type);
1503  return FALSE;
1504  }
1505 
1506  if (g_strcmp0(priv_aa->accountName, priv_ab->accountName) != 0)
1507  {
1508  PWARN ("names differ: %s vs %s", priv_aa->accountName, priv_ab->accountName);
1509  return FALSE;
1510  }
1511 
1512  if (g_strcmp0(priv_aa->accountCode, priv_ab->accountCode) != 0)
1513  {
1514  PWARN ("codes differ: %s vs %s", priv_aa->accountCode, priv_ab->accountCode);
1515  return FALSE;
1516  }
1517 
1518  if (g_strcmp0(priv_aa->description, priv_ab->description) != 0)
1519  {
1520  PWARN ("descriptions differ: %s vs %s", priv_aa->description, priv_ab->description);
1521  return FALSE;
1522  }
1523 
1524  if (!gnc_commodity_equal(priv_aa->commodity, priv_ab->commodity))
1525  {
1526  PWARN ("commodities differ");
1527  return FALSE;
1528  }
1529 
1530  if (check_guids)
1531  {
1532  if (qof_instance_guid_compare(aa, ab) != 0)
1533  {
1534  PWARN ("GUIDs differ");
1535  return FALSE;
1536  }
1537  }
1538 
1539  if (qof_instance_compare_kvp (QOF_INSTANCE (aa), QOF_INSTANCE (ab)) != 0)
1540  {
1541  char *frame_a;
1542  char *frame_b;
1543 
1544  frame_a = qof_instance_kvp_as_string (QOF_INSTANCE (aa));
1545  frame_b = qof_instance_kvp_as_string (QOF_INSTANCE (ab));
1546 
1547  PWARN ("kvp frames differ:\n%s\n\nvs\n\n%s", frame_a, frame_b);
1548 
1549  g_free (frame_a);
1550  g_free (frame_b);
1551 
1552  return FALSE;
1553  }
1554 
1555  if (!gnc_numeric_equal(priv_aa->starting_balance, priv_ab->starting_balance))
1556  {
1557  char *str_a;
1558  char *str_b;
1559 
1560  str_a = gnc_numeric_to_string(priv_aa->starting_balance);
1561  str_b = gnc_numeric_to_string(priv_ab->starting_balance);
1562 
1563  PWARN ("starting balances differ: %s vs %s", str_a, str_b);
1564 
1565  g_free (str_a);
1566  g_free (str_b);
1567 
1568  return FALSE;
1569  }
1570 
1571  if (!gnc_numeric_equal(priv_aa->starting_cleared_balance,
1572  priv_ab->starting_cleared_balance))
1573  {
1574  char *str_a;
1575  char *str_b;
1576 
1577  str_a = gnc_numeric_to_string(priv_aa->starting_cleared_balance);
1578  str_b = gnc_numeric_to_string(priv_ab->starting_cleared_balance);
1579 
1580  PWARN ("starting cleared balances differ: %s vs %s", str_a, str_b);
1581 
1582  g_free (str_a);
1583  g_free (str_b);
1584 
1585  return FALSE;
1586  }
1587 
1588  if (!gnc_numeric_equal(priv_aa->starting_reconciled_balance,
1589  priv_ab->starting_reconciled_balance))
1590  {
1591  char *str_a;
1592  char *str_b;
1593 
1594  str_a = gnc_numeric_to_string(priv_aa->starting_reconciled_balance);
1595  str_b = gnc_numeric_to_string(priv_ab->starting_reconciled_balance);
1596 
1597  PWARN ("starting reconciled balances differ: %s vs %s", str_a, str_b);
1598 
1599  g_free (str_a);
1600  g_free (str_b);
1601 
1602  return FALSE;
1603  }
1604 
1605  if (!gnc_numeric_equal(priv_aa->balance, priv_ab->balance))
1606  {
1607  char *str_a;
1608  char *str_b;
1609 
1610  str_a = gnc_numeric_to_string(priv_aa->balance);
1611  str_b = gnc_numeric_to_string(priv_ab->balance);
1612 
1613  PWARN ("balances differ: %s vs %s", str_a, str_b);
1614 
1615  g_free (str_a);
1616  g_free (str_b);
1617 
1618  return FALSE;
1619  }
1620 
1621  if (!gnc_numeric_equal(priv_aa->cleared_balance, priv_ab->cleared_balance))
1622  {
1623  char *str_a;
1624  char *str_b;
1625 
1626  str_a = gnc_numeric_to_string(priv_aa->cleared_balance);
1627  str_b = gnc_numeric_to_string(priv_ab->cleared_balance);
1628 
1629  PWARN ("cleared balances differ: %s vs %s", str_a, str_b);
1630 
1631  g_free (str_a);
1632  g_free (str_b);
1633 
1634  return FALSE;
1635  }
1636 
1637  if (!gnc_numeric_equal(priv_aa->reconciled_balance, priv_ab->reconciled_balance))
1638  {
1639  char *str_a;
1640  char *str_b;
1641 
1642  str_a = gnc_numeric_to_string(priv_aa->reconciled_balance);
1643  str_b = gnc_numeric_to_string(priv_ab->reconciled_balance);
1644 
1645  PWARN ("reconciled balances differ: %s vs %s", str_a, str_b);
1646 
1647  g_free (str_a);
1648  g_free (str_b);
1649 
1650  return FALSE;
1651  }
1652 
1653  /* no parent; always compare downwards. */
1654 
1655  {
1656  GList *la = priv_aa->splits;
1657  GList *lb = priv_ab->splits;
1658 
1659  if ((la && !lb) || (!la && lb))
1660  {
1661  PWARN ("only one has splits");
1662  return FALSE;
1663  }
1664 
1665  if (la && lb)
1666  {
1667  /* presume that the splits are in the same order */
1668  while (la && lb)
1669  {
1670  Split *sa = (Split *) la->data;
1671  Split *sb = (Split *) lb->data;
1672 
1673  if (!xaccSplitEqual(sa, sb, check_guids, TRUE, FALSE))
1674  {
1675  PWARN ("splits differ");
1676  return(FALSE);
1677  }
1678 
1679  la = la->next;
1680  lb = lb->next;
1681  }
1682 
1683  if ((la != NULL) || (lb != NULL))
1684  {
1685  PWARN ("number of splits differs");
1686  return(FALSE);
1687  }
1688  }
1689  }
1690 
1691  if (!xaccAcctChildrenEqual(priv_aa->children, priv_ab->children, check_guids))
1692  {
1693  PWARN ("children differ");
1694  return FALSE;
1695  }
1696 
1697  return(TRUE);
1698 }
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
Equivalence predicate: Returns TRUE (1) if a and b represent the same number.
gboolean gnc_commodity_equal(const gnc_commodity *a, const gnc_commodity *b)
This routine returns TRUE if the two commodities are equal.
gchar * gnc_numeric_to_string(gnc_numeric n)
Convert to string.
gboolean xaccSplitEqual(const Split *sa, const Split *sb, gboolean check_guids, gboolean check_balances, gboolean check_txn_splits)
Equality.
Definition: Split.c:776
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:243
gint qof_instance_guid_compare(gconstpointer ptr1, gconstpointer ptr2)
Compare the GncGUID values of two instances.

◆ xaccAccountGainsAccount()

Account* xaccAccountGainsAccount ( Account acc,
gnc_commodity *  curr 
)

Retrieve the gains account used by this account for the indicated currency, creating and recording a new one if necessary.

FIXME: There is at present no interface to designate an existing account, and the new account name is hard coded to "Orphaned Gains -- CUR"

FIXME: There is no provision for creating separate accounts for anything other than currency, e.g. holding period of a security.

Definition at line 4589 of file Account.c.

4590 {
4591  GValue v = G_VALUE_INIT;
4592  gchar *curr_name = g_strdup_printf ("/lot-mgmt/gains-act/%s",
4594  GncGUID *guid = NULL;
4595  Account *gains_account;
4596 
4597  g_return_val_if_fail (acc != NULL, NULL);
4598  qof_instance_get_kvp (QOF_INSTANCE(acc), curr_name, &v);
4599  if (G_VALUE_HOLDS_BOXED (&v))
4600  guid = (GncGUID*)g_value_get_boxed (&v);
4601  if (guid == NULL) /* No gains account for this currency */
4602  {
4603  gains_account = GetOrMakeOrphanAccount (gnc_account_get_root (acc),
4604  curr);
4605  guid = (GncGUID*)qof_instance_get_guid (QOF_INSTANCE (gains_account));
4606  xaccAccountBeginEdit (acc);
4607  {
4608  GValue vr = G_VALUE_INIT;
4609  g_value_init (&vr, GNC_TYPE_GUID);
4610  g_value_set_boxed (&vr, guid);
4611  qof_instance_set_kvp (QOF_INSTANCE (acc), curr_name, &vr);
4612  qof_instance_set_dirty (QOF_INSTANCE (acc));
4613  }
4614  xaccAccountCommitEdit (acc);
4615  }
4616  else
4617  gains_account = xaccAccountLookup (guid,
4618  qof_instance_get_book(acc));
4619 
4620  g_free (curr_name);
4621  return gains_account;
4622 }
void qof_instance_get_kvp(const QofInstance *inst, const gchar *key, GValue *value)
Retrieves the contents of a KVP slot into a provided GValue.
const GncGUID * qof_instance_get_guid(gconstpointer inst)
Return the GncGUID of this instance.
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.
STRUCTS.
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition: Account.c:1294
const char * gnc_commodity_get_unique_name(const gnc_commodity *cm)
Retrieve the 'unique' name for the specified commodity.
void qof_instance_set_kvp(QofInstance *inst, const gchar *key, const GValue *value)
Sets a KVP slot to a value from a GValue.
Account * gnc_account_get_root(Account *acc)
This routine returns the root account of the account tree that the specified account belongs to...
Definition: Account.c:2630
The type used to store guids in C.
Definition: guid.h:75
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.c:1335
Account * xaccAccountLookup(const GncGUID *guid, QofBook *book)
The xaccAccountLookup() subroutine will return the account associated with the given id...
Definition: Account.c:1841

◆ xaccAccountGetAutoInterestXfer()

gboolean xaccAccountGetAutoInterestXfer ( const Account account,
gboolean  default_value 
)

Returns a per-account flag: Prior to reconciling an account which charges or pays interest, this flag tells whether to prompt the user to enter a transaction for the interest charge or payment.

This per-account flag overrides the global preference.

Definition at line 4500 of file Account.c.

4501 {
4502  return boolean_from_key (acc, "reconcile-info/auto-interest-transfer");
4503 }

◆ xaccAccountGetCommoditySCU()

int xaccAccountGetCommoditySCU ( const Account account)

Return the SCU for the account.

If a non-standard SCU has been set for the account, that is returned; else the default SCU for the account commodity is returned.

Definition at line 2455 of file Account.c.

2456 {
2457  AccountPrivate *priv;
2458 
2459  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), 0);
2460 
2461  priv = GET_PRIVATE(acc);
2462  if (priv->non_standard_scu || !priv->commodity)
2463  return priv->commodity_scu;
2464  return gnc_commodity_get_fraction(priv->commodity);
2465 }
int gnc_commodity_get_fraction(const gnc_commodity *cm)
Retrieve the fraction for the specified commodity.

◆ xaccAccountGetCommoditySCUi()

int xaccAccountGetCommoditySCUi ( const Account account)

Return the 'internal' SCU setting.

This returns the over-ride SCU for the account (which might not be set, and might be zero).

Definition at line 2448 of file Account.c.

2449 {
2450  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), 0);
2451  return GET_PRIVATE(acc)->commodity_scu;
2452 }

◆ xaccAccountGetNonStdSCU()

gboolean xaccAccountGetNonStdSCU ( const Account account)

Return boolean, indicating whether this account uses a non-standard SCU.

Definition at line 2484 of file Account.c.

2485 {
2486  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), 0);
2487  return GET_PRIVATE(acc)->non_standard_scu;
2488 }

◆ xaccAccountGetType()

GNCAccountType xaccAccountGetType ( const Account account)

Returns the account's account type.

This must not be confused with the GType as returned by gnc_account_get_type(), which is related to glib's type system.

Definition at line 3009 of file Account.c.

3010 {
3011  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), ACCT_TYPE_NONE);
3012  return GET_PRIVATE(acc)->type;
3013 }
Not a type.
Definition: Account.h:105

◆ xaccAccountHasAncestor()

gboolean xaccAccountHasAncestor ( const Account acc,
const Account ancestor 
)

Returns true if the account is 'ancestor' or has 'ancestor' as an ancestor.

An ancestor account may be the accounts parent, its parent's parent, its parent's parent's parent, etc. Returns false if either one is NULL.

Definition at line 4006 of file Account.c.

4007 {
4008  const Account *parent;
4009 
4010  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
4011  g_return_val_if_fail(GNC_IS_ACCOUNT(ancestor), FALSE);
4012 
4013  parent = acc;
4014  while (parent && parent != ancestor)
4015  parent = GET_PRIVATE(parent)->parent;
4016 
4017  return (parent == ancestor);
4018 }
STRUCTS.

◆ xaccAccountIsPriced()

gboolean xaccAccountIsPriced ( const Account acc)

Returns true if the account is a stock, mutual fund or currency, otherwise false.

Definition at line 4291 of file Account.c.

4292 {
4293  AccountPrivate *priv;
4294 
4295  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
4296 
4297  priv = GET_PRIVATE(acc);
4298  return (priv->type == ACCT_TYPE_STOCK || priv->type == ACCT_TYPE_MUTUAL ||
4299  priv->type == ACCT_TYPE_CURRENCY);
4300 }
Mutual Fund accounts will typically be shown in registers which show three columns: price...
Definition: Account.h:125
Stock accounts will typically be shown in registers which show three columns: price, number of shares, and value.
Definition: Account.h:122
The currency account type indicates that the account is a currency trading account.
Definition: Account.h:129

◆ xaccAccountLookup()

Account* xaccAccountLookup ( const GncGUID guid,
QofBook *  book 
)

The xaccAccountLookup() subroutine will return the account associated with the given id, or NULL if there is no such account.

Definition at line 1841 of file Account.c.

1842 {
1843  QofCollection *col;
1844  if (!guid || !book) return NULL;
1845  col = qof_book_get_collection (book, GNC_ID_ACCOUNT);
1846  return (Account *) qof_collection_lookup_entity (col, guid);
1847 }
QofInstance * qof_collection_lookup_entity(const QofCollection *col, const GncGUID *guid)
Find the entity going only from its guid.
Definition: qofid.cpp:214
STRUCTS.
QofCollection * qof_book_get_collection(const QofBook *book, QofIdType entity_type)
Return The table of entities of the given type.
Definition: qofbook.cpp:599

◆ xaccAccountOrder()

int xaccAccountOrder ( const Account account_1,
const Account account_2 
)

The xaccAccountOrder() subroutine defines a sorting order on accounts.

It takes pointers to two accounts, and returns an int < 0 if the first account is "less than" the second, returns an int > 0 if the first is "greater than" the second, and 0 if they are equal. To determine the sort order, first the account codes are compared, and if these are equal, then account types, then account names. If still equal, it compares GUID to ensure that there aren't any ties.

Definition at line 2146 of file Account.c.

2147 {
2148  AccountPrivate *priv_aa, *priv_ab;
2149  char *da, *db;
2150  char *endptr = NULL;
2151  int ta, tb, result;
2152  long la, lb;
2153 
2154  if ( aa && !ab ) return -1;
2155  if ( !aa && ab ) return +1;
2156  if ( !aa && !ab ) return 0;
2157 
2158  priv_aa = GET_PRIVATE(aa);
2159  priv_ab = GET_PRIVATE(ab);
2160 
2161  /* sort on accountCode strings */
2162  da = priv_aa->accountCode;
2163  db = priv_ab->accountCode;
2164 
2165  /* If accountCodes are both base 36 integers do an integer sort */
2166  la = strtoul (da, &endptr, 36);
2167  if ((*da != '\0') && (*endptr == '\0'))
2168  {
2169  lb = strtoul (db, &endptr, 36);
2170  if ((*db != '\0') && (*endptr == '\0'))
2171  {
2172  if (la < lb) return -1;
2173  if (la > lb) return +1;
2174  }
2175  }
2176 
2177  /* Otherwise do a string sort */
2178  result = g_strcmp0 (da, db);
2179  if (result)
2180  return result;
2181 
2182  /* if account-type-order array not initialized, initialize it */
2183  /* this will happen at most once during program invocation */
2184  if (-1 == revorder[0])
2185  {
2186  int i;
2187  for (i = 0; i < NUM_ACCOUNT_TYPES; i++)
2188  {
2189  revorder [typeorder[i]] = i;
2190  }
2191  }
2192 
2193  /* otherwise, sort on account type */
2194  ta = priv_aa->type;
2195  tb = priv_ab->type;
2196  ta = revorder[ta];
2197  tb = revorder[tb];
2198  if (ta < tb) return -1;
2199  if (ta > tb) return +1;
2200 
2201  /* otherwise, sort on accountName strings */
2202  da = priv_aa->accountName;
2203  db = priv_ab->accountName;
2204  result = safe_utf8_collate(da, db);
2205  if (result)
2206  return result;
2207 
2208  /* guarantee a stable sort */
2209  return qof_instance_guid_compare(aa, ab);
2210 }
int safe_utf8_collate(const char *da, const char *db)
Collate two UTF-8 strings.
stop here; the following types just aren&#39;t ready for prime time
Definition: Account.h:161
gint qof_instance_guid_compare(gconstpointer ptr1, gconstpointer ptr2)
Compare the GncGUID values of two instances.

◆ xaccAccountSetAutoInterestXfer()

void xaccAccountSetAutoInterestXfer ( Account account,
gboolean  value 
)

Sets a per-account flag: Prior to reconciling an account which charges or pays interest, this flag tells whether to prompt the user to enter a transaction for the interest charge or payment.

This per-account flag overrides the global preference.

Definition at line 4509 of file Account.c.

4510 {
4511  set_boolean_key (acc, "reconcile-info/auto-interest-transfer", option);
4512 }

◆ xaccAccountSetCommoditySCU()

void xaccAccountSetCommoditySCU ( Account account,
int  frac 
)

Set the SCU for the account.

Normally, this routine is not required, as the default SCU for an account is given by its commodity.

Definition at line 2432 of file Account.c.

2433 {
2434  AccountPrivate *priv;
2435 
2436  g_return_if_fail(GNC_IS_ACCOUNT(acc));
2437 
2438  priv = GET_PRIVATE(acc);
2439  xaccAccountBeginEdit(acc);
2440  priv->commodity_scu = scu;
2441  if (scu != gnc_commodity_get_fraction(priv->commodity))
2442  priv->non_standard_scu = TRUE;
2443  mark_account(acc);
2444  xaccAccountCommitEdit(acc);
2445 }
int gnc_commodity_get_fraction(const gnc_commodity *cm)
Retrieve the fraction for the specified commodity.
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition: Account.c:1294
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.c:1335

◆ xaccAccountSetNonStdSCU()

void xaccAccountSetNonStdSCU ( Account account,
gboolean  flag 
)

Set the flag indicating that this account uses a non-standard SCU.

Definition at line 2468 of file Account.c.

2469 {
2470  AccountPrivate *priv;
2471 
2472  g_return_if_fail(GNC_IS_ACCOUNT(acc));
2473 
2474  priv = GET_PRIVATE(acc);
2475  if (priv->non_standard_scu == flag)
2476  return;
2477  xaccAccountBeginEdit(acc);
2478  priv->non_standard_scu = flag;
2479  mark_account (acc);
2480  xaccAccountCommitEdit(acc);
2481 }
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition: Account.c:1294
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.c:1335

◆ xaccAccountSortSplits()

void xaccAccountSortSplits ( Account acc,
gboolean  force 
)

The xaccAccountSortSplits() routine will resort the account's splits if the sort is dirty.

If 'force' is true, the account is sorted even if the editlevel is not zero.

Definition at line 1795 of file Account.c.

1796 {
1797  AccountPrivate *priv;
1798 
1799  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1800 
1801  priv = GET_PRIVATE(acc);
1802  if (!priv->sort_dirty || (!force && qof_instance_get_editlevel(acc) > 0))
1803  return;
1804  priv->splits = g_list_sort(priv->splits, (GCompareFunc)xaccSplitOrder);
1805  priv->sort_dirty = FALSE;
1806  priv->balance_dirty = TRUE;
1807 }
gint xaccSplitOrder(const Split *sa, const Split *sb)
The xaccSplitOrder(sa,sb) method is useful for sorting.
Definition: Split.c:1485

◆ xaccCloneAccount()

Account* xaccCloneAccount ( const Account source,
QofBook *  book 
)

The xaccCloneAccount() routine makes a simple copy of the indicated account, placing it in the indicated book.

It copies the account type, name, description, and the kvp values; it does not copy splits/transactions. The book should have a commodity table in it that has commodities with the same unique name as the ones being copied in the account (the commodities in the clone will be those from the book).

Definition at line 1129 of file Account.c.

1130 {
1131  Account *ret;
1132  AccountPrivate *from_priv, *priv;
1133 
1134  g_return_val_if_fail(GNC_IS_ACCOUNT(from), NULL);
1135  g_return_val_if_fail(QOF_IS_BOOK(book), NULL);
1136 
1137  ENTER (" ");
1138  ret = g_object_new (GNC_TYPE_ACCOUNT, NULL);
1139  g_return_val_if_fail (ret, NULL);
1140 
1141  from_priv = GET_PRIVATE(from);
1142  priv = GET_PRIVATE(ret);
1143  xaccInitAccount (ret, book);
1144 
1145  /* Do not Begin/CommitEdit() here; give the caller
1146  * a chance to fix things up, and let them do it.
1147  * Also let caller issue the generate_event (EVENT_CREATE) */
1148  priv->type = from_priv->type;
1149 
1150  priv->accountName = CACHE_INSERT(from_priv->accountName);
1151  priv->accountCode = CACHE_INSERT(from_priv->accountCode);
1152  priv->description = CACHE_INSERT(from_priv->description);
1153 
1154  qof_instance_copy_kvp (QOF_INSTANCE (ret), QOF_INSTANCE (from));
1155 
1156  /* The new book should contain a commodity that matches
1157  * the one in the old book. Find it, use it. */
1158  priv->commodity = gnc_commodity_obtain_twin(from_priv->commodity, book);
1159  gnc_commodity_increment_usage_count(priv->commodity);
1160 
1161  priv->commodity_scu = from_priv->commodity_scu;
1162  priv->non_standard_scu = from_priv->non_standard_scu;
1163 
1164  qof_instance_set_dirty(&ret->inst);
1165  LEAVE (" ");
1166  return ret;
1167 }
STRUCTS.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:261
void gnc_commodity_increment_usage_count(gnc_commodity *cm)
Increment a commodity&#39;s internal counter that tracks how many accounts are using that commodity...
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:271
gnc_commodity * gnc_commodity_obtain_twin(const gnc_commodity *from, QofBook *book)
Given the commodity &#39;findlike&#39;, this routine will find and return the equivalent commodity (commodity...