|
GnuCash 2.3.0
|
Data Structures | |
| struct | AccountClass |
Files | |
| file | Account.h |
Account handling public routines. | |
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)) |
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, 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 } |
Functions | |
| GType | gnc_account_get_type (void) |
| gchar * | gnc_account_name_violations_errmsg (const gchar *separator, GList *invalid_account_names) |
| GList * | gnc_account_list_name_violations (QofBook *book, const gchar *separator) |
| 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 *source, 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 lookup and GncGUID routines | |
| 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 GncGUID *guid, QofBook *book) |
| #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) |
| void | xaccAccountSetName (Account *account, const char *name) |
| void | xaccAccountSetCode (Account *account, const char *code) |
| void | xaccAccountSetDescription (Account *account, const char *desc) |
| void | xaccAccountSetColor (Account *account, const char *color) |
| void | xaccAccountSetFilter (Account *account, const char *filter) |
| void | xaccAccountSetSortOrder (Account *account, const char *sortorder) |
| 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_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 * | xaccAccountGetColor (const Account *account) |
| const char * | xaccAccountGetFilter (const Account *account) |
| const char * | xaccAccountGetSortOrder (const Account *account) |
| const char * | xaccAccountGetNotes (const Account *account) |
| const char * | xaccAccountGetLastNum (const Account *account) |
| GNCPolicy * | gnc_account_get_policy (Account *account) |
| void | xaccAccountRecomputeBalance (Account *) |
| void | xaccAccountSortSplits (Account *acc, gboolean force) |
| gchar * | gnc_account_get_full_name (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 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) |
| 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 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 hierarchy lies a single root node, the root account group. 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) |
| 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) |
| 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_merge_children (Account *parent) |
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.
| 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 96 of file Account.h.
{
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,
/* bank account types */
ACCT_TYPE_CHECKING = 15,
ACCT_TYPE_SAVINGS = 16,
ACCT_TYPE_MONEYMRKT = 17,
ACCT_TYPE_CREDITLINE = 18,
ACCT_TYPE_LAST
} GNCAccountType;
| 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.
Definition at line 4250 of file Account.c.
{
if (!acc) return NULL;
if (xaccAccountIsPriced(acc))
{
KvpValue *value = kvp_frame_get_slot(acc->inst.kvp_data,
"old-price-source");
if (value) return (kvp_value_get_string(value));
}
return NULL;
}
| 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 4229 of file Account.c.
{
if (!acc) return;
xaccAccountBeginEdit(acc);
if (xaccAccountIsPriced(acc))
{
kvp_frame_set_slot_nc(acc->inst.kvp_data,
"old-price-source",
src ? kvp_value_new_string(src) : NULL);
mark_account (acc);
}
qof_instance_set_dirty(&acc->inst);
xaccAccountCommitEdit(acc);
}
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 2348 of file Account.c.
{
AccountPrivate *ppriv, *cpriv;
Account *old_parent;
QofCollection *col;
/* errors */
g_assert(GNC_IS_ACCOUNT(new_parent));
g_assert(GNC_IS_ACCOUNT(child));
/* optimizations */
ppriv = GET_PRIVATE(new_parent);
cpriv = GET_PRIVATE(child);
old_parent = cpriv->parent;
if (old_parent == new_parent)
return;
// xaccAccountBeginEdit(new_parent);
xaccAccountBeginEdit(child);
if (old_parent)
{
gnc_account_remove_child(old_parent, child);
if (!qof_instance_books_equal(old_parent, new_parent))
{
/* hack alert -- this implementation is not exactly correct.
* If the entity tables are not identical, then the 'from' book
* may have a different backend than the 'to' book. This means
* that we should get the 'from' backend to destroy this account,
* and the 'to' backend to save it. Right now, this is broken.
*
* A 'correct' implementation similar to this is in Period.c
* except its for transactions ...
*
* Note also, we need to reparent the children to the new book as well.
*/
PWARN ("reparenting accounts across books is not correctly supported\n");
qof_event_gen (&child->inst, QOF_EVENT_DESTROY, NULL);
col = qof_book_get_collection (qof_instance_get_book(new_parent),
GNC_ID_ACCOUNT);
qof_collection_insert_entity (col, &child->inst);
qof_event_gen (&child->inst, QOF_EVENT_CREATE, NULL);
}
}
cpriv->parent = new_parent;
ppriv->children = g_list_append(ppriv->children, child);
qof_instance_set_dirty(&new_parent->inst);
qof_instance_set_dirty(&child->inst);
/* Send events data. Warning: The call to commit_edit is also going
* to send a MODIFY event. If the gtktreemodelfilter code gets the
* MODIFY before it gets the ADD, it gets very confused and thinks
* that two nodes have been added. */
qof_event_gen (&child->inst, QOF_EVENT_ADD, NULL);
// qof_event_gen (&new_parent->inst, QOF_EVENT_MODIFY, NULL);
xaccAccountCommitEdit (child);
// xaccAccountCommitEdit(new_parent);
}
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 2506 of file Account.c.
{
g_return_val_if_fail(GNC_IS_ACCOUNT(parent), -1);
g_return_val_if_fail(GNC_IS_ACCOUNT(child), -1);
return g_list_index(GET_PRIVATE(parent)->children, child);
}
Create a new root level account.
Definition at line 938 of file Account.c.
{
Account *root;
AccountPrivate *rpriv;
root = xaccMallocAccount(book);
rpriv = GET_PRIVATE(root);
xaccAccountBeginEdit(root);
rpriv->type = ACCT_TYPE_ROOT;
CACHE_REPLACE(rpriv->accountName, "Root Account");
xaccAccountCommitEdit(root);
gnc_book_set_root_account(book, root);
return root;
}
| 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 2763 of file Account.c.
{
const AccountPrivate *priv;
GList *node;
g_return_if_fail(GNC_IS_ACCOUNT(acc));
g_return_if_fail(thunk);
priv = GET_PRIVATE(acc);
for (node = priv->children; node; node = node->next)
{
thunk (node->data, user_data);
}
}
| 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 2781 of file Account.c.
{
const AccountPrivate *priv;
GList *node;
Account *child;
g_return_if_fail(GNC_IS_ACCOUNT(acc));
g_return_if_fail(thunk);
priv = GET_PRIVATE(acc);
for (node = priv->children; node; node = node->next)
{
child = node->data;
thunk(child, user_data);
gnc_account_foreach_descendant(child, thunk, user_data);
}
}
| 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 2802 of file Account.c.
{
const AccountPrivate *priv;
GList *node;
Account *child;
gpointer result;
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
g_return_val_if_fail(thunk, NULL);
priv = GET_PRIVATE(acc);
for (node = priv->children; node; node = node->next)
{
child = node->data;
result = thunk(child, user_data);
if (result)
return(result);
result = gnc_account_foreach_descendant_until(child, thunk, user_data);
if (result)
return(result);
}
return NULL;
}
| 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 2477 of file Account.c.
{
g_return_val_if_fail(GNC_IS_ACCOUNT(account), NULL);
return g_list_copy(GET_PRIVATE(account)->children);
}
| 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 2484 of file Account.c.
{
AccountPrivate *priv;
/* errors */
g_return_val_if_fail(GNC_IS_ACCOUNT(account), NULL);
/* optimizations */
priv = GET_PRIVATE(account);
if (!priv->children)
return NULL;
return g_list_sort(g_list_copy(priv->children), (GCompareFunc)xaccAccountOrder);
}
| 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 2538 of file Account.c.
{
AccountPrivate *priv;
int depth = 0;
g_return_val_if_fail(GNC_IS_ACCOUNT(account), 0);
priv = GET_PRIVATE(account);
while (priv->parent && (priv->type != ACCT_TYPE_ROOT))
{
account = priv->parent;
priv = GET_PRIVATE(account);
depth++;
}
return depth;
}
| 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 2578 of file Account.c.
{
AccountPrivate *priv;
GList *child, *descendants;
g_return_val_if_fail(GNC_IS_ACCOUNT(account), NULL);
priv = GET_PRIVATE(account);
if (!priv->children)
return NULL;
descendants = NULL;
for (child = priv->children; child; child = g_list_next(child))
{
descendants = g_list_append(descendants, child->data);
descendants = g_list_concat(descendants,
gnc_account_get_descendants(child->data));
}
return descendants;
}
| GList* gnc_account_get_descendants_sorted | ( | const Account * | account | ) |
This function returns a GList containing all the descendants of the specified account, sorted at each level. This includes not only the the children, but the children of the children, etc. Within each set of child accounts, the accounts returned by this function are ordered via the standard account sort function. For a list of descendants where each set of children is unordered, use the gnc_account_get_descendants() function.
Note: Use this function where the results are intended for display to the user. If the results are internal to GnuCash or will be resorted at som later point in time you should use the gnc_account_get_descendants() function.
| account | The account whose descendants should be returned. |
Definition at line 2600 of file Account.c.
{
AccountPrivate *priv;
GList *child, *children, *descendants;
/* errors */
g_return_val_if_fail(GNC_IS_ACCOUNT(account), NULL);
/* optimizations */
priv = GET_PRIVATE(account);
if (!priv->children)
return NULL;
descendants = NULL;
children = g_list_sort(g_list_copy(priv->children), (GCompareFunc)xaccAccountOrder);
for (child = children; child; child = g_list_next(child))
{
descendants = g_list_append(descendants, child->data);
descendants = g_list_concat(descendants,
gnc_account_get_descendants_sorted(child->data));
}
g_list_free(children);
return descendants;
}
| 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 2861 of file Account.c.
{
AccountPrivate *priv;
const Account *a;
char *fullname;
gchar **names;
int level;
/* So much for hardening the API. Too many callers to this function don't
* bother to check if they have a non-NULL pointer before calling. */
if (NULL == account)
return g_strdup("");
/* errors */
g_return_val_if_fail(GNC_IS_ACCOUNT(account), g_strdup(""));
/* optimizations */
priv = GET_PRIVATE(account);
if (!priv->parent)
return g_strdup("");
/* Figure out how much space is needed by counting the nodes up to
* the root. */
level = 0;
for (a = account; a; a = priv->parent)
{
priv = GET_PRIVATE(a);
level++;
}
/* Get all the pointers in the right order. The root node "entry"
* becomes the terminating NULL pointer for the array of strings. */
names = g_malloc(level * sizeof(gchar *));
names[--level] = NULL;
for (a = account; level > 0; a = priv->parent)
{
priv = GET_PRIVATE(a);
names[--level] = priv->accountName;
}
/* Build the full name */
fullname = g_strjoinv(account_separator, names);
g_free(names);
return fullname;
}
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 2446 of file Account.c.
{
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
return GET_PRIVATE(acc)->parent;
}
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 2453 of file Account.c.
{
AccountPrivate *priv;
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL);
priv = GET_PRIVATE(acc);
while (priv->parent)
{
acc = priv->parent;
priv = GET_PRIVATE(acc);
}
return acc;
}
| 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 specifed account itself.
| account | The account to query. |
Definition at line 2557 of file Account.c.
{
AccountPrivate *priv;
GList *node;
gint depth = 0, child_depth;
g_return_val_if_fail(GNC_IS_ACCOUNT(account), 0);
priv = GET_PRIVATE(account);
if (!priv->children)
return 1;
for (node = priv->children; node; node = g_list_next(node))
{
child_depth = gnc_account_get_tree_depth(node->data);
depth = MAX(depth, child_depth);
}
return depth + 1;
}
| 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().
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 1540 of file Account.c.
{
AccountPrivate *priv;
GList *node;
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
g_return_val_if_fail(GNC_IS_SPLIT(s), FALSE);
priv = GET_PRIVATE(acc);
node = g_list_find(priv->splits, s);
if (node)
return FALSE;
if (qof_instance_get_editlevel(acc) == 0)
{
priv->splits = g_list_insert_sorted(priv->splits, s,
(GCompareFunc)xaccSplitOrder);
}
else
{
priv->splits = g_list_prepend(priv->splits, s);
priv->sort_dirty = TRUE;
}
//FIXME: find better event
qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, NULL);
/* Also send an event based on the account */
qof_event_gen(&acc->inst, GNC_EVENT_ITEM_ADDED, s);
priv->balance_dirty = TRUE;
// DRH: Should the below be added? It is present in the delete path.
// xaccAccountRecomputeBalance(acc);
return TRUE;
}
| 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 2470 of file Account.c.
{
g_return_val_if_fail(GNC_IS_ACCOUNT(account), FALSE);
return (GET_PRIVATE(account)->parent == NULL);
}
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 4399 of file Account.c.
{
AccountPrivate *from_priv;
GList *children, *node;
/* errors */
g_return_if_fail(GNC_IS_ACCOUNT(to_parent));
g_return_if_fail(GNC_IS_ACCOUNT(from_parent));
/* optimizations */
from_priv = GET_PRIVATE(from_parent);
if (!from_priv->children)
return;
ENTER (" ");
children = g_list_copy(from_priv->children);
for (node = children; node; node = g_list_next(node))
gnc_account_append_child(to_parent, node->data);
g_list_free(children);
LEAVE (" ");
}
| 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 177 of file Account.c.
{
Account *root_account = gnc_book_get_root_account(book);
GList *accounts, *node;
GList *invalid_list = NULL;
g_return_val_if_fail (separator != NULL, NULL);
if (root_account == NULL)
return NULL;
accounts = gnc_account_get_descendants (root_account);
for (node = accounts; node; node = g_list_next(node))
{
Account *acct = (Account*)node->data;
gchar *acct_name = g_strdup ( xaccAccountGetName ( acct ) );
if ( g_strstr_len ( acct_name, -1, separator ) )
invalid_list = g_list_prepend ( invalid_list, (gpointer) acct_name );
else
g_free ( acct_name );
}
if (accounts != NULL)
{
g_list_free(accounts);
}
return invalid_list;
}
| 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 4424 of file Account.c.
{
AccountPrivate *ppriv, *priv_a, *priv_b;
GList *node_a, *node_b, *work, *worker;
g_return_if_fail(GNC_IS_ACCOUNT(parent));
ppriv = GET_PRIVATE(parent);
for (node_a = ppriv->children; node_a; node_a = node_a->next)
{
Account *acc_a = node_a->data;
priv_a = GET_PRIVATE(acc_a);
for (node_b = node_a->next; node_b; node_b = g_list_next(node_b))
{
Account *acc_b = node_b->data;
priv_b = GET_PRIVATE(acc_b);
if (0 != null_strcmp(priv_a->accountName, priv_b->accountName))
continue;
if (0 != null_strcmp(priv_a->accountCode, priv_b->accountCode))
continue;
if (0 != null_strcmp(priv_a->description, priv_b->description))
continue;
if (0 != null_strcmp(xaccAccountGetColor(acc_a),
xaccAccountGetColor(acc_b)))
continue;
if (!gnc_commodity_equiv(priv_a->commodity, priv_b->commodity))
continue;
if (0 != null_strcmp(xaccAccountGetNotes(acc_a),
xaccAccountGetNotes(acc_b)))
continue;
if (priv_a->type != priv_b->type)
continue;
/* consolidate children */
if (priv_b->children)
{
work = g_list_copy(priv_b->children);
for (worker = work; worker; worker = g_list_next(worker))
gnc_account_append_child (acc_a, (Account *)worker->data);
g_list_free(work);
qof_event_gen (&acc_a->inst, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&acc_b->inst, QOF_EVENT_MODIFY, NULL);
}
/* recurse to do the children's children */
gnc_account_merge_children (acc_a);
/* consolidate transactions */
while (priv_b->splits)
xaccSplitSetAccount (priv_b->splits->data, acc_a);
/* move back one before removal. next iteration around the loop
* will get the node after node_b */
node_b = g_list_previous(node_b);
/* The destroy function will remove from list -- node_a is ok,
* it's before node_b */
xaccAccountBeginEdit (acc_b);
xaccAccountDestroy (acc_b);
}
}
}
| 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 2499 of file Account.c.
{
g_return_val_if_fail(GNC_IS_ACCOUNT(account), 0);
return g_list_length(GET_PRIVATE(account)->children);
}
| 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 2521 of file Account.c.
{
AccountPrivate *priv;
GList *node;
gint count = 0;
g_return_val_if_fail(GNC_IS_ACCOUNT(account), 0);
priv = GET_PRIVATE(account);
for (node = priv->children; node; node = g_list_next(node))
{
count += gnc_account_n_descendants(node->data) + 1;
}
return count;
}
| 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 140 of file Account.c.
{
GList *node;
gchar *message = NULL;
gchar *account_list = NULL;
if ( !invalid_account_names )
return NULL;
for ( node = invalid_account_names; node; node = g_list_next(node))
{
if ( !account_list )
account_list = node->data;
else
{
gchar *tmp_list = NULL;
tmp_list = g_strconcat (account_list, "\n", node->data, NULL );
g_free ( account_list );
account_list = tmp_list;
}
}
/* Translators: The first %s will be the account separator character,
the second %s is a list of account names.
The resulting string will be displayed to the user if there are
account names containing the separator character. */
message = g_strdup_printf(
_("The separator character \"%s\" is used in one or more account names.\n\n"
"This will result in unexpected behaviour. "
"Either change the account names or choose another separator character.\n\n"
"Below you will find the list of invalid account names:\n"
"%s"), separator, account_list );
g_free ( account_list );
return message;
}
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 2514 of file Account.c.
{
g_return_val_if_fail(GNC_IS_ACCOUNT(parent), NULL);
return g_list_nth_data(GET_PRIVATE(parent)->children, num);
}
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 2410 of file Account.c.
{
AccountPrivate *ppriv, *cpriv;
GncEventData ed;
if (!child) return;
/* Note this routine might be called on accounts which
* are not yet parented. */
if (!parent) return;
ppriv = GET_PRIVATE(parent);
cpriv = GET_PRIVATE(child);
if (cpriv->parent != parent)
{
PERR ("account not a child of parent");
return;
}
/* Gather event data */
ed.node = parent;
ed.idx = g_list_index(ppriv->children, child);
ppriv->children = g_list_remove(ppriv->children, child);
/* Now send the event. */
qof_event_gen(&child->inst, QOF_EVENT_REMOVE, &ed);
/* clear the account's parent pointer after REMOVE event generation. */
cpriv->parent = NULL;
qof_event_gen (&parent->inst, QOF_EVENT_MODIFY, NULL);
}
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 1576 of file Account.c.
{
AccountPrivate *priv;
GList *node;
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
g_return_val_if_fail(GNC_IS_SPLIT(s), FALSE);
priv = GET_PRIVATE(acc);
node = g_list_find(priv->splits, s);
if (NULL == node)
return FALSE;
priv->splits = g_list_delete_link(priv->splits, node);
//FIXME: find better event type
qof_event_gen(&acc->inst, QOF_EVENT_MODIFY, NULL);
// And send the account-based event, too
qof_event_gen(&acc->inst, GNC_EVENT_ITEM_REMOVED, s);
priv->balance_dirty = TRUE;
xaccAccountRecomputeBalance(acc);
return TRUE;
}
| 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 1523 of file Account.c.
{
AccountPrivate *priv;
g_return_if_fail(GNC_IS_ACCOUNT(acc));
if (qof_instance_get_destroying(acc))
return;
priv = GET_PRIVATE(acc);
priv->balance_dirty = TRUE;
}
Set the account's lot order policy
Definition at line 1708 of file Account.c.
{
AccountPrivate *priv;
g_return_if_fail(GNC_IS_ACCOUNT(acc));
priv = GET_PRIVATE(acc);
priv->policy = policy ? policy : xaccGetFIFOPolicy();
}
| 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 1509 of file Account.c.
{
AccountPrivate *priv;
g_return_if_fail(GNC_IS_ACCOUNT(acc));
if (qof_instance_get_destroying(acc))
return;
priv = GET_PRIVATE(acc);
priv->sort_dirty = TRUE;
}
| 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 2981 of file Account.c.
{
AccountPrivate *priv;
g_return_if_fail(GNC_IS_ACCOUNT(acc));
priv = GET_PRIVATE(acc);
priv->starting_balance = start_baln;
priv->balance_dirty = TRUE;
}
| 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 2993 of file Account.c.
{
AccountPrivate *priv;
g_return_if_fail(GNC_IS_ACCOUNT(acc));
priv = GET_PRIVATE(acc);
priv->starting_cleared_balance = start_baln;
priv->balance_dirty = TRUE;
}
| 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 3006 of file Account.c.
{
AccountPrivate *priv;
g_return_if_fail(GNC_IS_ACCOUNT(acc));
priv = GET_PRIVATE(acc);
priv->starting_reconciled_balance = start_baln;
priv->balance_dirty = TRUE;
}
| const gchar* gnc_get_account_separator_string | ( | void | ) |
| void xaccAccountBeginEdit | ( | Account * | account | ) |
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account updates.
Definition at line 1120 of file Account.c.
{
g_return_if_fail(acc);
qof_begin_edit(&acc->inst);
}
| void xaccAccountCommitEdit | ( | Account * | account | ) |
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account updates.
Definition at line 1161 of file Account.c.
{
AccountPrivate *priv;
QofBook *book;
g_return_if_fail(acc);
if (!qof_commit_edit(&acc->inst)) return;
/* If marked for deletion, get rid of subaccounts first,
* and then the splits ... */
priv = GET_PRIVATE(acc);
if (qof_instance_get_destroying(acc))
{
GList *lp, *slist;
QofCollection *col;
qof_instance_increase_editlevel(acc);
/* First, recursively free children */
xaccFreeAccountChildren(acc);
PINFO ("freeing splits for account %p (%s)",
acc, priv->accountName ? priv->accountName : "(null)");
book = qof_instance_get_book(acc);
/* If book is shutting down, just clear the split list. The splits
themselves will be destroyed by the transaction code */
if (!qof_book_shutting_down(book))
{
slist = g_list_copy(priv->splits);
for (lp = slist; lp; lp = lp->next)
{
Split *s = lp->data;
xaccSplitDestroy (s);
}
g_list_free(slist);
}
else
{
g_list_free(priv->splits);
priv->splits = NULL;
}
/* It turns out there's a case where this assertion does not hold:
When the user tries to delete an Imbalance account, while also
deleting all the splits in it. The splits will just get
recreated and put right back into the same account!
g_assert(priv->splits == NULL || qof_book_shutting_down(acc->inst.book));
*/
if (!qof_book_shutting_down(book))
{
col = qof_book_get_collection(book, GNC_ID_TRANS);
qof_collection_foreach(col, destroy_pending_splits_for_account, acc);
/* the lots should be empty by now */
for (lp = priv->lots; lp; lp = lp->next)
{
GNCLot *lot = lp->data;
gnc_lot_destroy (lot);
}
}
g_list_free(priv->lots);
priv->lots = NULL;
qof_instance_set_dirty(&acc->inst);
qof_instance_decrease_editlevel(acc);
}
else
{
xaccAccountBringUpToDate(acc);
}
qof_commit_edit_part2(&acc->inst, on_err, on_done, acc_free);
}
| 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 1240 of file Account.c.
{
g_return_if_fail(GNC_IS_ACCOUNT(acc));
qof_instance_set_destroying(acc, TRUE);
xaccAccountCommitEdit (acc);
}
Compare two accounts for equality - this is a deep compare.
Definition at line 1295 of file Account.c.
{
AccountPrivate *priv_aa, *priv_ab;
if (!aa && !ab) return TRUE;
g_return_val_if_fail(GNC_IS_ACCOUNT(aa), FALSE);
g_return_val_if_fail(GNC_IS_ACCOUNT(ab), FALSE);
priv_aa = GET_PRIVATE(aa);
priv_ab = GET_PRIVATE(ab);
if (priv_aa->type != priv_ab->type)
{
PWARN ("types differ: %d vs %d", priv_aa->type, priv_ab->type);
return FALSE;
}
if (safe_strcmp(priv_aa->accountName, priv_ab->accountName) != 0)
{
PWARN ("names differ: %s vs %s", priv_aa->accountName, priv_ab->accountName);
return FALSE;
}
if (safe_strcmp(priv_aa->accountCode, priv_ab->accountCode) != 0)
{
PWARN ("codes differ: %s vs %s", priv_aa->accountCode, priv_ab->accountCode);
return FALSE;
}
if (safe_strcmp(priv_aa->description, priv_ab->description) != 0)
{
PWARN ("descriptions differ: %s vs %s", priv_aa->description, priv_ab->description);
return FALSE;
}
if (!gnc_commodity_equal(priv_aa->commodity, priv_ab->commodity))
{
PWARN ("commodities differ");
return FALSE;
}
if (check_guids)
{
if (qof_instance_guid_compare(aa, ab) != 0)
{
PWARN ("GUIDs differ");
return FALSE;
}
}
if (kvp_frame_compare(aa->inst.kvp_data, ab->inst.kvp_data) != 0)
{
char *frame_a;
char *frame_b;
frame_a = kvp_frame_to_string (aa->inst.kvp_data);
frame_b = kvp_frame_to_string (ab->inst.kvp_data);
PWARN ("kvp frames differ:\n%s\n\nvs\n\n%s", frame_a, frame_b);
g_free (frame_a);
g_free (frame_b);
return FALSE;
}
if (!gnc_numeric_equal(priv_aa->starting_balance, priv_ab->starting_balance))
{
char *str_a;
char *str_b;
str_a = gnc_numeric_to_string(priv_aa->starting_balance);
str_b = gnc_numeric_to_string(priv_ab->starting_balance);
PWARN ("starting balances differ: %s vs %s", str_a, str_b);
g_free (str_a);
g_free (str_b);
return FALSE;
}
if (!gnc_numeric_equal(priv_aa->starting_cleared_balance,
priv_ab->starting_cleared_balance))
{
char *str_a;
char *str_b;
str_a = gnc_numeric_to_string(priv_aa->starting_cleared_balance);
str_b = gnc_numeric_to_string(priv_ab->starting_cleared_balance);
PWARN ("starting cleared balances differ: %s vs %s", str_a, str_b);
g_free (str_a);
g_free (str_b);
return FALSE;
}
if (!gnc_numeric_equal(priv_aa->starting_reconciled_balance,
priv_ab->starting_reconciled_balance))
{
char *str_a;
char *str_b;
str_a = gnc_numeric_to_string(priv_aa->starting_reconciled_balance);
str_b = gnc_numeric_to_string(priv_ab->starting_reconciled_balance);
PWARN ("starting reconciled balances differ: %s vs %s", str_a, str_b);
g_free (str_a);
g_free (str_b);
return FALSE;
}
if (!gnc_numeric_equal(priv_aa->balance, priv_ab->balance))
{
char *str_a;
char *str_b;
str_a = gnc_numeric_to_string(priv_aa->balance);
str_b = gnc_numeric_to_string(priv_ab->balance);
PWARN ("balances differ: %s vs %s", str_a, str_b);
g_free (str_a);
g_free (str_b);
return FALSE;
}
if (!gnc_numeric_equal(priv_aa->cleared_balance, priv_ab->cleared_balance))
{
char *str_a;
char *str_b;
str_a = gnc_numeric_to_string(priv_aa->cleared_balance);
str_b = gnc_numeric_to_string(priv_ab->cleared_balance);
PWARN ("cleared balances differ: %s vs %s", str_a, str_b);
g_free (str_a);
g_free (str_b);
return FALSE;
}
if (!gnc_numeric_equal(priv_aa->reconciled_balance, priv_ab->reconciled_balance))
{
char *str_a;
char *str_b;
str_a = gnc_numeric_to_string(priv_aa->reconciled_balance);
str_b = gnc_numeric_to_string(priv_ab->reconciled_balance);
PWARN ("reconciled balances differ: %s vs %s", str_a, str_b);
g_free (str_a);
g_free (str_b);
return FALSE;
}
/* no parent; always compare downwards. */
{
GList *la = priv_aa->splits;
GList *lb = priv_ab->splits;
if ((la && !lb) || (!la && lb))
{
PWARN ("only one has splits");
return FALSE;
}
if (la && lb)
{
/* presume that the splits are in the same order */
while (la && lb)
{
Split *sa = (Split *) la->data;
Split *sb = (Split *) lb->data;
if (!xaccSplitEqual(sa, sb, check_guids, TRUE, FALSE))
{
PWARN ("splits differ");
return(FALSE);
}
la = la->next;
lb = lb->next;
}
if ((la != NULL) || (lb != NULL))
{
PWARN ("number of splits differs");
return(FALSE);
}
}
}
if (!xaccAcctChildrenEqual(priv_aa->children, priv_ab->children, check_guids))
{
PWARN ("children differ");
return FALSE;
}
return(TRUE);
}
| gboolean xaccAccountGetAutoInterestXfer | ( | const Account * | account, |
| gboolean | default_value | ||
| ) |
Returns a per-account flag: Prior to reconciling an account which charges or pays interest, this flag tells whether to prompt the user to enter a transaction for the interest charge or payment. This per-account flag overrides the global preference.
Definition at line 4175 of file Account.c.
{
const char *str = NULL;
if (!acc) return default_value;
str = kvp_frame_get_string(acc->inst.kvp_data,
"reconcile-info/auto-interest-transfer");
return str ? !strcmp(str, "true") : default_value;
}
| gnc_numeric xaccAccountGetBalance | ( | const Account * | account | ) |
| gnc_numeric xaccAccountGetBalanceAsOfDate | ( | Account * | account, |
| time_t | date | ||
| ) |
Get the balance of the account as of the date specified
Definition at line 3078 of file Account.c.
{
/* Ideally this could use xaccAccountForEachSplit, but
* it doesn't exist yet and I'm uncertain of exactly how
* it would work at this time, since it differs from
* xaccAccountForEachTransaction by using gpointer return
* values rather than gints.
*/
AccountPrivate *priv;
GList *lp;
Timespec ts, trans_ts;
gboolean found = FALSE;
gnc_numeric balance;
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), gnc_numeric_zero());
xaccAccountSortSplits (acc, TRUE); /* just in case, normally a noop */
xaccAccountRecomputeBalance (acc); /* just in case, normally a noop */
priv = GET_PRIVATE(acc);
balance = priv->balance;
/* Since transaction post times are stored as a Timespec,
* convert date into a Timespec as well rather than converting
* each transaction's Timespec into a time_t.
*
* FIXME: CAS: I think this comment is a bogus justification for
* using xaccTransGetDatePostedTS. There's no benefit to using
* Timespec when the input argument is time_t, and it's hard to
* imagine that casting long long to long and comparing two longs is
* worse than comparing two long longs every time. IMO,
* xaccAccountGetPresentBalance gets this right, and its algorithm
* should be used here.
*/
ts.tv_sec = date;
ts.tv_nsec = 0;
lp = priv->splits;
while ( lp && !found )
{
xaccTransGetDatePostedTS( xaccSplitGetParent( (Split *)lp->data ),
&trans_ts );
if ( timespec_cmp( &trans_ts, &ts ) >= 0 )
found = TRUE;
else
lp = lp->next;
}
if ( lp )
{
if ( lp->prev )
{
/* Since lp is now pointing to a split which was past the reconcile
* date, get the running balance of the previous split.
*/
balance = xaccSplitGetBalance( (Split *)lp->prev->data );
}
else
{
/* AsOf date must be before any entries, return zero. */
balance = gnc_numeric_zero();
}
}
/* Otherwise there were no splits posted after the given date,
* so the latest account balance should be good enough.
*/
return( balance );
}
| gnc_numeric xaccAccountGetClearedBalance | ( | const Account * | account | ) |
| const char* xaccAccountGetCode | ( | const Account * | account | ) |
| const char* xaccAccountGetColor | ( | const Account * | account | ) |
| gnc_commodity* xaccAccountGetCommodity | ( | const Account * | account | ) |
| 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 2281 of file Account.c.
{
AccountPrivate *priv;
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), 0);
priv = GET_PRIVATE(acc);
if (priv->non_standard_scu || !priv->commodity)
return priv->commodity_scu;
return gnc_commodity_get_fraction(priv->commodity);
}
| int xaccAccountGetCommoditySCUi | ( | const Account * | account | ) |
| const char* xaccAccountGetDescription | ( | const Account * | account | ) |
| const char* xaccAccountGetFilter | ( | const Account * | account | ) |
| const char* xaccAccountGetLastNum | ( | const Account * | account | ) |
| const char* xaccAccountGetName | ( | const Account * | account | ) |
| gboolean xaccAccountGetNonStdSCU | ( | const Account * | account | ) |
| const char* xaccAccountGetNotes | ( | const Account * | account | ) |
| gboolean xaccAccountGetReconcileChildrenStatus | ( | const Account * | account | ) |
DOCUMENT ME!
Definition at line 4320 of file Account.c.
{
/* access the account's kvp-data for status and return that, if no value
* is found then we can assume not to include the children, that being
* the default behaviour
*/
return acc ? kvp_frame_get_gint64(acc->inst.kvp_data,
"reconcile-info/include-children") : FALSE;
}
| gnc_numeric xaccAccountGetReconciledBalance | ( | const Account * | account | ) |
| const char* xaccAccountGetSortOrder | ( | const Account * | account | ) |
| 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 2832 of file Account.c.
{
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), ACCT_TYPE_NONE);
return GET_PRIVATE(acc)->type;
}
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 3774 of file Account.c.
{
const Account *parent;
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
g_return_val_if_fail(GNC_IS_ACCOUNT(ancestor), FALSE);
parent = acc;
while (parent && parent != ancestor)
parent = GET_PRIVATE(parent)->parent;
return (parent == ancestor);
}
| gboolean xaccAccountIsPriced | ( | const Account * | acc | ) |
Returns true if the account is a stock, mutual fund or currency, otherwise false.
Definition at line 3983 of file Account.c.
{
AccountPrivate *priv;
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
priv = GET_PRIVATE(acc);
return (priv->type == ACCT_TYPE_STOCK || priv->type == ACCT_TYPE_MUTUAL ||
priv->type == ACCT_TYPE_CURRENCY);
}
The xaccAccountLookup() subroutine will return the account associated with the given id, or NULL if there is no such account.
Definition at line 1647 of file Account.c.
{
QofCollection *col;
if (!guid || !book) return NULL;
col = qof_book_get_collection (book, GNC_ID_ACCOUNT);
return (Account *) qof_collection_lookup_entity (col, guid);
}
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 1955 of file Account.c.
{
AccountPrivate *priv_aa, *priv_ab;
char *da, *db;
char *endptr = NULL;
int ta, tb, result;
long la, lb;
if ( aa && !ab ) return -1;
if ( !aa && ab ) return +1;
if ( !aa && !ab ) return 0;
priv_aa = GET_PRIVATE(aa);
priv_ab = GET_PRIVATE(ab);
/* sort on accountCode strings */
da = priv_aa->accountCode;
db = priv_ab->accountCode;
/* If accountCodes are both base 36 integers do an integer sort */
la = strtoul (da, &endptr, 36);
if ((*da != '\0') && (*endptr == '\0'))
{
lb = strtoul (db, &endptr, 36);
if ((*db != '\0') && (*endptr == '\0'))
{
if (la < lb) return -1;
if (la > lb) return +1;
}
}
/* Otherwise do a string sort */
result = safe_strcmp (da, db);
if (result)
return result;
/* if account-type-order array not initialized, initialize it */
/* this will happen at most once during program invocation */
if (-1 == revorder[0])
{
int i;
for (i = 0; i < NUM_ACCOUNT_TYPES; i++)
{
revorder [typeorder[i]] = i;
}
}
/* otherwise, sort on account type */
ta = priv_aa->type;
tb = priv_ab->type;
ta = revorder[ta];
tb = revorder[tb];
if (ta < tb) return -1;
if (ta > tb) return +1;
/* otherwise, sort on accountName strings */
da = priv_aa->accountName;
db = priv_ab->accountName;
result = safe_utf8_collate(da, db);
if (result)
return result;
/* guarantee a stable sort */
return qof_instance_guid_compare(aa, ab);
}
| void xaccAccountRecomputeBalance | ( | Account * | ) |
The following recompute the partial balances (stored with the transaction) and the total balance, for this account
Definition at line 1879 of file Account.c.
{
AccountPrivate *priv;
gnc_numeric balance;
gnc_numeric cleared_balance;
gnc_numeric reconciled_balance;
Split *last_split = NULL;
GList *lp;
if (NULL == acc) return;
priv = GET_PRIVATE(acc);
if (qof_instance_get_editlevel(acc) > 0) return;
if (!priv->balance_dirty) return;
if (qof_instance_get_destroying(acc)) return;
if (qof_book_shutting_down(qof_instance_get_book(acc))) return;
balance = priv->starting_balance;
cleared_balance = priv->starting_cleared_balance;
reconciled_balance = priv->starting_reconciled_balance;
PINFO ("acct=%s starting baln=%" G_GINT64_FORMAT "/%" G_GINT64_FORMAT,
priv->accountName, balance.num, balance.denom);
for (lp = priv->splits; lp; lp = lp->next)
{
Split *split = (Split *) lp->data;
gnc_numeric amt = xaccSplitGetAmount (split);
balance = gnc_numeric_add_fixed(balance, amt);
if (NREC != split->reconciled)
{
cleared_balance = gnc_numeric_add_fixed(cleared_balance, amt);
}
if (YREC == split->reconciled ||
FREC == split->reconciled)
{
reconciled_balance =
gnc_numeric_add_fixed(reconciled_balance, amt);
}
split->balance = balance;
split->cleared_balance = cleared_balance;
split->reconciled_balance = reconciled_balance;
last_split = split;
}
priv->balance = balance;
priv->cleared_balance = cleared_balance;
priv->reconciled_balance = reconciled_balance;
priv->balance_dirty = FALSE;
}
| void xaccAccountSetAutoInterestXfer | ( | Account * | account, |
| gboolean | value | ||
| ) |
Sets a per-account flag: Prior to reconciling an account which charges or pays interest, this flag tells whether to prompt the user to enter a transaction for the interest charge or payment. This per-account flag overrides the global preference.
Definition at line 4189 of file Account.c.
{
if (!acc) return;
xaccAccountBeginEdit (acc);
/* FIXME: need KVP_TYPE_BOOLEAN for this someday */
kvp_frame_set_string (acc->inst.kvp_data,
"/reconcile-info/auto-interest-transfer",
(option ? "true" : "false"));
mark_account (acc);
xaccAccountCommitEdit (acc);
}
| void xaccAccountSetCode | ( | Account * | account, |
| const char * | code | ||
| ) |
Set the account's accounting code
Definition at line 2072 of file Account.c.
{
AccountPrivate *priv;
/* errors */
g_return_if_fail(GNC_IS_ACCOUNT(acc));
/* optimizations */
priv = GET_PRIVATE(acc);
if (safe_strcmp(str, priv->accountCode) == 0)
return;
xaccAccountBeginEdit(acc);
CACHE_REPLACE(priv->accountCode, str ? str : "");
mark_account (acc);
xaccAccountCommitEdit(acc);
}
| void xaccAccountSetColor | ( | Account * | account, |
| const char * | color | ||
| ) |
Set the account's Color
Definition at line 2110 of file Account.c.
{
g_return_if_fail(GNC_IS_ACCOUNT(acc));
xaccAccountBeginEdit(acc);
if (str)
{
gchar *tmp = g_strstrip(g_strdup(str));
kvp_frame_set_slot_nc(acc->inst.kvp_data, "color",
strlen(tmp) ? kvp_value_new_string(tmp) : NULL);
g_free(tmp);
}
else
{
kvp_frame_set_slot_nc(acc->inst.kvp_data, "color", NULL);
}
mark_account (acc);
xaccAccountCommitEdit(acc);
}
| void xaccAccountSetCommodity | ( | Account * | account, |
| gnc_commodity * | comm | ||
| ) |
Set the account's commodity
Definition at line 2212 of file Account.c.
{
AccountPrivate *priv;
GList *lp;
/* errors */
g_return_if_fail(GNC_IS_ACCOUNT(acc));
g_return_if_fail(GNC_IS_COMMODITY(com));
/* optimizations */
priv = GET_PRIVATE(acc);
if (com == priv->commodity)
return;
xaccAccountBeginEdit(acc);
gnc_commodity_decrement_usage_count(priv->commodity);
priv->commodity = com;
gnc_commodity_increment_usage_count(com);
priv->commodity_scu = gnc_commodity_get_fraction(com);
priv->non_standard_scu = FALSE;
/* iterate over splits */
for (lp = priv->splits; lp; lp = lp->next)
{
Split *s = (Split *) lp->data;
Transaction *trans = xaccSplitGetParent (s);
xaccTransBeginEdit (trans);
xaccSplitSetAmount (s, xaccSplitGetAmount(s));
xaccTransCommitEdit (trans);
}
priv->sort_dirty = TRUE; /* Not needed. */
priv->balance_dirty = TRUE;
mark_account (acc);
xaccAccountCommitEdit(acc);
}
| 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 2258 of file Account.c.
{
AccountPrivate *priv;
g_return_if_fail(GNC_IS_ACCOUNT(acc));
priv = GET_PRIVATE(acc);
xaccAccountBeginEdit(acc);
priv->commodity_scu = scu;
if (scu != gnc_commodity_get_fraction(priv->commodity))
priv->non_standard_scu = TRUE;
mark_account(acc);
xaccAccountCommitEdit(acc);
}
| void xaccAccountSetDescription | ( | Account * | account, |
| const char * | desc | ||
| ) |
Set the account's description
Definition at line 2091 of file Account.c.
{
AccountPrivate *priv;
/* errors */
g_return_if_fail(GNC_IS_ACCOUNT(acc));
/* optimizations */
priv = GET_PRIVATE(acc);
if (safe_strcmp(str, priv->description) == 0)
return;
xaccAccountBeginEdit(acc);
CACHE_REPLACE(priv->description, str ? str : "");
mark_account (acc);
xaccAccountCommitEdit(acc);
}
| void xaccAccountSetFilter | ( | Account * | account, |
| const char * | filter | ||
| ) |
Set the account's Filter
Definition at line 2131 of file Account.c.
{
g_return_if_fail(GNC_IS_ACCOUNT(acc));
xaccAccountBeginEdit(acc);
if (str)
{
gchar *tmp = g_strstrip(g_strdup(str));
kvp_frame_set_slot_nc(acc->inst.kvp_data, "filter",
strlen(tmp) ? kvp_value_new_string(tmp) : NULL);
g_free(tmp);
}
else
{
kvp_frame_set_slot_nc(acc->inst.kvp_data, "filter", NULL);
}
mark_account (acc);
xaccAccountCommitEdit(acc);
}
| void xaccAccountSetLastNum | ( | Account * | account, |
| const char * | num | ||
| ) |
Set the last num field of an Account
Definition at line 4215 of file Account.c.
{
if (!acc) return;
xaccAccountBeginEdit (acc);
kvp_frame_set_string(acc->inst.kvp_data, "last-num", num);
mark_account (acc);
xaccAccountCommitEdit (acc);
}
| void xaccAccountSetName | ( | Account * | account, |
| const char * | name | ||
| ) |
Set the account's name
Definition at line 2052 of file Account.c.
{
AccountPrivate *priv;
/* errors */
g_return_if_fail(GNC_IS_ACCOUNT(acc));
g_return_if_fail(str);
/* optimizations */
priv = GET_PRIVATE(acc);
if (safe_strcmp(str, priv->accountName) == 0)
return;
xaccAccountBeginEdit(acc);
CACHE_REPLACE(priv->accountName, str);
mark_account (acc);
xaccAccountCommitEdit(acc);
}
| void xaccAccountSetNonStdSCU | ( | Account * | account, |
| gboolean | flag | ||
| ) |
Set the flag indicating that this account uses a non-standard SCU.
Definition at line 2294 of file Account.c.
{
AccountPrivate *priv;
g_return_if_fail(GNC_IS_ACCOUNT(acc));
priv = GET_PRIVATE(acc);
if (priv->non_standard_scu == flag)
return;
xaccAccountBeginEdit(acc);
priv->non_standard_scu = flag;
mark_account (acc);
xaccAccountCommitEdit(acc);
}
| void xaccAccountSetNotes | ( | Account * | account, |
| const char * | notes | ||
| ) |
Set the account's notes
Definition at line 2191 of file Account.c.
{
g_return_if_fail(GNC_IS_ACCOUNT(acc));
xaccAccountBeginEdit(acc);
if (str)
{
gchar *tmp = g_strstrip(g_strdup(str));
kvp_frame_set_slot_nc(acc->inst.kvp_data, "notes",
strlen(tmp) ? kvp_value_new_string(tmp) : NULL);
g_free(tmp);
}
else
{
kvp_frame_set_slot_nc(acc->inst.kvp_data, "notes", NULL);
}
mark_account(acc);
xaccAccountCommitEdit(acc);
}
| void xaccAccountSetReconcileChildrenStatus | ( | Account * | account, |
| gboolean | status | ||
| ) |
DOCUMENT ME!
Definition at line 4303 of file Account.c.
{
if (!acc) return;
xaccAccountBeginEdit (acc);
/* XXX FIXME: someday this should use KVP_TYPE_BOOLEAN */
kvp_frame_set_gint64 (acc->inst.kvp_data,
"/reconcile-info/include-children", status);
mark_account(acc);
xaccAccountCommitEdit (acc);
}
| void xaccAccountSetSortOrder | ( | Account * | account, |
| const char * | sortorder | ||
| ) |
Set the account's Sort Order
Definition at line 2152 of file Account.c.
{
g_return_if_fail(GNC_IS_ACCOUNT(acc));
xaccAccountBeginEdit(acc);
if (str)
{
gchar *tmp = g_strstrip(g_strdup(str));
kvp_frame_set_slot_nc(acc->inst.kvp_data, "sort-order",
strlen(tmp) ? kvp_value_new_string(tmp) : NULL);
g_free(tmp);
}
else
{
kvp_frame_set_slot_nc(acc->inst.kvp_data, "sort-order", NULL);
}
mark_account (acc);
xaccAccountCommitEdit(acc);
}
| void xaccAccountSetType | ( | Account * | account, |
| GNCAccountType | |||
| ) |
Set the account's type
Definition at line 2031 of file Account.c.
{
AccountPrivate *priv;
/* errors */
g_return_if_fail(GNC_IS_ACCOUNT(acc));
g_return_if_fail(tip < NUM_ACCOUNT_TYPES);
/* optimizations */
priv = GET_PRIVATE(acc);
if (priv->type == tip)
return;
xaccAccountBeginEdit(acc);
priv->type = tip;
priv->balance_dirty = TRUE; /* new type may affect balance computation */
mark_account(acc);
xaccAccountCommitEdit(acc);
}
| 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 1601 of file Account.c.
{
AccountPrivate *priv;
g_return_if_fail(GNC_IS_ACCOUNT(acc));
priv = GET_PRIVATE(acc);
if (!priv->sort_dirty || (!force && qof_instance_get_editlevel(acc) > 0))
return;
priv->splits = g_list_sort(priv->splits, (GCompareFunc)xaccSplitOrder);
priv->sort_dirty = FALSE;
priv->balance_dirty = TRUE;
}
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 954 of file Account.c.
{
Account *ret;
AccountPrivate *from_priv, *priv;
g_return_val_if_fail(GNC_IS_ACCOUNT(from), NULL);
g_return_val_if_fail(QOF_IS_BOOK(book), NULL);
ENTER (" ");
ret = g_object_new (GNC_TYPE_ACCOUNT, NULL);
g_return_val_if_fail (ret, NULL);
from_priv = GET_PRIVATE(from);
priv = GET_PRIVATE(ret);
xaccInitAccount (ret, book);
/* Do not Begin/CommitEdit() here; give the caller
* a chance to fix things up, and let them do it.
* Also let caller issue the generate_event (EVENT_CREATE) */
priv->type = from_priv->type;
priv->accountName = CACHE_INSERT(from_priv->accountName);
priv->accountCode = CACHE_INSERT(from_priv->accountCode);
priv->description = CACHE_INSERT(from_priv->description);
kvp_frame_delete(ret->inst.kvp_data);
ret->inst.kvp_data = kvp_frame_copy(from->inst.kvp_data);
/* The new book should contain a commodity that matches
* the one in the old book. Find it, use it. */
priv->commodity = gnc_commodity_obtain_twin(from_priv->commodity, book);
gnc_commodity_increment_usage_count(priv->commodity);
priv->commodity_scu = from_priv->commodity_scu;
priv->non_standard_scu = from_priv->non_standard_scu;
qof_instance_set_dirty(&ret->inst);
LEAVE (" ");
return ret;
}
1.7.4