GnuCash
2.6.99
|
Files | |
file | Split.h |
API for Transactions and Splits (journal entries) | |
file | Transaction.h |
API for Transactions and Splits (journal entries) | |
Macros | |
#define | GNC_TYPE_SPLIT (gnc_split_get_type ()) |
#define | GNC_SPLIT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_SPLIT, Split)) |
#define | GNC_SPLIT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_SPLIT, SplitClass)) |
#define | GNC_IS_SPLIT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_SPLIT)) |
#define | GNC_IS_SPLIT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_SPLIT)) |
#define | GNC_SPLIT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_SPLIT, SplitClass)) |
#define | xaccSplitGetGUID(X) qof_entity_get_guid(QOF_INSTANCE(X)) |
#define | xaccSplitReturnGUID(X) (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null())) |
#define | GNC_TYPE_TRANSACTION (gnc_transaction_get_type ()) |
#define | GNC_TRANSACTION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_TRANSACTION, Transaction)) |
#define | GNC_TRANSACTION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_TRANSACTION, TransactionClass)) |
#define | GNC_IS_TRANSACTION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_TRANSACTION)) |
#define | GNC_IS_TRANSACTION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_TRANSACTION)) |
#define | GNC_TRANSACTION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_TRANSACTION, TransactionClass)) |
#define | GNC_IS_TRANS(obj) GNC_IS_TRANSACTION(obj) |
#define | GNC_TRANS(obj) GNC_TRANSACTION(obj) |
#define | RECONCILED_MATCH_TYPE "reconciled-match" |
#define | xaccTransGetBook(X) qof_instance_get_book (QOF_INSTANCE(X)) |
#define | xaccTransGetGUID(X) qof_entity_get_guid(QOF_INSTANCE(X)) |
#define | xaccTransReturnGUID(X) (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null())) |
Typedefs | |
typedef struct _SplitClass | SplitClass |
typedef struct _TransactionClass | TransactionClass |
Functions | |
GType | gnc_split_get_type (void) |
gnc_numeric | xaccSplitConvertAmount (const Split *split, const Account *account) |
GType | gnc_transaction_get_type (void) |
Split Reconciled field values | |
If you change these be sure to change gnc-ui-util.c:gnc_get_reconciled_str() and associated functions | |
#define | CREC 'c' |
#define | YREC 'y' |
#define | FREC 'f' |
#define | NREC 'n' |
#define | VREC 'v' |
Split general getters/setters | |
Split * | xaccMallocSplit (QofBook *book) |
void | xaccSplitReinit (Split *split) |
gboolean | xaccSplitDestroy (Split *split) |
void | xaccSplitCopyOnto (const Split *from_split, Split *to_split) |
QofBook * | xaccSplitGetBook (const Split *split) |
Account * | xaccSplitGetAccount (const Split *split) |
void | xaccSplitSetAccount (Split *s, Account *acc) |
Transaction * | xaccSplitGetParent (const Split *split) |
void | xaccSplitSetParent (Split *split, Transaction *trans) |
GNCLot * | xaccSplitGetLot (const Split *split) |
void | xaccSplitSetLot (Split *split, GNCLot *lot) |
void | xaccSplitSetMemo (Split *split, const char *memo) |
const char * | xaccSplitGetMemo (const Split *split) |
void | xaccSplitSetAction (Split *split, const char *action) |
const char * | xaccSplitGetAction (const Split *split) |
Split Date getters/setters | |
void | xaccSplitSetReconcile (Split *split, char reconciled_flag) |
char | xaccSplitGetReconcile (const Split *split) |
void | xaccSplitSetDateReconciledSecs (Split *split, time64 time) |
void | xaccSplitSetDateReconciledTS (Split *split, Timespec *ts) |
void | xaccSplitGetDateReconciledTS (const Split *split, Timespec *ts) |
Timespec | xaccSplitRetDateReconciledTS (const Split *split) |
time64 | xaccSplitGetDateReconciled (const Split *split) |
Split amount getters/setters | |
'value' vs. 'amount' of a Split: The 'value' is the amount of the transaction balancing commodity (i.e. currency) involved, 'amount' is the amount of the account's commodity involved. | |
void | xaccSplitSetAmount (Split *split, gnc_numeric amount) |
gnc_numeric | xaccSplitGetAmount (const Split *split) |
void | xaccSplitSetValue (Split *split, gnc_numeric value) |
gnc_numeric | xaccSplitGetValue (const Split *split) |
void | xaccSplitSetSharePriceAndAmount (Split *split, gnc_numeric price, gnc_numeric amount) |
gnc_numeric | xaccSplitGetSharePrice (const Split *split) |
void | xaccSplitSetBaseValue (Split *split, gnc_numeric value, const gnc_commodity *base_currency) |
gnc_numeric | xaccSplitGetBaseValue (const Split *split, const gnc_commodity *base_currency) |
gnc_numeric | xaccSplitGetBalance (const Split *split) |
gnc_numeric | xaccSplitGetClearedBalance (const Split *split) |
gnc_numeric | xaccSplitGetReconciledBalance (const Split *split) |
Split utility functions | |
gboolean | xaccSplitEqual (const Split *sa, const Split *sb, gboolean check_guids, gboolean check_balances, gboolean check_txn_splits) |
Split * | xaccSplitLookup (const GncGUID *guid, QofBook *book) |
GList * | xaccSplitListGetUniqueTransactions (const GList *splits) |
Split * | xaccSplitGetOtherSplit (const Split *split) |
const char * | xaccSplitGetType (const Split *s) |
void | xaccSplitMakeStockSplit (Split *s) |
gint | xaccSplitOrder (const Split *sa, const Split *sb) |
gint | xaccSplitOrderDateOnly (const Split *sa, const Split *sb) |
int | xaccSplitCompareAccountFullNames (const Split *sa, const Split *sb) |
int | xaccSplitCompareAccountCodes (const Split *sa, const Split *sb) |
int | xaccSplitCompareOtherAccountFullNames (const Split *sa, const Split *sb) |
int | xaccSplitCompareOtherAccountCodes (const Split *sa, const Split *sb) |
char * | xaccSplitGetCorrAccountFullName (const Split *sa) |
const char * | xaccSplitGetCorrAccountName (const Split *sa) |
const char * | xaccSplitGetCorrAccountCode (const Split *sa) |
#define | xaccSplitLookupDirect(g, b) xaccSplitLookup(&(g),b) |
Split deprecated functions | |
void | xaccSplitSetSharePrice (Split *split, gnc_numeric price) |
Split voiding | |
gnc_numeric | xaccSplitVoidFormerAmount (const Split *split) |
gnc_numeric | xaccSplitVoidFormerValue (const Split *split) |
Split Parameter names | |
Note, if you want to get the equivalent of "ACCT_MATCH_ALL" you need to create a search on the following parameter list: SPLIT->SPLIT_TRANS->TRANS_SPLITLIST->SPLIT_ACCOUNT_GUID. If you do this, you might want to use the ACCOUNT_MATCH_ALL_TYPE as the override so the gnome-search dialog displays the right type. | |
#define | SPLIT_KVP "kvp" |
#define | SPLIT_DATE_RECONCILED "date-reconciled" |
#define | SPLIT_BALANCE "balance" |
#define | SPLIT_CLEARED_BALANCE "cleared-balance" |
#define | SPLIT_RECONCILED_BALANCE "reconciled-balance" |
#define | SPLIT_MEMO "memo" |
#define | SPLIT_ACTION "action" |
#define | SPLIT_RECONCILE "reconcile-flag" |
#define | SPLIT_AMOUNT "amount" |
#define | SPLIT_SHARE_PRICE "share-price" |
#define | SPLIT_VALUE "value" |
#define | SPLIT_TYPE "type" |
#define | SPLIT_VOIDED_AMOUNT "voided-amount" |
#define | SPLIT_VOIDED_VALUE "voided-value" |
#define | SPLIT_LOT "lot" |
#define | SPLIT_TRANS "trans" |
#define | SPLIT_ACCOUNT "account" |
#define | SPLIT_ACCOUNT_GUID "account-guid" |
#define | SPLIT_ACCT_FULLNAME "acct-fullname" |
#define | SPLIT_CORR_ACCT_NAME "corr-acct-fullname" |
#define | SPLIT_CORR_ACCT_CODE "corr-acct-code" |
Transaction Type field values | |
#define | TXN_TYPE_NONE '\0' |
#define | TXN_TYPE_INVOICE 'I' |
#define | TXN_TYPE_PAYMENT 'P' |
#define | TXN_TYPE_LINK 'L' |
Transaction creation and editing | |
Transaction * | xaccMallocTransaction (QofBook *book) |
void | xaccTransDestroy (Transaction *trans) |
Transaction * | xaccTransClone (const Transaction *t) |
Transaction * | xaccTransCloneNoKvp (const Transaction *t) |
gboolean | xaccTransEqual (const Transaction *ta, const Transaction *tb, gboolean check_guids, gboolean check_splits, gboolean check_balances, gboolean assume_ordered) |
void | xaccTransBeginEdit (Transaction *trans) |
void | xaccTransCommitEdit (Transaction *trans) |
void | xaccTransRollbackEdit (Transaction *trans) |
gboolean | xaccTransIsOpen (const Transaction *trans) |
Transaction * | xaccTransLookup (const GncGUID *guid, QofBook *book) |
Transaction * | xaccTransCopyToClipBoard (const Transaction *from_trans) |
void | xaccTransCopyOnto (const Transaction *from_trans, Transaction *to_trans) |
void | xaccTransCopyFromClipBoard (const Transaction *from_trans, Transaction *to_trans, const Account *from_acc, Account *to_acc, gboolean no_date) |
Split * | xaccTransFindSplitByAccount (const Transaction *trans, const Account *acc) |
void | xaccTransScrubGains (Transaction *trans, Account *gain_acc) |
guint | gnc_book_count_transactions (QofBook *book) |
#define | xaccTransLookupDirect(g, b) xaccTransLookup(&(g),b) |
Transaction voiding | |
void | xaccTransVoid (Transaction *transaction, const char *reason) |
void | xaccTransUnvoid (Transaction *transaction) |
Transaction * | xaccTransReverse (Transaction *transaction) |
Transaction * | xaccTransGetReversedBy (const Transaction *trans) |
gboolean | xaccTransGetVoidStatus (const Transaction *transaction) |
const char * | xaccTransGetVoidReason (const Transaction *transaction) |
Timespec | xaccTransGetVoidTime (const Transaction *tr) |
A good overview of transactions, splits and accounts can be found in the texinfo documentation, together with an overview of how to use this API.
A good overview of transactions, splits and accounts can be found in the texinfo documentation, together with an overview of how to use this API.
Splits, or "Ledger Entries" are the fundamental accounting units. Each Split consists of an amount (number of dollar bills, number of shares, etc.), the value of that amount expressed in a (possibly) different currency than the amount, a Memo, a pointer to the parent Transaction, a pointer to the debited Account, a reconciled flag and timestamp, an "Action" field, and a key-value frame which can store arbitrary data.
Transactions embody the notion of "double entry" accounting. A Transaction consists of a date, a description, an ID number, a list of one or more Splits, and a key-value frame. The transaction also specifies the currency with which all of the splits will be valued. When double-entry rules are enforced, the sum total value of the splits are zero. If there are only two splits, then the value of one must be positive, the other negative: this denotes that one account is debited, and another is credited by an equal amount. By forcing the value of the splits to always 'add up' to zero, we can guarantee that the balances of the accounts are always correctly balanced.
The engine does not enforce double-entry accounting, but provides an API to enable user-code to find unbalanced transactions and 'repair' them so that they are in balance.
Note the sum of the values of Splits in a Transaction is always computed with respect to a currency; thus splits can be balanced even when they are in different currencies, as long as they share a common currency. This feature allows currency-trading accounts to be established.
Every Split must point to its parent Transaction, and that Transaction must in turn include that Split in the Transaction's list of Splits. A Split can belong to at most one Transaction. These relationships are enforced by the engine. The engine user cannnot accidentally destroy this relationship as long as they stick to using the API and never access internal structures directly.
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 tradable: 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. The nodes of the tree are called "Account Groups". 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 SPLIT_ACCOUNT_GUID "account-guid" |
#define TXN_TYPE_INVOICE 'I' |
Transaction is an invoice
Definition at line 120 of file Transaction.h.
#define TXN_TYPE_LINK 'L' |
Transaction is a link between (invoice and payment) lots
Definition at line 122 of file Transaction.h.
#define TXN_TYPE_NONE '\0' |
No transaction type
Definition at line 119 of file Transaction.h.
#define TXN_TYPE_PAYMENT 'P' |
Transaction is a payment
Definition at line 121 of file Transaction.h.
#define xaccSplitGetGUID | ( | X | ) | qof_entity_get_guid(QOF_INSTANCE(X)) |
#define xaccSplitReturnGUID | ( | X | ) | (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null())) |
#define xaccTransAppendSplit | ( | t, | |
s | |||
) | xaccSplitSetParent((s), (t)) |
Add a split to the transaction
The xaccTransAppendSplit() method will append the indicated split to the collection of splits in this transaction.
Definition at line 357 of file Transaction.h.
#define xaccTransGetBook | ( | X | ) | qof_instance_get_book (QOF_INSTANCE(X)) |
Definition at line 753 of file Transaction.h.
#define xaccTransGetGUID | ( | X | ) | qof_entity_get_guid(QOF_INSTANCE(X)) |
Definition at line 755 of file Transaction.h.
#define xaccTransReturnGUID | ( | X | ) | (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null())) |
Definition at line 757 of file Transaction.h.
guint gnc_book_count_transactions | ( | QofBook * | book | ) |
Definition at line 2483 of file Transaction.c.
Transaction* xaccMallocTransaction | ( | QofBook * | book | ) |
The xaccMallocTransaction() will malloc memory and initialize it. Once created, it is usually unsafe to merely "free" this memory; the xaccTransDestroy() method should be called.
Definition at line 513 of file Transaction.c.
Compare two splits by full name of account. Returns similar to strcmp.
Definition at line 1698 of file Split.c.
Compare two splits by code of the other account. Returns similar to strcmp. This function attempts to find the split on the other side of a transaction and compare on it.
Definition at line 1754 of file Split.c.
Compare two splits by full name of the other account. Returns similar to strcmp. This function attempts to find the split on the other side of a transaction and compare on it.
Definition at line 1733 of file Split.c.
This is really a helper for xaccTransCopyOnto. It doesn't reparent the 'to' split to from's transaction, because xaccTransCopyOnto is responsible for parenting the split to the correct transaction. Also, from's parent transaction may not even be a valid transaction, so this function may not modify anything about 'from' or from's transaction.
Definition at line 686 of file Split.c.
gboolean xaccSplitDestroy | ( | Split * | split | ) |
Destructor.
The xaccSplitDestroy() method will update its parent account and transaction in a consistent manner, resulting in the complete unlinking of the split, and the freeing of its associated memory. The goal of this routine is to perform the removal and destruction of the split in an atomic fashion, with no chance of accidentally leaving the accounting structure out-of-balance or otherwise inconsistent.
If the deletion of the split leaves the transaction with no splits, then the transaction will be marked for deletion. (It will not be deleted until the xaccTransCommitEdit() routine is called.)
Definition at line 1492 of file Split.c.
gboolean xaccSplitEqual | ( | const Split * | sa, |
const Split * | sb, | ||
gboolean | check_guids, | ||
gboolean | check_balances, | ||
gboolean | check_txn_splits | ||
) |
Equality.
sa | First split to compare |
sb | Second split to compare |
check_guids | If TRUE, try a guid_equal() on the GUIDs of both splits if their pointers are not equal in the first place. |
check_balances | If TRUE, compare balances between the two splits. Balances are recalculated whenever a split is added or removed from an account, so YMMV on whether this should be set. |
check_txn_splits | If the pointers are not equal, but everything else so far is equal (including memo, amount, value, kvp_frame), then, when comparing the parenting transactions with xaccTransEqual(), set its argument check_splits to be TRUE. |
Definition at line 815 of file Split.c.
Returns the account of this split, which was set through xaccAccountInsertSplit().
const char* xaccSplitGetAction | ( | const Split * | split | ) |
Returns the action string. Rather than use this function directly, see 'gnc_get_num_action' and 'gnc_get_action_num'in engine/engine-helpers.c & .h which takes a user-set book option for selecting the source for the num-cell (the transaction-number or the split-action field) in registers/reports into account automatically
gnc_numeric xaccSplitGetAmount | ( | const Split * | split | ) |
gnc_numeric xaccSplitGetBalance | ( | const Split * | split | ) |
Returns the running balance up to and including the indicated split. The balance is the currency-denominated balance. For accounts with non-unit share prices, it is correctly adjusted for share prices.
Returns the running balance up to & including the indicated split.
gnc_numeric xaccSplitGetBaseValue | ( | const Split * | split, |
const gnc_commodity * | base_currency | ||
) |
Depending on the base_currency, return either the value or the amount of this split: If the base_curreny is the transaction's commodity, return the value. If it is the account's commodity, return the amount. If it is neither print a warning message and return gnc_numeric_zero().
Definition at line 1396 of file Split.c.
gnc_numeric xaccSplitGetClearedBalance | ( | const Split * | split | ) |
The cleared-balance is the currency-denominated balance of all transactions that have been marked as cleared or reconciled. It is correctly adjusted for price fluctuations.
Returns the running balance up to & including the indicated split.
const char* xaccSplitGetCorrAccountCode | ( | const Split * | sa | ) |
document me
Definition at line 1680 of file Split.c.
char* xaccSplitGetCorrAccountFullName | ( | const Split * | sa | ) |
These functions take a split, get the corresponding split on the "other side" of the transaction, and extract either the name or code of that split, reverting to returning a constant "Split" if the transaction has more than one split on the "other side". These were added for the transaction report, and is in C because the code was already written in C for the above functions and duplication is silly.
Definition at line 1664 of file Split.c.
const char* xaccSplitGetCorrAccountName | ( | const Split * | sa | ) |
const char* xaccSplitGetMemo | ( | const Split * | split | ) |
The xaccSplitGetOtherSplit() is a convenience routine that returns the other of a pair of splits. If there are more than two splits, it returns NULL.
Definition at line 2086 of file Split.c.
Transaction* xaccSplitGetParent | ( | const Split * | split | ) |
char xaccSplitGetReconcile | ( | const Split * | split | ) |
gnc_numeric xaccSplitGetReconciledBalance | ( | const Split * | split | ) |
Returns the reconciled-balance of this split. The reconciled-balance is the currency-denominated balance of all transactions that have been marked as reconciled.
Returns the running balance up to & including the indicated split.
gnc_numeric xaccSplitGetSharePrice | ( | const Split * | split | ) |
Returns the price of the split, that is, the value divided by the amount. If the amount is zero, returns a gnc_numeric of value one.
Definition at line 1999 of file Split.c.
const char* xaccSplitGetType | ( | const Split * | s | ) |
The xaccIsPeerSplit() is a convenience routine that returns TRUE (a non-zero value) if the two splits share a common parent transaction, else it returns FALSE (zero).
gboolean xaccIsPeerSplit (const Split *split_1, const Split *split_2); Returns the split type, which is either the string "normal", or "stock-split" for a split from a stock split (pun intended? :-).
gnc_numeric xaccSplitGetValue | ( | const Split * | split | ) |
The xaccSplitLookup() subroutine will return the split associated with the given id, or NULL if there is no such split.
Definition at line 1104 of file Split.c.
void xaccSplitMakeStockSplit | ( | Split * | s | ) |
The xaccSplitOrder(sa,sb) method is useful for sorting. if sa and sb have different transactions, return their xaccTransOrder return a negative value if split sa has a smaller currency-value than sb, return a positive value if split sa has a larger currency-value than sb, return a negative value if split sa has a smaller share-price than sb, return a positive value if split sa has a larger share-price than sb, then compares memo and action using the strcmp() c-library routine, returning what strcmp would return. Then it compares the reconciled flags, then the reconciled dates, Finally, it returns zero if all of the above match.
Definition at line 1521 of file Split.c.
void xaccSplitSetAction | ( | Split * | split, |
const char * | action | ||
) |
The Action is an arbitrary user-assigned string. The action field is an arbitrary user-assigned value. It is meant to be a very short (one to ten character) string that signifies the "type" of this split, such as e.g. Buy, Sell, Div, Withdraw, Deposit, ATM, Check, etc. The idea is that this field can be used to create custom reports or graphs of data. Rather than use this function directly, see 'gnc_set_num_action' in engine/engine-helpers.c & .h which takes a user-set book option for selecting the source for the num-cell (the transaction-number or the split-action field) in registers/reports into account automatically
Definition at line 1793 of file Split.c.
void xaccSplitSetAmount | ( | Split * | split, |
gnc_numeric | amount | ||
) |
The xaccSplitSetAmount() method sets the amount in the account's commodity that the split should have.
The following four setter functions set the prices and amounts. All of the routines always maintain balance: that is, invoking any of them will cause other splits in the transaction to be modified so that the net value of the transaction is zero.
IMPORTANT: The split should be parented by an account before any of these routines are invoked! This is because the actual setting of amounts/values requires SCU settings from the account. If these are not available, then amounts/values will be set to -1/0, which is an invalid value. I believe this order dependency is a bug, but I'm too lazy to find, fix & test at the moment ...
Definition at line 1258 of file Split.c.
void xaccSplitSetBaseValue | ( | Split * | split, |
gnc_numeric | value, | ||
const gnc_commodity * | base_currency | ||
) |
Depending on the base_currency, set either the value or the amount of this split or both: If the base_currency is the transaction's commodity, set the value. If it is the account's commodity, set the amount. If both, set both.
Definition at line 1341 of file Split.c.
void xaccSplitSetMemo | ( | Split * | split, |
const char * | memo | ||
) |
void xaccSplitSetReconcile | ( | Split * | split, |
char | reconciled_flag | ||
) |
Set the reconcile flag. The Reconcile flag is a single char, whose values are typically are 'n', 'y', 'c'. In Transaction.h, macros are defined for typical values (e.g. CREC, YREC).
Definition at line 1826 of file Split.c.
void xaccSplitSetSharePrice | ( | Split * | split, |
gnc_numeric | price | ||
) |
Definition at line 1224 of file Split.c.
void xaccSplitSetSharePriceAndAmount | ( | Split * | split, |
gnc_numeric | price, | ||
gnc_numeric | amount | ||
) |
The xaccSplitSetSharePriceAndAmount() method will simultaneously update the share price and the number of shares. This is a utility routine that is equivalent to a xaccSplitSetSharePrice() followed by and xaccSplitSetAmount(), except that it incurs the processing overhead of balancing only once, instead of twice.
Definition at line 1196 of file Split.c.
void xaccSplitSetValue | ( | Split * | split, |
gnc_numeric | value | ||
) |
The xaccSplitSetValue() method sets the value of this split in the transaction's commodity.
Definition at line 1294 of file Split.c.
gnc_numeric xaccSplitVoidFormerAmount | ( | const Split * | split | ) |
Returns the original pre-void amount of a split.
split | The split in question. |
gnc_numeric xaccSplitVoidFormerValue | ( | const Split * | split | ) |
Returns the original pre-void value of a split.
split | The split in question. |
void xaccTransBeginEdit | ( | Transaction * | trans | ) |
The xaccTransBeginEdit() method must be called before any changes are made to a transaction or any of its component splits. If this is not done, errors will result.
Definition at line 1380 of file Transaction.c.
Transaction* xaccTransClone | ( | const Transaction * | t | ) |
The xaccTransClone() method will create a complete copy of an existing transaction.
Definition at line 679 of file Transaction.c.
Transaction* xaccTransCloneNoKvp | ( | const Transaction * | t | ) |
The xaccTransCloneNoKvp() method will create a complete copy of an existing transaction except that the KVP slots will be empty.
Definition at line 642 of file Transaction.c.
void xaccTransCommitEdit | ( | Transaction * | trans | ) |
The xaccTransCommitEdit() method indicates that the changes to the transaction and its splits are complete and should be made permanent. Note this routine may result in the deletion of the transaction, if the transaction is "empty" (has no splits), or of xaccTransDestroy() was called on the transaction.
Definition at line 1579 of file Transaction.c.
void xaccTransCopyFromClipBoard | ( | const Transaction * | from_trans, |
Transaction * | to_trans, | ||
const Account * | from_acc, | ||
Account * | to_acc, | ||
gboolean | no_date | ||
) |
This function explicitly must robustly handle some unusual input.
'from_trans' may be a duped trans (see xaccDupeTransaction), so its splits may not really belong to the accounts that they say they do.
'from_acc' need not be a valid account. It may be an already freed Account. Therefore, it must not be dereferenced at all.
Neither 'from_trans', nor 'from_acc', nor any of 'from's splits may be modified in any way.
'no_date' if TRUE will not copy the date posted.
The 'to_trans' transaction will end up with valid copies of from's splits. In addition, the copies of any of from's splits that were in from_acc (or at least claimed to be) will end up in to_acc.
Definition at line 742 of file Transaction.c.
void xaccTransCopyOnto | ( | const Transaction * | from_trans, |
Transaction * | to_trans | ||
) |
Copy a transaction to another using the function below without changing any account information.
Definition at line 718 of file Transaction.c.
Transaction* xaccTransCopyToClipBoard | ( | const Transaction * | from_trans | ) |
Copy a transaction to the 'clipboard' transaction using dupe_transaction. The 'clipboard' transaction must never be dereferenced.
Definition at line 702 of file Transaction.c.
int xaccTransCountSplits | ( | const Transaction * | trans | ) |
Returns the number of splits in this transaction.
Definition at line 2170 of file Transaction.c.
void xaccTransDestroy | ( | Transaction * | trans | ) |
Destroys a transaction. Each split in transaction trans is removed from its account and destroyed as well.
If the transaction has not already been opened for editing with xaccTransBeginEdit() then the changes are committed immediately. Otherwise, the caller must follow up with either xaccTransCommitEdit(), in which case the transaction and split memory will be freed, or xaccTransRollbackEdit(), in which case nothing at all is freed, and everything is put back into original order.
trans | the transaction to destroy |
Definition at line 1402 of file Transaction.c.
gboolean xaccTransEqual | ( | const Transaction * | ta, |
const Transaction * | tb, | ||
gboolean | check_guids, | ||
gboolean | check_splits, | ||
gboolean | check_balances, | ||
gboolean | assume_ordered | ||
) |
Equality.
ta | First transaction to compare |
tb | Second transaction to compare |
check_guids | If TRUE, try a guid_equal() on the GUIDs of both transactions if their pointers are not equal in the first place. Also passed to subsidiary calls to xaccSplitEqual. |
check_splits | If TRUE, after checking the transaction data structures for equality, also check all splits attached to the transation for equality. |
check_balances | If TRUE, when checking splits also compare balances between the two splits. Balances are recalculated whenever a split is added or removed from an account, so YMMV on whether this should be set. |
assume_ordered | If TRUE, assume that the splits in each transaction appear in the same order. This saves some time looking up splits by GncGUID, and is required for checking duplicated transactions because all the splits have new GUIDs. |
Definition at line 857 of file Transaction.c.
gnc_numeric xaccTransGetAccountAmount | ( | const Transaction * | trans, |
const Account * | account | ||
) |
Same as xaccTransGetAccountValue, but uses the Account's commodity.
Definition at line 1186 of file Transaction.c.
gnc_numeric xaccTransGetAccountBalance | ( | const Transaction * | trans, |
const Account * | account | ||
) |
Get the account balance for the specified account after the last split in the specified transaction.
Definition at line 1310 of file Transaction.c.
gnc_numeric xaccTransGetAccountValue | ( | const Transaction * | trans, |
const Account * | account | ||
) |
The xaccTransGetAccountValue() method returns the total value applied to a particular account. In some cases there may be multiple Splits in a single Transaction applied to one account (in particular when trying to balance Lots) – this function is just a convienience to view everything at once.
Definition at line 1170 of file Transaction.c.
const char* xaccTransGetAssociation | ( | const Transaction * | trans | ) |
Gets the transaction association
Definition at line 2190 of file Transaction.c.
gnc_commodity* xaccTransGetCurrency | ( | const Transaction * | trans | ) |
Returns the valuation commodity of this transaction.
Each transaction's valuation commodity, or 'currency' is, by definition, the common currency in which all splits in the transaction can be valued. The total value of the transaction must be zero when all splits are valued in this currency.
Definition at line 1348 of file Transaction.c.
time64 xaccTransGetDate | ( | const Transaction * | trans | ) |
Retrieve the posted date of the transaction. The posted date is the date when this transaction was posted at the bank. (Although having different function names, GetDate and GetDatePosted refer to the same single date.)
Definition at line 2215 of file Transaction.c.
void xaccTransGetDateDueTS | ( | const Transaction * | trans, |
Timespec * | ts | ||
) |
Dates and txn-type for A/R and A/P "invoice" postings
Definition at line 2280 of file Transaction.c.
time64 xaccTransGetDateEntered | ( | const Transaction * | trans | ) |
Retrieve the date of when the transaction was entered. The entered date is the date when the register entry was made.
Definition at line 2222 of file Transaction.c.
void xaccTransGetDateEnteredTS | ( | const Transaction * | trans, |
Timespec * | ts | ||
) |
Retrieve the date of when the transaction was entered. The entered date is the date when the register entry was made.
Definition at line 2236 of file Transaction.c.
GDate xaccTransGetDatePostedGDate | ( | const Transaction * | trans | ) |
Retrieve the posted date of the transaction. The posted date is the date when this transaction was posted at the bank.
Definition at line 2250 of file Transaction.c.
void xaccTransGetDatePostedTS | ( | const Transaction * | trans, |
Timespec * | ts | ||
) |
Retrieve the posted date of the transaction. The posted date is the date when this transaction was posted at the bank. (Although having different function names, GetDate and GetDatePosted refer to the same single date.)
Definition at line 2229 of file Transaction.c.
const char* xaccTransGetDescription | ( | const Transaction * | trans | ) |
Gets the transaction Description
Definition at line 2184 of file Transaction.c.
MonetaryList* xaccTransGetImbalance | ( | const Transaction * | trans | ) |
The xaccTransGetImbalance method returns a list giving the value of the transaction in each currency for which the balance is not zero. If the use of currency accounts is disabled, then this will be only the common currency for the transaction and xaccTransGetImbalance becomes equivalent to xaccTransGetImbalanceValue. Otherwise it will return a list containing the imbalance in each currency.
Definition at line 1052 of file Transaction.c.
gnc_numeric xaccTransGetImbalanceValue | ( | const Transaction * | trans | ) |
The xaccTransGetImbalanceValue() method returns the total value of the transaction. In a pure double-entry system, this imbalance should be exactly zero, and if it is not, something is broken. However, when double-entry semantics are not enforced, unbalanced transactions can sneak in, and this routine can be used to find out how much things are off by. The value returned is denominated in the currency that is returned by the xaccTransFindCommonCurrency() method.
If the use of currency exchange accounts is enabled then the a a transaction must be balanced in each currency it uses to be considered to be balanced. The method xaccTransGetImbalance is used by most code to take this into consideration. This method is only used in a few places that want the transaction value even if currency exchange accounts are enabled.
Definition at line 1036 of file Transaction.c.
gboolean xaccTransGetIsClosingTxn | ( | const Transaction * | trans | ) |
Returns whether this transaction is a "closing transaction"
Definition at line 2204 of file Transaction.c.
const char* xaccTransGetNotes | ( | const Transaction * | trans | ) |
Gets the transaction Notes
The Notes field is only visible in the register in double-line mode
Definition at line 2197 of file Transaction.c.
const char* xaccTransGetNum | ( | const Transaction * | trans | ) |
Gets the transaction Number (or ID) field; rather than use this function directly, see 'gnc_get_num_action' and 'gnc_get_action_num' in engine/engine-helpers.c & .h which takes a user-set book option for selecting the source for the num-cell (the transaction-number or the split-action field) in registers/reports into account automatically
Definition at line 2178 of file Transaction.c.
const char* xaccTransGetReadOnly | ( | const Transaction * | trans | ) |
Returns a non-NULL value if this Transaction was marked as read-only with some specific "reason" text.
Definition at line 2313 of file Transaction.c.
Transaction* xaccTransGetReversedBy | ( | const Transaction * | trans | ) |
Returns the transaction that reversed the given transaction.
trans | a Transaction that has been reversed |
Definition at line 2606 of file Transaction.c.
Split* xaccTransGetSplit | ( | const Transaction * | trans, |
int | i | ||
) |
The xaccTransGetSplit() method returns a pointer to each of the splits in this transaction.
trans | The transaction |
i | The split number. Valid values for i are zero to (number_of__splits-1). An invalid value of i will cause NULL to be returned. A convenient way of cycling through all splits is to start at zero, and keep incrementing until a null value is returned. |
Definition at line 2144 of file Transaction.c.
int xaccTransGetSplitIndex | ( | const Transaction * | trans, |
const Split * | split | ||
) |
Inverse of xaccTransGetSplit()
Definition at line 2154 of file Transaction.c.
SplitList* xaccTransGetSplitList | ( | const Transaction * | trans | ) |
The xaccTransGetSplitList() method returns a GList of the splits in a transaction.
Definition at line 2164 of file Transaction.c.
char xaccTransGetTxnType | ( | const Transaction * | trans | ) |
Returns the Transaction Type
See TXN_TYPE_NONE, TXN_TYPE_INVOICE and TXN_TYPE_PAYMENT
Definition at line 2302 of file Transaction.c.
const char* xaccTransGetVoidReason | ( | const Transaction * | transaction | ) |
Returns the user supplied textual reason why a transaction was voided.
transaction | The transaction in question. |
Definition at line 2533 of file Transaction.c.
gboolean xaccTransGetVoidStatus | ( | const Transaction * | transaction | ) |
Retrieve information on whether or not a transaction has been voided.
transaction | The transaction in question. |
Definition at line 2526 of file Transaction.c.
Timespec xaccTransGetVoidTime | ( | const Transaction * | tr | ) |
Returns the time that a transaction was voided.
tr | The transaction in question. |
Definition at line 2540 of file Transaction.c.
gboolean xaccTransHasReconciledSplits | ( | const Transaction * | trans | ) |
FIXME: document me
Definition at line 2433 of file Transaction.c.
gboolean xaccTransHasReconciledSplitsByAccount | ( | const Transaction * | trans, |
const Account * | account | ||
) |
FIXME: document me
Definition at line 2404 of file Transaction.c.
gboolean xaccTransHasSplitsInState | ( | const Transaction * | trans, |
const char | state | ||
) |
FIXME: document me
Definition at line 2463 of file Transaction.c.
gboolean xaccTransHasSplitsInStateByAccount | ( | const Transaction * | trans, |
const char | state, | ||
const Account * | account | ||
) |
FIXME: document me
Definition at line 2440 of file Transaction.c.
gboolean xaccTransInFutureByPostedDate | ( | const Transaction * | trans | ) |
Returns TRUE if this Transaction's posted-date is in the future
Definition at line 2385 of file Transaction.c.
gboolean xaccTransIsBalanced | ( | const Transaction * | trans | ) |
Returns true if the transaction is balanced according to the rules currently in effect.
Definition at line 1124 of file Transaction.c.
gboolean xaccTransIsOpen | ( | const Transaction * | trans | ) |
The xaccTransIsOpen() method returns TRUE if the transaction is open for editing. Otherwise, it returns false. XXX this routine should probably be deprecated. its, umm, hard to imagine legitimate uses (but it is used by the import/export code for reasons I can't understand.)
Definition at line 1819 of file Transaction.c.
gboolean xaccTransIsReadonlyByPostedDate | ( | const Transaction * | trans | ) |
Returns TRUE if this Transaction is read-only because its posted-date is older than the "auto-readonly" threshold of this book. See qof_book_uses_autofreeze() and qof_book_get_autofreeze_gdate().
Definition at line 2345 of file Transaction.c.
Transaction* xaccTransLookup | ( | const GncGUID * | guid, |
QofBook * | book | ||
) |
The xaccTransLookup() subroutine will return the transaction associated with the given id, or NULL if there is no such transaction.
Definition at line 1024 of file Transaction.c.
int xaccTransOrder | ( | const Transaction * | ta, |
const Transaction * | tb | ||
) |
The xaccTransOrder(ta,tb) method is useful for sorting. Orders ta and tb return <0 if ta sorts before tb return >0 if ta sorts after tb return 0 if they are absolutely equal
The comparrison uses the following fields, in order: date posted (compare as a date) num field (compare as an integer) date entered (compare as a date) description field (comcpare as a string using strcmp()) GncGUID (compare as a guid) Finally, it returns zero if all of the above match. Note that it does NOT compare its member splits. Note also that it calls xaccTransOrder_num_action with actna and actnb set as NULL.
Definition at line 1827 of file Transaction.c.
int xaccTransOrder_num_action | ( | const Transaction * | ta, |
const char * | actna, | ||
const Transaction * | tb, | ||
const char * | actnb | ||
) |
The xaccTransOrder_num_action(ta,actna,tb,actnb) method is useful for sorting. Orders ta and tb return <0 if ta sorts before tb return >0 if ta sorts after tb return 0 if they are absolutely equal
The comparrison uses the following fields, in order: date posted (compare as a date) if actna and actnb are NULL, num field (compare as an integer) else actna and actnb (compare as an integer) date entered (compare as a date) description field (comcpare as a string using strcmp()) GncGUID (compare as a guid) Finally, it returns zero if all of the above match. Note that it does NOT compare its member splits (except action as specified above).
Definition at line 1833 of file Transaction.c.
Timespec xaccTransRetDateDueTS | ( | const Transaction * | trans | ) |
Dates and txn-type for A/R and A/P "invoice" postings
Definition at line 2294 of file Transaction.c.
Timespec xaccTransRetDateEnteredTS | ( | const Transaction * | trans | ) |
Retrieve the date of when the transaction was entered. The entered date is the date when the register entry was made.
Definition at line 2273 of file Transaction.c.
Timespec xaccTransRetDatePostedTS | ( | const Transaction * | trans | ) |
Retrieve the posted date of the transaction. The posted date is the date when this transaction was posted at the bank. (Although having different function names, GetDate and GetDatePosted refer to the same single date.)
Definition at line 2243 of file Transaction.c.
Transaction* xaccTransReverse | ( | Transaction * | transaction | ) |
xaccTransReverse creates a Transaction that reverses the given tranaction by inverting all the numerical values in the given transaction. This function cancels out the effect of an earlier transaction. This will be needed by write only accounts as a way to void a previous transaction (since you can't alter the existing transaction).
transaction | The transaction to create a reverse of. |
Definition at line 2579 of file Transaction.c.
void xaccTransRollbackEdit | ( | Transaction * | trans | ) |
The xaccTransRollbackEdit() routine rejects all edits made, and sets the transaction back to where it was before the editing started. This includes restoring any deleted splits, removing any added splits, and undoing the effects of xaccTransDestroy, as well as restoring share quantities, memos, descriptions, etc.
Definition at line 1661 of file Transaction.c.
void xaccTransScrubGains | ( | Transaction * | trans, |
Account * | gain_acc | ||
) |
The xaccTransScrubGains() routine performs a number of cleanup functions on the indicated transaction, with the end-goal of setting up a consistent set of gains/losses for all the splits in the transaction. This includes making sure that the lot assignments of all the splits are good, and that the lots balance appropriately.
Definition at line 2678 of file Transaction.c.
void xaccTransSetAssociation | ( | Transaction * | trans, |
const char * | assoc | ||
) |
Sets the transaction Association
Definition at line 2096 of file Transaction.c.
void xaccTransSetCurrency | ( | Transaction * | trans, |
gnc_commodity * | curr | ||
) |
Set the commodity of this transaction.
Definition at line 1354 of file Transaction.c.
void xaccTransSetDate | ( | Transaction * | trans, |
int | day, | ||
int | mon, | ||
int | year | ||
) |
The xaccTransSetDate() method does the same thing as xaccTransSetDate[Posted]Secs(), but takes a convenient day-month-year format.
(Footnote: this shouldn't matter to a user, but anyone modifying the engine should understand that when xaccTransCommitEdit() is called, the date order of each of the component splits will be checked, and will be restored in ascending date order.)
Definition at line 1995 of file Transaction.c.
void xaccTransSetDateDueTS | ( | Transaction * | trans, |
const Timespec * | ts | ||
) |
Dates and txn-type for A/R and A/P "invoice" postings
Definition at line 2006 of file Transaction.c.
void xaccTransSetDateEnteredSecs | ( | Transaction * | trans, |
time64 | time | ||
) |
Modify the date of when the transaction was entered. The entered date is the date when the register entry was made.
Definition at line 1951 of file Transaction.c.
void xaccTransSetDateEnteredTS | ( | Transaction * | trans, |
const Timespec * | ts | ||
) |
Modify the date of when the transaction was entered. The entered date is the date when the register entry was made.
Definition at line 1988 of file Transaction.c.
void xaccTransSetDatePostedGDate | ( | Transaction * | trans, |
GDate | date | ||
) |
This method modifies posted date of the transaction, specified by a GDate. The posted date is the date when this transaction was posted at the bank.
This is identical to xaccTransSetDate(), but different from xaccTransSetDatePostedSecs which artificially introduces the time-of-day part, which needs to be ignored.
Definition at line 1928 of file Transaction.c.
void xaccTransSetDatePostedSecs | ( | Transaction * | trans, |
time64 | time | ||
) |
The xaccTransSetDatePostedSecs() method will modify the posted date of the transaction, specified by a time64 (see ctime(3)). The posted date is the date when this transaction was posted at the bank.
Please do not use this function, as the extra time-of-day part messes up a lot of places. Rather, please use xaccTransSetDatePostedGDate() or xaccTransSetDatePostedSecsNormalized().
Definition at line 1911 of file Transaction.c.
void xaccTransSetDatePostedSecsNormalized | ( | Transaction * | trans, |
time64 | time | ||
) |
This function sets the posted date of the transaction, specified by a time64 (see ctime(3)). Contrary to xaccTransSetDatePostedSecs(), the time will be normalized to only the date part, and the time-of-day will be ignored. The resulting date is the same as if it had been set as a GDate through xaccTransSetDatePostedGDate().
Please prefer this function over xaccTransSetDatePostedSecs().
The posted date is the date when this transaction was posted at the bank.
Definition at line 1920 of file Transaction.c.
void xaccTransSetDatePostedTS | ( | Transaction * | trans, |
const Timespec * | ts | ||
) |
The xaccTransSetDatePostedTS() method does the same thing as xaccTransSetDatePostedSecs(), but takes a struct timespec64.
Definition at line 1970 of file Transaction.c.
void xaccTransSetDescription | ( | Transaction * | trans, |
const char * | desc | ||
) |
void xaccTransSetIsClosingTxn | ( | Transaction * | trans, |
gboolean | is_closing | ||
) |
Sets whether or not this transaction is a "closing transaction"
Definition at line 2126 of file Transaction.c.
void xaccTransSetNotes | ( | Transaction * | trans, |
const char * | notes | ||
) |
Sets the transaction Notes
The Notes field is only visible in the register in double-line mode
Definition at line 2115 of file Transaction.c.
void xaccTransSetNum | ( | Transaction * | trans, |
const char * | num | ||
) |
Sets the transaction Number (or ID) field; rather than use this function directly, see 'gnc_set_num_action' in engine/engine-helpers.c & .h which takes a user-set book option for selecting the source for the num-cell (the transaction-number or the split-action field) in registers/reports into account automatically
Definition at line 2065 of file Transaction.c.
void xaccTransSetReadOnly | ( | Transaction * | trans, |
const char * | reason | ||
) |
Set the transaction to be ReadOnly by setting a non-NULL value as "reason".
FIXME: If "reason" is NULL, this function does nothing, instead of removing the readonly flag; the actual removal is possible only through xaccTransClearReadOnly().
Definition at line 2039 of file Transaction.c.
void xaccTransSetTxnType | ( | Transaction * | trans, |
char | type | ||
) |
Set the Transaction Type
See TXN_TYPE_NONE, TXN_TYPE_INVOICE and TXN_TYPE_PAYMENT
Definition at line 2016 of file Transaction.c.
void xaccTransSortSplits | ( | Transaction * | trans | ) |
Sorts the splits in a transaction, putting the debits first, followed by the credits.
Definition at line 564 of file Transaction.c.
void xaccTransUnvoid | ( | Transaction * | transaction | ) |
xaccTransUnvoid restores a voided transaction to its original state. At some point when gnucash is enhanced to support an audit trail (i.e. write only transactions) this command should be automatically disabled when the audit trail feature is enabled.
transaction | The transaction to restore from voided state. |
Definition at line 2552 of file Transaction.c.
gboolean xaccTransUseTradingAccounts | ( | const Transaction * | trans | ) |
Determine whether this transaction should use commodity trading accounts
Definition at line 1015 of file Transaction.c.
void xaccTransVoid | ( | Transaction * | transaction, |
const char * | reason | ||
) |
xaccTransVoid voids a transaction. A void transaction has no values, is unaffected by reconciliation, and, by default is not included in any queries. A voided transaction may not be altered.
transaction | The transaction to void. |
reason | The textual reason why this transaction is being voided. |
Definition at line 2495 of file Transaction.c.