GnuCash
5.6-150-g038405b370+
|
Splits are grouped into Accounts which are also known as "Ledgers" in accounting practice. More...
Files | |
file | Account.h |
Account handling public routines. | |
file | Account.hpp |
Account public routines (C++ api) | |
Data Structures | |
struct | AccountClass |
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) |
using | SplitsVec = std::vector< Split * > |
using | AccountVec = std::vector< Account * > |
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... | |
const SplitsVec & | xaccAccountGetSplits (const Account *) |
void | gnc_account_foreach_descendant (const Account *, std::function< void(Account *)> func) |
void | gnc_account_foreach_split (const Account *, std::function< void(Split *)>, bool) |
void | gnc_account_foreach_split_until_date (const Account *acc, time64 end_date, std::function< void(Split *)> f) |
Split * | gnc_account_find_split (const Account *, std::function< bool(const Split *)>, bool) |
scans account split list (in forward or reverse order) until predicate split->bool returns true. More... | |
Account Constructors, Edit/Commit, Comparison | |
Account * | xaccMallocAccount (QofBook *book) |
Constructor. | |
Account * | gnc_account_create_root (QofBook *book) |
Create a new root level account. More... | |
Account * | xaccCloneAccount (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) |
Account * | gnc_book_get_root_account (QofBook *book) |
void | gnc_book_set_root_account (QofBook *book, Account *root) |
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. 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 | xaccAccountSetAssociatedAccount (Account *acc, const char *tag, const Account *assoc_acct) |
Set the account's associated account e.g. More... | |
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. | |
Account * | xaccAccountGetAssociatedAccount (const Account *acc, const char *tag) |
Get the account's associated account e.g. More... | |
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... | |
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. 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 | xaccAccountGetNoclosingBalanceChangeInCurrencyForPeriod (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... | |
Account * | gnc_account_get_parent (const Account *account) |
This routine returns a pointer to the parent of the specified account. More... | |
Account * | gnc_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... | |
Account * | gnc_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... | |
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.
#define xaccAccountGetGUID | ( | X | ) | qof_entity_get_guid(QOF_INSTANCE(X)) |
enum 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.
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 101 of file Account.h.
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*.
Definition at line 4786 of file Account.cpp.
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
Definition at line 4774 of file Account.cpp.
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).
new_parent | The new parent account to which the child should be attached. |
child | The account to attach. |
Definition at line 2787 of file Account.cpp.
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.
parent | The parent account to check. |
child | The child account to find. |
Definition at line 2934 of file Account.cpp.
Account* gnc_account_create_root | ( | QofBook * | book | ) |
Create a new root level account.
Definition at line 1285 of file Account.cpp.
Split* gnc_account_find_split | ( | const Account * | , |
std::function< bool(const Split *)> | , | ||
bool | |||
) |
scans account split list (in forward or reverse order) until predicate split->bool returns true.
Maybe return the split.
acc | The account to which the split should be added. |
predicate | A split->bool predicate. |
reverse | To scan in reverse order |
Definition at line 1168 of file Account.cpp.
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.
account | A pointer to the account on whose children the function should be called. |
func | A function taking two arguments, an Account and a gpointer. |
user_data | This data will be passed to each call of func. |
Definition at line 3175 of file Account.cpp.
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.
account | A pointer to the account on whose descendants the function should be called. |
func | A function taking two arguments, an Account and a gpointer. |
user_data | This data will be passed to each call of func. |
Definition at line 3186 of file Account.cpp.
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.
account | A pointer to the account on whose descendants the function should be called. |
func | A function taking two arguments, an Account and a gpointer. |
user_data | This data will be passed to each call of func. |
Definition at line 3194 of file Account.cpp.
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.
account | The account whose children should be returned. |
Definition at line 2911 of file Account.cpp.
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().
Definition at line 2920 of file Account.cpp.
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 3366 of file Account.cpp.
gint gnc_account_get_current_depth | ( | const Account * | account | ) |
Return the number of levels of this account below the root account.
account | The account to query. |
Definition at line 2960 of file Account.cpp.
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.
account | The account whose descendants should be returned. |
Definition at line 2994 of file Account.cpp.
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.
account | The account whose descendants should be returned. |
Definition at line 3002 of file Account.cpp.
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.
Definition at line 3246 of file Account.cpp.
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.
account | A pointer to any exiting account. |
Definition at line 2886 of file Account.cpp.
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.
account | A pointer to any existing account. |
Definition at line 2893 of file Account.cpp.
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.
account | The account to query. |
Definition at line 2979 of file Account.cpp.
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.
gboolean gnc_account_insert_split | ( | Account * | acc, |
Split * | s | ||
) |
Insert the given split from an account.
acc | The account to which the split should be added. |
s | The split to be added. |
Definition at line 1925 of file Account.cpp.
gboolean gnc_account_is_root | ( | const Account * | account | ) |
This routine indicates whether the specified account is the root node of an account tree.
account | A pointer to any account. |
Definition at line 2904 of file Account.cpp.
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 4873 of file Account.cpp.
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.
book | Pointer to the book with accounts to verify |
separator | The separator character to verify against |
Definition at line 271 of file Account.cpp.
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 4895 of file Account.cpp.
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.
account | The account to query. |
Definition at line 2927 of file Account.cpp.
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.
account | The account to query. |
Definition at line 2952 of file Account.cpp.
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
separator | The separator character that was verified against |
invalid_account_names | A GList of invalid account names. |
Definition at line 233 of file Account.cpp.
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.
parent | The parent account to check. |
num | The index number of the child account that should be returned. |
Definition at line 2943 of file Account.cpp.
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.
parent | The parent account from which the child should be removed. |
child | The child account to remove. |
Definition at line 2849 of file Account.cpp.
gboolean gnc_account_remove_split | ( | Account * | acc, |
Split * | s | ||
) |
Remove the given split from an account.
acc | The account from which the split should be removed. |
s | The split to be removed. |
Definition at line 1955 of file Account.cpp.
void gnc_account_set_balance_dirty | ( | Account * | acc | ) |
Tell the account that the running balances may be incorrect and need to be recomputed.
acc | Set the flag on this account. |
Definition at line 1880 of file Account.cpp.
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.
acc | Set the flag on this account. |
defer | New value for the flag. |
Definition at line 1893 of file Account.cpp.
void gnc_account_set_sort_dirty | ( | Account * | acc | ) |
Tell the account believes that the splits may be incorrectly sorted and need to be resorted.
acc | Set the flag on this account. |
Definition at line 1866 of file Account.cpp.
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 3380 of file Account.cpp.
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 3392 of file Account.cpp.
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 3405 of file Account.cpp.
const gchar* gnc_get_account_separator_string | ( | void | ) |
Returns the account separation character chosen by the user.
Definition at line 203 of file Account.cpp.
void xaccAccountBeginEdit | ( | Account * | account | ) |
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account updates.
Definition at line 1475 of file Account.cpp.
void xaccAccountCommitEdit | ( | Account * | account | ) |
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account updates.
Definition at line 1516 of file Account.cpp.
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 1590 of file Account.cpp.
Compare two accounts for equality - this is a deep compare.
Definition at line 1648 of file Account.cpp.
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 4756 of file Account.cpp.
Get the account's associated account e.g.
stock account -> dividend account
Definition at line 3338 of file Account.cpp.
Get the balance of the account at the end of the day before the date specified.
Definition at line 3477 of file Account.cpp.
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 3795 of file Account.cpp.
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 2696 of file Account.cpp.
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 2689 of file Account.cpp.
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 3805 of file Account.cpp.
gboolean xaccAccountGetNonStdSCU | ( | const Account * | account | ) |
Return boolean, indicating whether this account uses a non-standard SCU.
Definition at line 2725 of file Account.cpp.
Get the reconciled balance of the account at the end of the day of the date specified.
Definition at line 3489 of file Account.cpp.
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 3217 of file Account.cpp.
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 4163 of file Account.cpp.
gboolean xaccAccountIsPriced | ( | const Account * | acc | ) |
Returns true if the account is a stock, mutual fund or currency, otherwise false.
Definition at line 4490 of file Account.cpp.
The xaccAccountLookup() subroutine will return the account associated with the given id, or NULL if there is no such account.
Definition at line 2032 of file Account.cpp.
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 2340 of file Account.cpp.
void xaccAccountSetAssociatedAccount | ( | Account * | acc, |
const char * | tag, | ||
const Account * | assoc_acct | ||
) |
Set the account's associated account e.g.
stock account -> dividend account
Definition at line 2620 of file Account.cpp.
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 2673 of file Account.cpp.
void xaccAccountSetNonStdSCU | ( | Account * | account, |
gboolean | flag | ||
) |
Set the flag indicating that this account uses a non-standard SCU.
Definition at line 2709 of file Account.cpp.
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 1986 of file Account.cpp.
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 1302 of file Account.cpp.