Definition in file Account.h.
#include "qof.h"
#include "gnc-engine.h"
#include "policy.h"
Go to the source code of this file.
Data Structures | |
| struct | AccountClass |
Account lookup and GUID routines | |
| #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) |
| const gchar * | gnc_get_account_separator_string (void) |
| 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 GUID *guid, QofBook *book) |
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. | |
| #define | DxaccAccountSetSecurity xaccAccountSetCommodity |
| #define | DxaccAccountGetSecurity xaccAccountGetCommodity |
| #define | xaccAccountSetCommoditySCUandFlag xaccAccountSetCommoditySCU |
| void | xaccAccountSetCommodity (Account *account, gnc_commodity *comm) |
| gnc_commodity * | xaccAccountGetCommodity (const Account *account) |
| int | xaccAccountGetCommoditySCU (const Account *account) |
| int | xaccAccountGetCommoditySCUi (const Account *account) |
| void | xaccAccountSetCommoditySCU (Account *account, int frac) |
| void | xaccAccountSetNonStdSCU (Account *account, gboolean flag) |
| gboolean | xaccAccountGetNonStdSCU (const Account *account) |
Account split/transaction list management | |
| #define | xaccAccountInsertSplit(acc, s) xaccSplitSetAccount((s), (acc)) |
| SplitList * | xaccAccountGetSplitList (const Account *account) |
| void | xaccAccountMoveAllSplits (Account *accfrom, Account *accto) |
| gint | xaccAccountForEachTransaction (const Account *account, TransactionCallback proc, void *data) |
| Transaction * | xaccAccountFindTransByDesc (const Account *account, const char *description) |
| Split * | xaccAccountFindSplitByDesc (const Account *account, const char *description) |
Defines | |
| #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)) |
| #define | xaccAccountGetSlots(X) qof_instance_get_slots(QOF_INSTANCE(X)) |
| #define | ACCOUNT_MATCH_ALL_TYPE "account-match-all" |
Account parameter names | |
| #define | ACCOUNT_KVP "kvp" |
| #define | ACCOUNT_NAME_ "name" |
| #define | ACCOUNT_CODE_ "code" |
| #define | ACCOUNT_DESCRIPTION_ "desc" |
| #define | ACCOUNT_NOTES_ "notes" |
| #define | ACCOUNT_BALANCE_ "balance" |
| #define | ACCOUNT_CLEARED_ "cleared" |
| #define | ACCOUNT_RECONCILED_ "reconciled" |
| #define | ACCOUNT_PRESENT_ "present" |
| #define | ACCOUNT_FUTURE_MINIMUM_ "future-minimum" |
| #define | ACCOUNT_TAX_RELATED "tax-related-p" |
| #define | ACCOUNT_TYPE_ "account-type" |
| #define | ACCOUNT_SCU "smallest-commodity-unit" |
| #define | ACCOUNT_NSCU "non-standard-scu" |
| #define | ACCOUNT_PARENT "parent-account" |
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, time_t 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, NUM_ACCOUNT_TYPES = 14, ACCT_TYPE_CHECKING = 14, ACCT_TYPE_SAVINGS = 15, ACCT_TYPE_MONEYMRKT = 16, ACCT_TYPE_CREDITLINE = 17 } |
| enum | GNCPlaceholderType { PLACEHOLDER_NONE, PLACEHOLDER_THIS, PLACEHOLDER_CHILD } |
Functions | |
| GType | gnc_account_get_type (void) |
| void | xaccAccountSetReconcileChildrenStatus (Account *account, gboolean status) |
| gboolean | xaccAccountGetReconcileChildrenStatus (const Account *account) |
| gboolean | xaccAccountHasAncestor (const Account *acc, const Account *ancestor) |
Account Constructors, Edit/Commit, Comparison | |
| Account * | xaccMallocAccount (QofBook *book) |
| Account * | gnc_account_create_root (QofBook *book) |
| Account * | xaccCloneAccount (const Account *from, QofBook *book) |
| Account * | xaccCloneAccountSimple (const Account *from, QofBook *book) |
| void | xaccAccountBeginEdit (Account *account) |
| void | xaccAccountCommitEdit (Account *account) |
| void | xaccAccountDestroy (Account *account) |
| gboolean | xaccAccountEqual (const Account *a, const Account *b, gboolean check_guids) |
| int | xaccAccountOrder (const Account *account_1, const Account *account_2) |
Account general setters/getters | |
| QofBook * | gnc_account_get_book (const Account *account) |
| void | xaccAccountSetType (Account *account, GNCAccountType) |
| void | xaccAccountSetName (Account *account, const char *name) |
| void | xaccAccountSetCode (Account *account, const char *code) |
| void | xaccAccountSetDescription (Account *account, const char *desc) |
| void | xaccAccountSetNotes (Account *account, const char *notes) |
| void | xaccAccountSetLastNum (Account *account, const char *num) |
| void | gnc_account_set_policy (Account *account, GNCPolicy *policy) |
| GNCAccountType | xaccAccountGetType (const Account *account) |
| gboolean | xaccAccountIsPriced (const Account *acc) |
| void | gnc_account_set_start_balance (Account *acc, const gnc_numeric start_baln) |
| void | gnc_account_set_start_cleared_balance (Account *acc, const gnc_numeric start_baln) |
| void | gnc_account_set_start_reconciled_balance (Account *acc, const gnc_numeric start_baln) |
| void | gnc_account_set_balance_dirty (Account *acc) |
| void | gnc_account_set_sort_dirty (Account *acc) |
| gboolean | gnc_account_find_split (Account *acc, Split *s) |
| gboolean | gnc_account_insert_split (Account *acc, Split *s) |
| gboolean | gnc_account_remove_split (Account *acc, Split *s) |
| const char * | xaccAccountGetName (const Account *account) |
| const char * | xaccAccountGetCode (const Account *account) |
| const char * | xaccAccountGetDescription (const Account *account) |
| const char * | xaccAccountGetNotes (const Account *account) |
| const char * | xaccAccountGetLastNum (const Account *account) |
| GNCPolicy * | gnc_account_get_policy (Account *account) |
| gnc_numeric | gnc_account_get_start_balance (Account *acc) |
| gnc_numeric | gnc_account_get_start_cleared_balance (Account *acc) |
| gnc_numeric | gnc_account_get_start_reconciled_balance (Account *acc) |
| gboolean | gnc_account_get_balance_dirty (Account *acc) |
| gboolean | gnc_account_get_sort_dirty (Account *acc) |
| void | xaccAccountRecomputeBalance (Account *) |
| void | xaccAccountSortSplits (Account *acc, gboolean force) |
| char * | xaccAccountGetFullName (const Account *account) |
| void | dxaccAccountSetPriceSrc (Account *account, const char *src) |
| const char * | dxaccAccountGetPriceSrc (const Account *account) |
| gboolean | xaccAccountGetAutoInterestXfer (const Account *account, gboolean default_value) |
| void | xaccAccountSetAutoInterestXfer (Account *account, gboolean value) |
Account Balance | |
| gnc_numeric | xaccAccountGetBalance (const Account *account) |
| gnc_numeric | xaccAccountGetClearedBalance (const Account *account) |
| gnc_numeric | xaccAccountGetReconciledBalance (const Account *account) |
| gnc_numeric | xaccAccountGetPresentBalance (const Account *account) |
| gnc_numeric | xaccAccountGetProjectedMinimumBalance (const Account *account) |
| gnc_numeric | xaccAccountGetBalanceAsOfDate (Account *account, time_t date) |
| gnc_numeric | xaccAccountConvertBalanceToCurrency (const Account *account, gnc_numeric balance, const gnc_commodity *balance_currency, const gnc_commodity *new_currency) |
| gnc_numeric | xaccAccountConvertBalanceToCurrencyAsOfDate (const Account *account, gnc_numeric balance, gnc_commodity *balance_currency, gnc_commodity *new_currency, time_t date) |
| gnc_numeric | xaccAccountGetBalanceInCurrency (const Account *account, const gnc_commodity *report_commodity, gboolean include_children) |
| gnc_numeric | xaccAccountGetClearedBalanceInCurrency (const Account *account, const gnc_commodity *report_commodity, gboolean include_children) |
| gnc_numeric | xaccAccountGetReconciledBalanceInCurrency (const Account *account, const gnc_commodity *report_commodity, gboolean include_children) |
| gnc_numeric | xaccAccountGetPresentBalanceInCurrency (const Account *account, const gnc_commodity *report_commodity, gboolean include_children) |
| gnc_numeric | xaccAccountGetProjectedMinimumBalanceInCurrency (const Account *account, const gnc_commodity *report_commodity, gboolean include_children) |
| gnc_numeric | xaccAccountGetBalanceAsOfDateInCurrency (Account *account, time_t date, gnc_commodity *report_commodity, gboolean include_children) |
| gnc_numeric | xaccAccountGetBalanceChangeForPeriod (Account *acc, time_t date1, time_t 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. To make the management of sets of accounts easier, an account does not directly point at its children, but rather at an 'Account Group' that stores the children. At the top of the tree heirarchy lies a single root node, the root account group.
The account tree heirarchy is unique, in that a given account can have only one parent account. | |
| void | gnc_account_append_child (Account *new_parent, Account *child) |
| void | gnc_account_remove_child (Account *parent, Account *child) |
| Account * | gnc_account_get_parent (const Account *account) |
| Account * | gnc_account_get_root (Account *account) |
| gboolean | gnc_account_is_root (const Account *account) |
| GList * | gnc_account_get_children (const Account *account) |
| GList * | gnc_account_get_children_sorted (const Account *account) |
| gint | gnc_account_n_children (const Account *account) |
| gint | gnc_account_child_index (const Account *parent, const Account *child) |
| Account * | gnc_account_nth_child (const Account *parent, gint num) |
| GList * | gnc_account_get_descendants (const Account *account) |
| GList * | gnc_account_get_descendants_sorted (const Account *account) |
| gint | gnc_account_n_descendants (const Account *account) |
| gint | gnc_account_get_current_depth (const Account *account) |
| gint | gnc_account_get_tree_depth (const Account *account) |
ForEach | |
| void | gnc_account_foreach_child (const Account *account, AccountCb func, gpointer user_data) |
| gpointer | gnc_account_foreach_child_until (const Account *account, AccountCb2 func, gpointer user_data) |
| void | gnc_account_foreach_descendant (const Account *account, AccountCb func, gpointer user_data) |
| gpointer | gnc_account_foreach_descendant_until (const Account *account, AccountCb2 func, gpointer user_data) |
Concatenation, Merging | |
| void | gnc_account_join_children (Account *to_parent, Account *from_parent) |
| void | gnc_account_copy_children (Account *dest, Account *src) |
| void | gnc_account_merge_children (Account *parent) |
Getting Accounts and Subaccounts by Name | |
| Account * | gnc_account_lookup_by_name (const Account *parent, const char *name) |
| Account * | gnc_account_lookup_by_full_name (const Account *any_account, const gchar *name) |
GNCAccountType conversion/checking | |
| const char * | xaccAccountTypeEnumAsString (GNCAccountType type) |
| gboolean | xaccAccountStringToType (const char *str, GNCAccountType *type) |
| GNCAccountType | xaccAccountStringToEnum (const char *str) |
| const char * | xaccAccountGetTypeStr (GNCAccountType type) |
| GNCAccountType | xaccAccountGetTypeFromStr (const gchar *str) |
| guint32 | xaccParentAccountTypesCompatibleWith (GNCAccountType type) |
| gboolean | xaccAccountTypesCompatible (GNCAccountType parent_type, GNCAccountType child_type) |
| guint32 | xaccAccountTypesValid (void) |
Account lots | |
| void | xaccAccountInsertLot (Account *, GNCLot *) |
| void | xaccAccountRemoveLot (Account *, GNCLot *) |
| LotList * | xaccAccountGetLotList (const Account *account) |
| gpointer | xaccAccountForEachLot (const Account *acc, gpointer(*proc)(GNCLot *lot, gpointer user_data), gpointer user_data) |
| LotList * | xaccAccountFindOpenLots (const Account *acc, gboolean(*match_func)(GNCLot *lot, gpointer user_data), gpointer user_data, GCompareFunc sort_func) |
Account Reconciliation information getters/setters | |
| gboolean | xaccAccountGetReconcileLastDate (const Account *account, time_t *last_date) |
| void | xaccAccountSetReconcileLastDate (Account *account, time_t last_date) |
| gboolean | xaccAccountGetReconcileLastInterval (const Account *account, int *months, int *days) |
| void | xaccAccountSetReconcileLastInterval (Account *account, int months, int days) |
| gboolean | xaccAccountGetReconcilePostponeDate (const Account *account, time_t *postpone_date) |
| void | xaccAccountSetReconcilePostponeDate (Account *account, time_t postpone_date) |
| gboolean | xaccAccountGetReconcilePostponeBalance (const Account *account, gnc_numeric *balance) |
| void | xaccAccountSetReconcilePostponeBalance (Account *account, gnc_numeric balance) |
| void | xaccAccountClearReconcilePostpone (Account *account) |
Account Placeholder flag | |
| gboolean | xaccAccountGetPlaceholder (const Account *account) |
| void | xaccAccountSetPlaceholder (Account *account, gboolean val) |
| GNCPlaceholderType | xaccAccountGetDescendantPlaceholder (const Account *account) |
Account Hidden flag | |
| gboolean | xaccAccountGetHidden (const Account *acc) |
| void | xaccAccountSetHidden (Account *acc, gboolean val) |
| gboolean | xaccAccountIsHidden (const Account *acc) |
Account Tax related getters/setters | |
| gboolean | xaccAccountGetTaxRelated (const Account *account) |
| void | xaccAccountSetTaxRelated (Account *account, gboolean tax_related) |
| const char * | xaccAccountGetTaxUSCode (const Account *account) |
| void | xaccAccountSetTaxUSCode (Account *account, const char *code) |
| const char * | xaccAccountGetTaxUSPayerNameSource (const Account *account) |
| void | xaccAccountSetTaxUSPayerNameSource (Account *account, const char *source) |
Account marking | |
| void | xaccAccountSetMark (Account *account, short mark) |
| short | xaccAccountGetMark (const Account *account) |
| void | xaccClearMark (Account *account, short val) |
| void | xaccClearMarkDown (Account *account, short val) |
Staged Traversal | |
The following functions provide support for "staged traversals" over all of the transactions in an account or group. The idea is to be able to perform a sequence of traversals ("stages"), and perform an operation on each transaction exactly once for that stage. Only transactions whose current "stage" is less than the stage of the current traversal will be affected, and they will be "brought up" to the current stage when they are processed. For example, you could perform a stage 1 traversal of all the transactions in an account, and then perform a stage 1 traversal of the transactions in a second account. Presuming the traversal of the first account didn't abort prematurely, any transactions shared by both accounts would be ignored during the traversal of the second account since they had been processed while traversing the first account. However, if you had traversed the second account using a stage of 2, then all the transactions in the second account would have been processed. Traversal can be aborted by having the callback function return a non-zero value. The traversal is aborted immediately, and the non-zero value is returned. Note that an aborted traversal can be restarted; no information is lost due to an abort. The initial impetus for this particular approach came from generalizing a mark/sweep practice that was already being used in FileIO.c.
Note that currently, there is a hard limit of 256 stages, which can be changed by enlarging "marker" in the transaction struct. | |
| void | gnc_account_tree_begin_staged_transaction_traversals (Account *acc) |
| void | xaccSplitsBeginStagedTransactionTraversals (SplitList *splits) |
| void | xaccAccountBeginStagedTransactionTraversals (const Account *account) |
| gboolean | xaccTransactionTraverse (Transaction *trans, int stage) |
| gboolean | xaccSplitTransactionTraverse (Split *split, int stage) |
| int | xaccAccountStagedTransactionTraversal (const Account *a, unsigned int stage, TransactionCallback thunk, void *data) |
| int | gnc_account_tree_staged_transaction_traversal (const Account *account, unsigned int stage, TransactionCallback thunk, void *data) |
| int | xaccAccountTreeForEachTransaction (Account *acc, TransactionCallback proc, void *data) |
Deprecated Routines. | |
| void | DxaccAccountSetCurrency (Account *account, gnc_commodity *currency) |
| gnc_commodity * | DxaccAccountGetCurrency (const Account *account) |
| void | dxaccAccountSetQuoteTZ (Account *account, const char *tz) |
| const char * | dxaccAccountGetQuoteTZ (const Account *account) |
1.5.2