GnuCash  4.8a-176-g88ecf8dd1
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...
 
gboolean gnc_account_and_descendants_empty (Account *acc)
 
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...
 
void gnc_account_set_defer_bal_computation (Account *acc, gboolean defer)
 Set the defer balance flag. 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.
 
gboolean gnc_account_get_defer_bal_computation (Account *acc)
 Get the account's flag for deferred balance computation.
 
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...
 

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 at the end of the day before the date specified. More...
 
gnc_numeric xaccAccountGetReconciledBalanceAsOfDate (Account *account, time64 date)
 Get the reconciled balance of the account at the end of the day of the date specified. More...
 
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, const gnc_commodity *balance_currency, const 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 xaccAccountGetNoclosingBalanceAsOfDateInCurrency (Account *acc, time64 date, gnc_commodity *report_commodity, gboolean include_children)
 This function gets the balance at the end of the given date, ignoring closing entries, in the desired commodity. More...
 
gnc_numeric xaccAccountGetBalanceAsOfDateInCurrency (Account *account, time64 date, gnc_commodity *report_commodity, gboolean include_children)
 This function gets the balance at the end of the given date in the desired commodity. More...
 
gnc_numeric xaccAccountGetNoclosingBalanceChangeForPeriod (Account *acc, time64 date1, time64 date2, gboolean recurse)
 
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 248 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 105 of file Account.h.

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

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. This function uses a static char*.

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

Definition at line 4977 of file Account.cpp.

4978 {
4979  static char *source = nullptr;
4980  if (!acc) return NULL;
4981 
4982  if (!xaccAccountIsPriced(acc)) return NULL;
4983 
4984  g_free (source);
4985  source = get_kvp_string_tag (acc, "old-price-source");
4986  return source;
4987 }
gboolean xaccAccountIsPriced(const Account *acc)
Returns true if the account is a stock, mutual fund or currency, otherwise false. ...
Definition: Account.cpp:4637

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

4966 {
4967  if (!acc) return;
4968 
4969  if (xaccAccountIsPriced(acc))
4970  set_kvp_string_tag (acc, "old-price-source", src);
4971 }
gboolean xaccAccountIsPriced(const Account *acc)
Returns true if the account is a stock, mutual fund or currency, otherwise false. ...
Definition: Account.cpp:4637

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

2783 {
2784  AccountPrivate *ppriv, *cpriv;
2785  Account *old_parent;
2786  QofCollection *col;
2787 
2788  /* errors */
2789  g_assert(GNC_IS_ACCOUNT(new_parent));
2790  g_assert(GNC_IS_ACCOUNT(child));
2791 
2792  /* optimizations */
2793  ppriv = GET_PRIVATE(new_parent);
2794  cpriv = GET_PRIVATE(child);
2795  old_parent = cpriv->parent;
2796  if (old_parent == new_parent)
2797  return;
2798 
2799  // xaccAccountBeginEdit(new_parent);
2800  xaccAccountBeginEdit(child);
2801  if (old_parent)
2802  {
2803  gnc_account_remove_child(old_parent, child);
2804 
2805  if (!qof_instance_books_equal(old_parent, new_parent))
2806  {
2807  /* hack alert -- this implementation is not exactly correct.
2808  * If the entity tables are not identical, then the 'from' book
2809  * may have a different backend than the 'to' book. This means
2810  * that we should get the 'from' backend to destroy this account,
2811  * and the 'to' backend to save it. Right now, this is broken.
2812  *
2813  * A 'correct' implementation similar to this is in Period.c
2814  * except its for transactions ...
2815  *
2816  * Note also, we need to reparent the children to the new book as well.
2817  */
2818  PWARN ("reparenting accounts across books is not correctly supported\n");
2819 
2820  qof_event_gen (&child->inst, QOF_EVENT_DESTROY, NULL);
2822  GNC_ID_ACCOUNT);
2823  qof_collection_insert_entity (col, &child->inst);
2824  qof_event_gen (&child->inst, QOF_EVENT_CREATE, NULL);
2825  }
2826  }
2827  cpriv->parent = new_parent;
2828  ppriv->children = g_list_append(ppriv->children, child);
2829  qof_instance_set_dirty(&new_parent->inst);
2830  qof_instance_set_dirty(&child->inst);
2831 
2832  /* Send events data. Warning: The call to commit_edit is also going
2833  * to send a MODIFY event. If the gtktreemodelfilter code gets the
2834  * MODIFY before it gets the ADD, it gets very confused and thinks
2835  * that two nodes have been added. */
2836  qof_event_gen (&child->inst, QOF_EVENT_ADD, NULL);
2837  // qof_event_gen (&new_parent->inst, QOF_EVENT_MODIFY, NULL);
2838 
2839  xaccAccountCommitEdit (child);
2840  // xaccAccountCommitEdit(new_parent);
2841 }
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:250
void gnc_account_remove_child(Account *parent, Account *child)
This function will remove the specified child account from the specified parent account.
Definition: Account.cpp:2844
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:98
gboolean qof_instance_books_equal(gconstpointer ptr1, gconstpointer ptr2)
See if two QofInstances share the same book.
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition: Account.cpp:1430
QofCollection * qof_book_get_collection(const QofBook *book, QofIdType entity_type)
Return The table of entities of the given type.
Definition: qofbook.cpp:604
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition: qofevent.cpp:231
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.cpp:1471

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

2941 {
2942  g_return_val_if_fail(GNC_IS_ACCOUNT(parent), -1);
2943  g_return_val_if_fail(GNC_IS_ACCOUNT(child), -1);
2944  return g_list_index(GET_PRIVATE(parent)->children, child);
2945 }

◆ gnc_account_create_root()

Account* gnc_account_create_root ( QofBook *  book)

Create a new root level account.

Definition at line 1223 of file Account.cpp.

1224 {
1225  Account *root;
1226  AccountPrivate *rpriv;
1227 
1228  root = xaccMallocAccount(book);
1229  rpriv = GET_PRIVATE(root);
1230  xaccAccountBeginEdit(root);
1231  rpriv->type = ACCT_TYPE_ROOT;
1232  rpriv->accountName = qof_string_cache_replace(rpriv->accountName, "Root Account");
1233  mark_account (root);
1234  xaccAccountCommitEdit(root);
1235  gnc_book_set_root_account(book, root);
1236  return root;
1237 }
const char * qof_string_cache_replace(char const *dst, char const *src)
Same as CACHE_REPLACE below, but safe to call from C++.
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition: Account.cpp:1430
Account * xaccMallocAccount(QofBook *book)
Constructor.
Definition: Account.cpp:1209
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.cpp:1471
The hidden root account of an account tree.
Definition: Account.h:156

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

3187 {
3188  const AccountPrivate *priv;
3189  GList *node;
3190 
3191  g_return_if_fail(GNC_IS_ACCOUNT(acc));
3192  g_return_if_fail(thunk);
3193 
3194  priv = GET_PRIVATE(acc);
3195  for (node = priv->children; node; node = node->next)
3196  {
3197  thunk (static_cast<Account*>(node->data), user_data);
3198  }
3199 }

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

3205 {
3206  account_foreach_descendant (acc, thunk, user_data, FALSE);
3207 }

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

3213 {
3214  gpointer result {nullptr};
3215 
3216  g_return_val_if_fail (GNC_IS_ACCOUNT(acc), nullptr);
3217  g_return_val_if_fail (thunk, nullptr);
3218 
3219  auto priv{GET_PRIVATE(acc)};
3220 
3221  for (auto node = priv->children; node; node = node->next)
3222  {
3223  auto child = static_cast<Account*>(node->data);
3224  result = thunk (child, user_data);
3225  if (result) break;
3226 
3227  result = gnc_account_foreach_descendant_until (child, thunk, user_data);
3228  if (result) break;
3229  }
3230 
3231  return result;
3232 }
gpointer gnc_account_foreach_descendant_until(const Account *acc, AccountCb2 thunk, gpointer user_data)
This method will traverse all children of this accounts and their descendants, calling &#39;func&#39; on each...
Definition: Account.cpp:3210

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

2912 {
2913  g_return_val_if_fail(GNC_IS_ACCOUNT(account), NULL);
2914  return g_list_copy(GET_PRIVATE(account)->children);
2915 }

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

2919 {
2920  AccountPrivate *priv;
2921 
2922  /* errors */
2923  g_return_val_if_fail(GNC_IS_ACCOUNT(account), NULL);
2924 
2925  /* optimizations */
2926  priv = GET_PRIVATE(account);
2927  if (!priv->children)
2928  return NULL;
2929  return g_list_sort(g_list_copy(priv->children), (GCompareFunc)xaccAccountOrder);
2930 }
int xaccAccountOrder(const Account *aa, const Account *ab)
The xaccAccountOrder() subroutine defines a sorting order on accounts.
Definition: Account.cpp:2343

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

3413 {
3414  gnc_commodity * commodity;
3415  g_return_val_if_fail (account, NULL);
3416 
3417  commodity = xaccAccountGetCommodity (account);
3418  if (gnc_commodity_is_currency(commodity))
3419  return commodity;
3420  else
3421  {
3422  const Account *parent_account = account;
3423  /* Account commodity is not a currency, walk up the tree until
3424  * we find a parent account that is a currency account and use
3425  * it's currency.
3426  */
3427  do
3428  {
3429  parent_account = gnc_account_get_parent (parent_account);
3430  if (parent_account)
3431  {
3432  commodity = xaccAccountGetCommodity (parent_account);
3433  if (gnc_commodity_is_currency(commodity))
3434  {
3435  return commodity;
3436  //break;
3437  }
3438  }
3439  }
3440  while (parent_account);
3441  }
3442  return NULL; // no suitable commodity found.
3443 }
Account * gnc_account_get_parent(const Account *acc)
This routine returns a pointer to the parent of the specified account.
Definition: Account.cpp:2880
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...
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account&#39;s commodity.
Definition: Account.cpp:3405

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

2971 {
2972  AccountPrivate *priv;
2973  int depth = 0;
2974 
2975  g_return_val_if_fail(GNC_IS_ACCOUNT(account), 0);
2976 
2977  priv = GET_PRIVATE(account);
2978  while (priv->parent && (priv->type != ACCT_TYPE_ROOT))
2979  {
2980  account = priv->parent;
2981  priv = GET_PRIVATE(account);
2982  depth++;
2983  }
2984 
2985  return depth;
2986 }
The hidden root account of an account tree.
Definition: Account.h:156

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

3018 {
3019  GList* list = nullptr;
3020  account_foreach_descendant (account, collect_acct, &list, FALSE);
3021  return g_list_reverse (list);
3022 }

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

3026 {
3027  GList* list = nullptr;
3028  account_foreach_descendant (account, collect_acct, &list, TRUE);
3029  return g_list_reverse (list);
3030 }

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

3266 {
3267  AccountPrivate *priv;
3268  const Account *a;
3269  char *fullname;
3270  const gchar **names;
3271  int level;
3272 
3273  /* So much for hardening the API. Too many callers to this function don't
3274  * bother to check if they have a non-NULL pointer before calling. */
3275  if (NULL == account)
3276  return g_strdup("");
3277 
3278  /* errors */
3279  g_return_val_if_fail(GNC_IS_ACCOUNT(account), g_strdup(""));
3280 
3281  /* optimizations */
3282  priv = GET_PRIVATE(account);
3283  if (!priv->parent)
3284  return g_strdup("");
3285 
3286  /* Figure out how much space is needed by counting the nodes up to
3287  * the root. */
3288  level = 0;
3289  for (a = account; a; a = priv->parent)
3290  {
3291  priv = GET_PRIVATE(a);
3292  level++;
3293  }
3294 
3295  /* Get all the pointers in the right order. The root node "entry"
3296  * becomes the terminating NULL pointer for the array of strings. */
3297  names = (const gchar **)g_malloc(level * sizeof(gchar *));
3298  names[--level] = NULL;
3299  for (a = account; level > 0; a = priv->parent)
3300  {
3301  priv = GET_PRIVATE(a);
3302  names[--level] = priv->accountName;
3303  }
3304 
3305  /* Build the full name */
3306  fullname = g_strjoinv(account_separator, (gchar **)names);
3307  g_free(names);
3308 
3309  return fullname;
3310 }

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

2881 {
2882  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
2883  return GET_PRIVATE(acc)->parent;
2884 }

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

2888 {
2889  AccountPrivate *priv;
2890 
2891  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
2892 
2893  priv = GET_PRIVATE(acc);
2894  while (priv->parent)
2895  {
2896  acc = priv->parent;
2897  priv = GET_PRIVATE(acc);
2898  }
2899 
2900  return acc;
2901 }

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

2990 {
2991  AccountPrivate *priv;
2992  GList *node;
2993  gint depth = 0, child_depth;
2994 
2995  g_return_val_if_fail(GNC_IS_ACCOUNT(account), 0);
2996 
2997  priv = GET_PRIVATE(account);
2998  if (!priv->children)
2999  return 1;
3000 
3001  for (node = priv->children; node; node = g_list_next(node))
3002  {
3003  child_depth = gnc_account_get_tree_depth(static_cast<Account const *>(node->data));
3004  depth = MAX(depth, child_depth);
3005  }
3006  return depth + 1;
3007 }
gint gnc_account_get_tree_depth(const Account *account)
Return the number of levels of descendants accounts below the specified account.
Definition: Account.cpp:2989

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

Definition at line 27 of file gmock-Account.cpp.

28 {
29  return gnc_mockaccount_get_type();
30 }

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

1925 {
1926  AccountPrivate *priv;
1927  GList *node;
1928 
1929  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
1930  g_return_val_if_fail(GNC_IS_SPLIT(s), FALSE);
1931 
1932  priv = GET_PRIVATE(acc);
1933  node = g_list_find(priv->splits, s);
1934  if (node)
1935  return FALSE;
1936 
1937  if (qof_instance_get_editlevel(acc) == 0)
1938  {
1939  priv->splits = g_list_insert_sorted(priv->splits, s,
1940  (GCompareFunc)xaccSplitOrder);
1941  }
1942  else
1943  {
1944  priv->splits = g_list_prepend(priv->splits, s);
1945  priv->sort_dirty = TRUE;
1946  }
1947 
1948  //FIXME: find better event
1949  qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, NULL);
1950  /* Also send an event based on the account */
1951  qof_event_gen(&acc->inst, GNC_EVENT_ITEM_ADDED, s);
1952 
1953  priv->balance_dirty = TRUE;
1954 // DRH: Should the below be added? It is present in the delete path.
1955 // xaccAccountRecomputeBalance(acc);
1956  return TRUE;
1957 }
gint xaccSplitOrder(const Split *sa, const Split *sb)
The xaccSplitOrder(sa,sb) method is useful for sorting.
Definition: Split.c:1500
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition: qofevent.cpp:231
#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 2904 of file Account.cpp.

2905 {
2906  g_return_val_if_fail(GNC_IS_ACCOUNT(account), FALSE);
2907  return (GET_PRIVATE(account)->parent == NULL);
2908 }

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

5127 {
5128  AccountPrivate *from_priv;
5129  GList *children, *node;
5130 
5131  /* errors */
5132  g_return_if_fail(GNC_IS_ACCOUNT(to_parent));
5133  g_return_if_fail(GNC_IS_ACCOUNT(from_parent));
5134 
5135  /* optimizations */
5136  from_priv = GET_PRIVATE(from_parent);
5137  if (!from_priv->children)
5138  return;
5139 
5140  ENTER (" ");
5141  children = g_list_copy(from_priv->children);
5142  for (node = children; node; node = g_list_next(node))
5143  gnc_account_append_child(to_parent, static_cast <Account*> (node->data));
5144  g_list_free(children);
5145  LEAVE (" ");
5146 }
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.cpp:2782
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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_full (value, g_free) when no longer needed.

Definition at line 266 of file Account.cpp.

267 {
268  g_return_val_if_fail (separator != NULL, nullptr);
269  if (!book) return nullptr;
270  ViolationData cb = { nullptr, separator };
271  gnc_account_foreach_descendant (gnc_book_get_root_account (book),
272  (AccountCb)check_acct_name, &cb);
273  return cb.list;
274 }
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 &#39;func&#39; on each...
Definition: Account.cpp:3202

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

5152 {
5153  AccountPrivate *ppriv, *priv_a, *priv_b;
5154  GList *node_a, *node_b, *work, *worker;
5155 
5156  g_return_if_fail(GNC_IS_ACCOUNT(parent));
5157 
5158  ppriv = GET_PRIVATE(parent);
5159  for (node_a = ppriv->children; node_a; node_a = node_a->next)
5160  {
5161  Account *acc_a = static_cast <Account*> (node_a->data);
5162 
5163  priv_a = GET_PRIVATE(acc_a);
5164  for (node_b = node_a->next; node_b; node_b = g_list_next(node_b))
5165  {
5166  Account *acc_b = static_cast <Account*> (node_b->data);
5167 
5168  priv_b = GET_PRIVATE(acc_b);
5169  if (0 != null_strcmp(priv_a->accountName, priv_b->accountName))
5170  continue;
5171  if (0 != null_strcmp(priv_a->accountCode, priv_b->accountCode))
5172  continue;
5173  if (0 != null_strcmp(priv_a->description, priv_b->description))
5174  continue;
5175  if (0 != null_strcmp(xaccAccountGetColor(acc_a),
5176  xaccAccountGetColor(acc_b)))
5177  continue;
5178  if (!gnc_commodity_equiv(priv_a->commodity, priv_b->commodity))
5179  continue;
5180  if (0 != null_strcmp(xaccAccountGetNotes(acc_a),
5181  xaccAccountGetNotes(acc_b)))
5182  continue;
5183  if (priv_a->type != priv_b->type)
5184  continue;
5185 
5186  /* consolidate children */
5187  if (priv_b->children)
5188  {
5189  work = g_list_copy(priv_b->children);
5190  for (worker = work; worker; worker = g_list_next(worker))
5191  gnc_account_append_child (acc_a, (Account *)worker->data);
5192  g_list_free(work);
5193 
5194  qof_event_gen (&acc_a->inst, QOF_EVENT_MODIFY, NULL);
5195  qof_event_gen (&acc_b->inst, QOF_EVENT_MODIFY, NULL);
5196  }
5197 
5198  /* recurse to do the children's children */
5200 
5201  /* consolidate transactions */
5202  while (priv_b->splits)
5203  xaccSplitSetAccount (static_cast <Split*> (priv_b->splits->data), acc_a);
5204 
5205  /* move back one before removal. next iteration around the loop
5206  * will get the node after node_b */
5207  node_b = g_list_previous(node_b);
5208 
5209  /* The destroy function will remove from list -- node_a is ok,
5210  * it's before node_b */
5211  xaccAccountBeginEdit (acc_b);
5212  xaccAccountDestroy (acc_b);
5213  }
5214  }
5215 }
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.cpp:2782
void xaccAccountDestroy(Account *acc)
The xaccAccountDestroy() routine can be used to get rid of an account.
Definition: Account.cpp:1550
const char * xaccAccountGetColor(const Account *acc)
Get the account&#39;s color.
Definition: Account.cpp:3327
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.cpp:1430
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition: qofevent.cpp:231
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.cpp:5151
const char * xaccAccountGetNotes(const Account *acc)
Get the account&#39;s notes.
Definition: Account.cpp:3373

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

2934 {
2935  g_return_val_if_fail(GNC_IS_ACCOUNT(account), 0);
2936  return g_list_length(GET_PRIVATE(account)->children);
2937 }

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

2963 {
2964  int count {0};
2965  account_foreach_descendant (account, count_acct, &count, FALSE);
2966  return count;
2967 }

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

229 {
230  gchar *message = NULL;
231 
232  if ( !invalid_account_names )
233  return NULL;
234 
235  auto account_list {gnc_g_list_stringjoin (invalid_account_names, "\n")};
236 
237  /* Translators: The first %s will be the account separator character,
238  the second %s is a list of account names.
239  The resulting string will be displayed to the user if there are
240  account names containing the separator character. */
241  message = g_strdup_printf(
242  _("The separator character \"%s\" is used in one or more account names.\n\n"
243  "This will result in unexpected behaviour. "
244  "Either change the account names or choose another separator character.\n\n"
245  "Below you will find the list of invalid account names:\n"
246  "%s"), separator, account_list );
247  g_free ( account_list );
248  return message;
249 }
gchar * gnc_g_list_stringjoin(GList *list_of_strings, const gchar *sep)
Return a string joining a GList whose elements are gchar* strings.

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

2949 {
2950  g_return_val_if_fail(GNC_IS_ACCOUNT(parent), NULL);
2951  return static_cast<Account*>(g_list_nth_data(GET_PRIVATE(parent)->children, num));
2952 }

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

2845 {
2846  AccountPrivate *ppriv, *cpriv;
2847  GncEventData ed;
2848 
2849  if (!child) return;
2850 
2851  /* Note this routine might be called on accounts which
2852  * are not yet parented. */
2853  if (!parent) return;
2854 
2855  ppriv = GET_PRIVATE(parent);
2856  cpriv = GET_PRIVATE(child);
2857 
2858  if (cpriv->parent != parent)
2859  {
2860  PERR ("account not a child of parent");
2861  return;
2862  }
2863 
2864  /* Gather event data */
2865  ed.node = parent;
2866  ed.idx = g_list_index(ppriv->children, child);
2867 
2868  ppriv->children = g_list_remove(ppriv->children, child);
2869 
2870  /* Now send the event. */
2871  qof_event_gen(&child->inst, QOF_EVENT_REMOVE, &ed);
2872 
2873  /* clear the account's parent pointer after REMOVE event generation. */
2874  cpriv->parent = NULL;
2875 
2876  qof_event_gen (&parent->inst, QOF_EVENT_MODIFY, NULL);
2877 }
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:244
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition: qofevent.cpp:231

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

1961 {
1962  AccountPrivate *priv;
1963  GList *node;
1964 
1965  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
1966  g_return_val_if_fail(GNC_IS_SPLIT(s), FALSE);
1967 
1968  priv = GET_PRIVATE(acc);
1969  node = g_list_find(priv->splits, s);
1970  if (NULL == node)
1971  return FALSE;
1972 
1973  priv->splits = g_list_delete_link(priv->splits, node);
1974  //FIXME: find better event type
1975  qof_event_gen(&acc->inst, QOF_EVENT_MODIFY, NULL);
1976  // And send the account-based event, too
1977  qof_event_gen(&acc->inst, GNC_EVENT_ITEM_REMOVED, s);
1978 
1979  priv->balance_dirty = TRUE;
1981  return TRUE;
1982 }
void xaccAccountRecomputeBalance(Account *acc)
The following recompute the partial balances (stored with the transaction) and the total balance...
Definition: Account.cpp:2262
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition: qofevent.cpp:231

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

1885 {
1886  AccountPrivate *priv;
1887 
1888  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1889 
1890  if (qof_instance_get_destroying(acc))
1891  return;
1892 
1893  priv = GET_PRIVATE(acc);
1894  priv->balance_dirty = TRUE;
1895 }
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_defer_bal_computation()

void gnc_account_set_defer_bal_computation ( Account acc,
gboolean  defer 
)

Set the defer balance flag.

If defer is true, the account balance is not automatically computed, which can save a lot of time if multiple operations have to be done on the same account. If defer is false, further operations on account will cause the balance to be recomputed as normal.

Parameters
accSet the flag on this account.
deferNew value for the flag.

Definition at line 1897 of file Account.cpp.

1898 {
1899  AccountPrivate *priv;
1900 
1901  g_return_if_fail (GNC_IS_ACCOUNT (acc));
1902 
1903  if (qof_instance_get_destroying (acc))
1904  return;
1905 
1906  priv = GET_PRIVATE (acc);
1907  priv->defer_bal_computation = defer;
1908 }
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 1870 of file Account.cpp.

1871 {
1872  AccountPrivate *priv;
1873 
1874  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1875 
1876  if (qof_instance_get_destroying(acc))
1877  return;
1878 
1879  priv = GET_PRIVATE(acc);
1880  priv->sort_dirty = TRUE;
1881 }
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 3448 of file Account.cpp.

3449 {
3450  AccountPrivate *priv;
3451 
3452  g_return_if_fail(GNC_IS_ACCOUNT(acc));
3453 
3454  priv = GET_PRIVATE(acc);
3455  priv->starting_balance = start_baln;
3456  priv->balance_dirty = TRUE;
3457 }

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

3462 {
3463  AccountPrivate *priv;
3464 
3465  g_return_if_fail(GNC_IS_ACCOUNT(acc));
3466 
3467  priv = GET_PRIVATE(acc);
3468  priv->starting_cleared_balance = start_baln;
3469  priv->balance_dirty = TRUE;
3470 }

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

3475 {
3476  AccountPrivate *priv;
3477 
3478  g_return_if_fail(GNC_IS_ACCOUNT(acc));
3479 
3480  priv = GET_PRIVATE(acc);
3481  priv->starting_reconciled_balance = start_baln;
3482  priv->balance_dirty = TRUE;
3483 }

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

199 {
200  return account_separator;
201 }

◆ xaccAccountBeginEdit()

void xaccAccountBeginEdit ( Account account)

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

Definition at line 1430 of file Account.cpp.

1431 {
1432  g_return_if_fail(acc);
1433  qof_begin_edit(&acc->inst);
1434 }
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 1471 of file Account.cpp.

1472 {
1473  AccountPrivate *priv;
1474  QofBook *book;
1475 
1476  g_return_if_fail(acc);
1477  if (!qof_commit_edit(&acc->inst)) return;
1478 
1479  /* If marked for deletion, get rid of subaccounts first,
1480  * and then the splits ... */
1481  priv = GET_PRIVATE(acc);
1482  if (qof_instance_get_destroying(acc))
1483  {
1484  GList *lp, *slist;
1485  QofCollection *col;
1486 
1487  qof_instance_increase_editlevel(acc);
1488 
1489  /* First, recursively free children */
1490  xaccFreeAccountChildren(acc);
1491 
1492  PINFO ("freeing splits for account %p (%s)",
1493  acc, priv->accountName ? priv->accountName : "(null)");
1494 
1495  book = qof_instance_get_book(acc);
1496 
1497  /* If book is shutting down, just clear the split list. The splits
1498  themselves will be destroyed by the transaction code */
1499  if (!qof_book_shutting_down(book))
1500  {
1501  slist = g_list_copy(priv->splits);
1502  for (lp = slist; lp; lp = lp->next)
1503  {
1504  Split *s = static_cast<Split *>(lp->data);
1505  xaccSplitDestroy (s);
1506  }
1507  g_list_free(slist);
1508  }
1509  else
1510  {
1511  g_list_free(priv->splits);
1512  priv->splits = NULL;
1513  }
1514 
1515  /* It turns out there's a case where this assertion does not hold:
1516  When the user tries to delete an Imbalance account, while also
1517  deleting all the splits in it. The splits will just get
1518  recreated and put right back into the same account!
1519 
1520  g_assert(priv->splits == NULL || qof_book_shutting_down(acc->inst.book));
1521  */
1522 
1523  if (!qof_book_shutting_down(book))
1524  {
1525  col = qof_book_get_collection(book, GNC_ID_TRANS);
1526  qof_collection_foreach(col, destroy_pending_splits_for_account, acc);
1527 
1528  /* the lots should be empty by now */
1529  for (lp = priv->lots; lp; lp = lp->next)
1530  {
1531  GNCLot *lot = static_cast<GNCLot*>(lp->data);
1532  gnc_lot_destroy (lot);
1533  }
1534  }
1535  g_list_free(priv->lots);
1536  priv->lots = NULL;
1537 
1538  qof_instance_set_dirty(&acc->inst);
1539  qof_instance_decrease_editlevel(acc);
1540  }
1541  else
1542  {
1543  xaccAccountBringUpToDate(acc);
1544  }
1545 
1546  qof_commit_edit_part2(&acc->inst, on_err, on_done, acc_free);
1547 }
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.
#define PINFO(format, args...)
Print an informational note.
Definition: qoflog.h:256
gboolean xaccSplitDestroy(Split *split)
Destructor.
Definition: Split.c:1470
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:323
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:604
gboolean qof_book_shutting_down(const QofBook *book)
Is the book shutting down?
Definition: qofbook.cpp:531

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

1551 {
1552  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1553 
1554  qof_instance_set_destroying(acc, TRUE);
1555 
1556  xaccAccountCommitEdit (acc);
1557 }
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.cpp:1471

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

1626 {
1627  AccountPrivate *priv_aa, *priv_ab;
1628 
1629  if (!aa && !ab) return TRUE;
1630 
1631  g_return_val_if_fail(GNC_IS_ACCOUNT(aa), FALSE);
1632  g_return_val_if_fail(GNC_IS_ACCOUNT(ab), FALSE);
1633 
1634  priv_aa = GET_PRIVATE(aa);
1635  priv_ab = GET_PRIVATE(ab);
1636  if (priv_aa->type != priv_ab->type)
1637  {
1638  PWARN ("types differ: %d vs %d", priv_aa->type, priv_ab->type);
1639  return FALSE;
1640  }
1641 
1642  if (g_strcmp0(priv_aa->accountName, priv_ab->accountName) != 0)
1643  {
1644  PWARN ("names differ: %s vs %s", priv_aa->accountName, priv_ab->accountName);
1645  return FALSE;
1646  }
1647 
1648  if (g_strcmp0(priv_aa->accountCode, priv_ab->accountCode) != 0)
1649  {
1650  PWARN ("codes differ: %s vs %s", priv_aa->accountCode, priv_ab->accountCode);
1651  return FALSE;
1652  }
1653 
1654  if (g_strcmp0(priv_aa->description, priv_ab->description) != 0)
1655  {
1656  PWARN ("descriptions differ: %s vs %s", priv_aa->description, priv_ab->description);
1657  return FALSE;
1658  }
1659 
1660  if (!gnc_commodity_equal(priv_aa->commodity, priv_ab->commodity))
1661  {
1662  PWARN ("commodities differ");
1663  return FALSE;
1664  }
1665 
1666  if (check_guids)
1667  {
1668  if (qof_instance_guid_compare(aa, ab) != 0)
1669  {
1670  PWARN ("GUIDs differ");
1671  return FALSE;
1672  }
1673  }
1674 
1675  if (qof_instance_compare_kvp (QOF_INSTANCE (aa), QOF_INSTANCE (ab)) != 0)
1676  {
1677  char *frame_a;
1678  char *frame_b;
1679 
1680  frame_a = qof_instance_kvp_as_string (QOF_INSTANCE (aa));
1681  frame_b = qof_instance_kvp_as_string (QOF_INSTANCE (ab));
1682 
1683  PWARN ("kvp frames differ:\n%s\n\nvs\n\n%s", frame_a, frame_b);
1684 
1685  g_free (frame_a);
1686  g_free (frame_b);
1687 
1688  return FALSE;
1689  }
1690 
1691  if (!gnc_numeric_equal(priv_aa->starting_balance, priv_ab->starting_balance))
1692  {
1693  char *str_a;
1694  char *str_b;
1695 
1696  str_a = gnc_numeric_to_string(priv_aa->starting_balance);
1697  str_b = gnc_numeric_to_string(priv_ab->starting_balance);
1698 
1699  PWARN ("starting balances differ: %s vs %s", str_a, str_b);
1700 
1701  g_free (str_a);
1702  g_free (str_b);
1703 
1704  return FALSE;
1705  }
1706 
1707  if (!gnc_numeric_equal(priv_aa->starting_noclosing_balance,
1708  priv_ab->starting_noclosing_balance))
1709  {
1710  char *str_a;
1711  char *str_b;
1712 
1713  str_a = gnc_numeric_to_string(priv_aa->starting_noclosing_balance);
1714  str_b = gnc_numeric_to_string(priv_ab->starting_noclosing_balance);
1715 
1716  PWARN ("starting noclosing balances differ: %s vs %s", str_a, str_b);
1717 
1718  g_free (str_a);
1719  g_free (str_b);
1720 
1721  return FALSE;
1722  }
1723  if (!gnc_numeric_equal(priv_aa->starting_cleared_balance,
1724  priv_ab->starting_cleared_balance))
1725  {
1726  char *str_a;
1727  char *str_b;
1728 
1729  str_a = gnc_numeric_to_string(priv_aa->starting_cleared_balance);
1730  str_b = gnc_numeric_to_string(priv_ab->starting_cleared_balance);
1731 
1732  PWARN ("starting cleared balances differ: %s vs %s", str_a, str_b);
1733 
1734  g_free (str_a);
1735  g_free (str_b);
1736 
1737  return FALSE;
1738  }
1739 
1740  if (!gnc_numeric_equal(priv_aa->starting_reconciled_balance,
1741  priv_ab->starting_reconciled_balance))
1742  {
1743  char *str_a;
1744  char *str_b;
1745 
1746  str_a = gnc_numeric_to_string(priv_aa->starting_reconciled_balance);
1747  str_b = gnc_numeric_to_string(priv_ab->starting_reconciled_balance);
1748 
1749  PWARN ("starting reconciled balances differ: %s vs %s", str_a, str_b);
1750 
1751  g_free (str_a);
1752  g_free (str_b);
1753 
1754  return FALSE;
1755  }
1756 
1757  if (!gnc_numeric_equal(priv_aa->balance, priv_ab->balance))
1758  {
1759  char *str_a;
1760  char *str_b;
1761 
1762  str_a = gnc_numeric_to_string(priv_aa->balance);
1763  str_b = gnc_numeric_to_string(priv_ab->balance);
1764 
1765  PWARN ("balances differ: %s vs %s", str_a, str_b);
1766 
1767  g_free (str_a);
1768  g_free (str_b);
1769 
1770  return FALSE;
1771  }
1772 
1773  if (!gnc_numeric_equal(priv_aa->noclosing_balance, priv_ab->noclosing_balance))
1774  {
1775  char *str_a;
1776  char *str_b;
1777 
1778  str_a = gnc_numeric_to_string(priv_aa->noclosing_balance);
1779  str_b = gnc_numeric_to_string(priv_ab->noclosing_balance);
1780 
1781  PWARN ("noclosing balances differ: %s vs %s", str_a, str_b);
1782 
1783  g_free (str_a);
1784  g_free (str_b);
1785 
1786  return FALSE;
1787  }
1788  if (!gnc_numeric_equal(priv_aa->cleared_balance, priv_ab->cleared_balance))
1789  {
1790  char *str_a;
1791  char *str_b;
1792 
1793  str_a = gnc_numeric_to_string(priv_aa->cleared_balance);
1794  str_b = gnc_numeric_to_string(priv_ab->cleared_balance);
1795 
1796  PWARN ("cleared balances differ: %s vs %s", str_a, str_b);
1797 
1798  g_free (str_a);
1799  g_free (str_b);
1800 
1801  return FALSE;
1802  }
1803 
1804  if (!gnc_numeric_equal(priv_aa->reconciled_balance, priv_ab->reconciled_balance))
1805  {
1806  char *str_a;
1807  char *str_b;
1808 
1809  str_a = gnc_numeric_to_string(priv_aa->reconciled_balance);
1810  str_b = gnc_numeric_to_string(priv_ab->reconciled_balance);
1811 
1812  PWARN ("reconciled balances differ: %s vs %s", str_a, str_b);
1813 
1814  g_free (str_a);
1815  g_free (str_b);
1816 
1817  return FALSE;
1818  }
1819 
1820  /* no parent; always compare downwards. */
1821 
1822  {
1823  GList *la = priv_aa->splits;
1824  GList *lb = priv_ab->splits;
1825 
1826  if ((la && !lb) || (!la && lb))
1827  {
1828  PWARN ("only one has splits");
1829  return FALSE;
1830  }
1831 
1832  if (la && lb)
1833  {
1834  /* presume that the splits are in the same order */
1835  while (la && lb)
1836  {
1837  Split *sa = (Split *) la->data;
1838  Split *sb = (Split *) lb->data;
1839 
1840  if (!xaccSplitEqual(sa, sb, check_guids, TRUE, FALSE))
1841  {
1842  PWARN ("splits differ");
1843  return(FALSE);
1844  }
1845 
1846  la = la->next;
1847  lb = lb->next;
1848  }
1849 
1850  if ((la != NULL) || (lb != NULL))
1851  {
1852  PWARN ("number of splits differs");
1853  return(FALSE);
1854  }
1855  }
1856  }
1857 
1858  if (!xaccAcctChildrenEqual(priv_aa->children, priv_ab->children, check_guids))
1859  {
1860  PWARN ("children differ");
1861  return FALSE;
1862  }
1863 
1864  return(TRUE);
1865 }
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:769
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:250
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 4925 of file Account.cpp.

4926 {
4927  GValue v = G_VALUE_INIT;
4928  std::vector<std::string> path {KEY_LOT_MGMT, "gains-acct",
4930  GncGUID *guid = NULL;
4931  Account *gains_account;
4932 
4933  g_return_val_if_fail (acc != NULL, NULL);
4934  qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, path);
4935  if (G_VALUE_HOLDS_BOXED (&v))
4936  guid = (GncGUID*)g_value_get_boxed (&v);
4937  if (guid == NULL) /* No gains account for this currency */
4938  {
4939  gains_account = GetOrMakeOrphanAccount (gnc_account_get_root (acc),
4940  curr);
4941  guid = (GncGUID*)qof_instance_get_guid (QOF_INSTANCE (gains_account));
4942  xaccAccountBeginEdit (acc);
4943  {
4944  GValue vr = G_VALUE_INIT;
4945  g_value_init (&vr, GNC_TYPE_GUID);
4946  g_value_set_boxed (&vr, guid);
4947  qof_instance_set_path_kvp (QOF_INSTANCE (acc), &vr, path);
4948  qof_instance_set_dirty (QOF_INSTANCE (acc));
4949  g_value_unset (&vr);
4950  }
4951  xaccAccountCommitEdit (acc);
4952  }
4953  else
4954  gains_account = xaccAccountLookup (guid,
4955  qof_instance_get_book(acc));
4956 
4957  g_value_unset (&v);
4958  return gains_account;
4959 }
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.
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition: Account.cpp:1430
const char * gnc_commodity_get_unique_name(const gnc_commodity *cm)
Retrieve the &#39;unique&#39; name for the specified commodity.
Account * gnc_account_get_root(Account *acc)
This routine returns the root account of the account tree that the specified account belongs to...
Definition: Account.cpp:2887
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.cpp:1471
Account * xaccAccountLookup(const GncGUID *guid, QofBook *book)
The xaccAccountLookup() subroutine will return the account associated with the given id...
Definition: Account.cpp:2031

◆ xaccAccountGetBalanceAsOfDate()

gnc_numeric xaccAccountGetBalanceAsOfDate ( Account account,
time64  date 
)

Get the balance of the account at the end of the day before the date specified.

Definition at line 3577 of file Account.cpp.

3578 {
3579  return GetBalanceAsOfDate (acc, date, FALSE);
3580 }

◆ xaccAccountGetBalanceAsOfDateInCurrency()

gnc_numeric xaccAccountGetBalanceAsOfDateInCurrency ( Account account,
time64  date,
gnc_commodity *  report_commodity,
gboolean  include_children 
)

This function gets the balance at the end of the given date in the desired commodity.

Definition at line 3907 of file Account.cpp.

3910 {
3911  return xaccAccountGetXxxBalanceAsOfDateInCurrencyRecursive (
3912  acc, date, xaccAccountGetBalanceAsOfDate, report_commodity,
3913  include_children);
3914 }
gnc_numeric xaccAccountGetBalanceAsOfDate(Account *acc, time64 date)
Get the balance of the account at the end of the day before the date specified.
Definition: Account.cpp:3577

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

2683 {
2684  AccountPrivate *priv;
2685 
2686  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), 0);
2687 
2688  priv = GET_PRIVATE(acc);
2689  if (priv->non_standard_scu || !priv->commodity)
2690  return priv->commodity_scu;
2691  return gnc_commodity_get_fraction(priv->commodity);
2692 }
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 2675 of file Account.cpp.

2676 {
2677  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), 0);
2678  return GET_PRIVATE(acc)->commodity_scu;
2679 }

◆ xaccAccountGetNoclosingBalanceAsOfDateInCurrency()

gnc_numeric xaccAccountGetNoclosingBalanceAsOfDateInCurrency ( Account acc,
time64  date,
gnc_commodity *  report_commodity,
gboolean  include_children 
)

This function gets the balance at the end of the given date, ignoring closing entries, in the desired commodity.

Definition at line 3917 of file Account.cpp.

3920 {
3921  return xaccAccountGetXxxBalanceAsOfDateInCurrencyRecursive
3922  (acc, date, xaccAccountGetNoclosingBalanceAsOfDate,
3923  report_commodity, include_children);
3924 }

◆ xaccAccountGetNonStdSCU()

gboolean xaccAccountGetNonStdSCU ( const Account account)

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

Definition at line 2711 of file Account.cpp.

2712 {
2713  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), 0);
2714  return GET_PRIVATE(acc)->non_standard_scu;
2715 }

◆ xaccAccountGetReconciledBalanceAsOfDate()

gnc_numeric xaccAccountGetReconciledBalanceAsOfDate ( Account account,
time64  date 
)

Get the reconciled balance of the account at the end of the day of the date specified.

Definition at line 3589 of file Account.cpp.

3590 {
3591  gnc_numeric balance = gnc_numeric_zero();
3592 
3593  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), gnc_numeric_zero());
3594 
3595  for (GList *node = GET_PRIVATE(acc)->splits; node; node = node->next)
3596  {
3597  Split *split = (Split*) node->data;
3598  if ((xaccSplitGetReconcile (split) == YREC) &&
3599  (xaccSplitGetDateReconciled (split) <= date))
3600  balance = gnc_numeric_add_fixed (balance, xaccSplitGetAmount (split));
3601  };
3602 
3603  return balance;
3604 }
char xaccSplitGetReconcile(const Split *split)
Returns the value of the reconcile flag.
#define YREC
The Split has been reconciled.
Definition: Split.h:72
time64 xaccSplitGetDateReconciled(const Split *split)
Retrieve the date when the Split was reconciled.
Definition: Split.c:1820
gnc_numeric xaccSplitGetAmount(const Split *split)
Returns the amount of the split in the account&#39;s commodity.
Definition: gmock-Split.cpp:69

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

3237 {
3238  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), ACCT_TYPE_NONE);
3239  return GET_PRIVATE(acc)->type;
3240 }
Not a type.
Definition: Account.h:108

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

4311 {
4312  const Account *parent;
4313 
4314  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
4315  g_return_val_if_fail(GNC_IS_ACCOUNT(ancestor), FALSE);
4316 
4317  parent = acc;
4318  while (parent && parent != ancestor)
4319  parent = GET_PRIVATE(parent)->parent;
4320 
4321  return (parent == ancestor);
4322 }

◆ xaccAccountIsPriced()

gboolean xaccAccountIsPriced ( const Account acc)

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

Definition at line 4637 of file Account.cpp.

4638 {
4639  AccountPrivate *priv;
4640 
4641  g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
4642 
4643  priv = GET_PRIVATE(acc);
4644  return (priv->type == ACCT_TYPE_STOCK || priv->type == ACCT_TYPE_MUTUAL ||
4645  priv->type == ACCT_TYPE_CURRENCY);
4646 }
Mutual Fund accounts will typically be shown in registers which show three columns: price...
Definition: Account.h:128
Stock accounts will typically be shown in registers which show three columns: price, number of shares, and value.
Definition: Account.h:125
The currency account type indicates that the account is a currency trading account.
Definition: Account.h:132

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

2032 {
2033  QofCollection *col;
2034  if (!guid || !book) return NULL;
2035  col = qof_book_get_collection (book, GNC_ID_ACCOUNT);
2036  return (Account *) qof_collection_lookup_entity (col, guid);
2037 }
QofInstance * qof_collection_lookup_entity(const QofCollection *col, const GncGUID *guid)
Find the entity going only from its guid.
Definition: qofid.cpp:215
QofCollection * qof_book_get_collection(const QofBook *book, QofIdType entity_type)
Return The table of entities of the given type.
Definition: qofbook.cpp:604

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

2344 {
2345  AccountPrivate *priv_aa, *priv_ab;
2346  const char *da, *db;
2347  char *endptr = NULL;
2348  int ta, tb, result;
2349  long la, lb;
2350 
2351  if ( aa && !ab ) return -1;
2352  if ( !aa && ab ) return +1;
2353  if ( !aa && !ab ) return 0;
2354 
2355  priv_aa = GET_PRIVATE(aa);
2356  priv_ab = GET_PRIVATE(ab);
2357 
2358  /* sort on accountCode strings */
2359  da = priv_aa->accountCode;
2360  db = priv_ab->accountCode;
2361 
2362  /* Otherwise do a string sort */
2363  result = g_strcmp0 (da, db);
2364  if (result)
2365  return result;
2366 
2367  /* if account-type-order array not initialized, initialize it */
2368  /* this will happen at most once during program invocation */
2369  if (-1 == revorder[0])
2370  {
2371  int i;
2372  for (i = 0; i < NUM_ACCOUNT_TYPES; i++)
2373  {
2374  revorder [typeorder[i]] = i;
2375  }
2376  }
2377 
2378  /* otherwise, sort on account type */
2379  ta = priv_aa->type;
2380  tb = priv_ab->type;
2381  ta = revorder[ta];
2382  tb = revorder[tb];
2383  if (ta < tb) return -1;
2384  if (ta > tb) return +1;
2385 
2386  /* otherwise, sort on accountName strings */
2387  da = priv_aa->accountName;
2388  db = priv_ab->accountName;
2389  result = safe_utf8_collate(da, db);
2390  if (result)
2391  return result;
2392 
2393  /* guarantee a stable sort */
2394  return qof_instance_guid_compare(aa, ab);
2395 }
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:164
gint qof_instance_guid_compare(gconstpointer ptr1, gconstpointer ptr2)
Compare the GncGUID values of two instances.

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

2660 {
2661  AccountPrivate *priv;
2662 
2663  g_return_if_fail(GNC_IS_ACCOUNT(acc));
2664 
2665  priv = GET_PRIVATE(acc);
2666  xaccAccountBeginEdit(acc);
2667  priv->commodity_scu = scu;
2668  if (scu != gnc_commodity_get_fraction(priv->commodity))
2669  priv->non_standard_scu = TRUE;
2670  mark_account(acc);
2671  xaccAccountCommitEdit(acc);
2672 }
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.cpp:1430
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.cpp:1471

◆ xaccAccountSetNonStdSCU()

void xaccAccountSetNonStdSCU ( Account account,
gboolean  flag 
)

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

Definition at line 2695 of file Account.cpp.

2696 {
2697  AccountPrivate *priv;
2698 
2699  g_return_if_fail(GNC_IS_ACCOUNT(acc));
2700 
2701  priv = GET_PRIVATE(acc);
2702  if (priv->non_standard_scu == flag)
2703  return;
2704  xaccAccountBeginEdit(acc);
2705  priv->non_standard_scu = flag;
2706  mark_account (acc);
2707  xaccAccountCommitEdit(acc);
2708 }
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition: Account.cpp:1430
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.cpp:1471

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

1986 {
1987  AccountPrivate *priv;
1988 
1989  g_return_if_fail(GNC_IS_ACCOUNT(acc));
1990 
1991  priv = GET_PRIVATE(acc);
1992  if (!priv->sort_dirty || (!force && qof_instance_get_editlevel(acc) > 0))
1993  return;
1994  priv->splits = g_list_sort(priv->splits, (GCompareFunc)xaccSplitOrder);
1995  priv->sort_dirty = FALSE;
1996  priv->balance_dirty = TRUE;
1997 }
gint xaccSplitOrder(const Split *sa, const Split *sb)
The xaccSplitOrder(sa,sb) method is useful for sorting.
Definition: Split.c:1500

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

1241 {
1242  Account *ret;
1243  AccountPrivate *from_priv, *priv;
1244 
1245  g_return_val_if_fail(GNC_IS_ACCOUNT(from), NULL);
1246  g_return_val_if_fail(QOF_IS_BOOK(book), NULL);
1247 
1248  ENTER (" ");
1249  ret = static_cast<Account*>(g_object_new (GNC_TYPE_ACCOUNT, NULL));
1250  g_return_val_if_fail (ret, NULL);
1251 
1252  from_priv = GET_PRIVATE(from);
1253  priv = GET_PRIVATE(ret);
1254  xaccInitAccount (ret, book);
1255 
1256  /* Do not Begin/CommitEdit() here; give the caller
1257  * a chance to fix things up, and let them do it.
1258  * Also let caller issue the generate_event (EVENT_CREATE) */
1259  priv->type = from_priv->type;
1260 
1261  priv->accountName = qof_string_cache_replace(priv->accountName, from_priv->accountName);
1262  priv->accountCode = qof_string_cache_replace(priv->accountCode, from_priv->accountCode);
1263  priv->description = qof_string_cache_replace(priv->description, from_priv->description);
1264 
1265  qof_instance_copy_kvp (QOF_INSTANCE (ret), QOF_INSTANCE (from));
1266 
1267  /* The new book should contain a commodity that matches
1268  * the one in the old book. Find it, use it. */
1269  priv->commodity = gnc_commodity_obtain_twin(from_priv->commodity, book);
1270  gnc_commodity_increment_usage_count(priv->commodity);
1271 
1272  priv->commodity_scu = from_priv->commodity_scu;
1273  priv->non_standard_scu = from_priv->non_standard_scu;
1274 
1275  qof_instance_set_dirty(&ret->inst);
1276  LEAVE (" ");
1277  return ret;
1278 }
const char * qof_string_cache_replace(char const *dst, char const *src)
Same as CACHE_REPLACE below, but safe to call from C++.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
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:282
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...