GnuCash
5.6-150-g038405b370+
|
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. More...
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 | 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)) |
Functions | |
GType | gnc_split_get_type (void) |
gnc_numeric | xaccSplitConvertAmount (const Split *split, const Account *account) |
GType | gnc_transaction_get_type (void) |
void | xaccTransRecordPrice (Transaction *trans, PriceSource source) |
The xaccTransRecordPrice() method iterates through the splits and and record the non-currency equivalent prices in the price database. More... | |
Split Reconciled field values | |
These define the various reconciliations states a split can be in. If you change these be sure to change gnc-ui-util.c:gnc_get_reconciled_str() and associated functions | |
#define | CREC 'c' |
The Split has been cleared. | |
#define | YREC 'y' |
The Split has been reconciled. | |
#define | FREC 'f' |
frozen into accounting period | |
#define | NREC 'n' |
not reconciled or cleared | |
#define | VREC 'v' |
split is void | |
Split general getters/setters | |
Split * | xaccMallocSplit (QofBook *book) |
Constructor. More... | |
void | xaccSplitReinit (Split *split) |
gboolean | xaccSplitDestroy (Split *split) |
Destructor. More... | |
void | xaccSplitCopyOnto (const Split *from_split, Split *to_split) |
This is really a helper for xaccTransCopyOnto. More... | |
QofBook * | xaccSplitGetBook (const Split *split) |
Returns the book of this split, i.e. More... | |
Account * | xaccSplitGetAccount (const Split *split) |
Returns the account of this split, which was set through xaccAccountInsertSplit(). More... | |
void | xaccSplitSetAccount (Split *s, Account *acc) |
Transaction * | xaccSplitGetParent (const Split *split) |
Returns the parent transaction of the split. More... | |
void | xaccSplitSetParent (Split *split, Transaction *trans) |
GNCLot * | xaccSplitGetLot (const Split *split) |
Returns the pointer to the debited/credited Lot where this split belongs to, or NULL if it doesn't belong to any. More... | |
void | xaccSplitSetLot (Split *split, GNCLot *lot) |
Assigns the split to a specific Lot. | |
void | xaccSplitSetMemo (Split *split, const char *memo) |
The memo is an arbitrary string associated with a split. More... | |
const char * | xaccSplitGetMemo (const Split *split) |
Returns the memo string. More... | |
void | xaccSplitSetAction (Split *split, const char *action) |
The Action is an arbitrary user-assigned string. More... | |
const char * | xaccSplitGetAction (const Split *split) |
Returns the action string. More... | |
Split Date getters/setters | |
void | xaccSplitSetReconcile (Split *split, char reconciled_flag) |
Set the reconcile flag. More... | |
char | xaccSplitGetReconcile (const Split *split) |
Returns the value of the reconcile flag. More... | |
void | xaccSplitSetDateReconciledSecs (Split *split, time64 time) |
Set the date on which this split was reconciled by specifying the time as time64. More... | |
time64 | xaccSplitGetDateReconciled (const Split *split) |
Retrieve the date when the Split was reconciled. More... | |
Split amount getters/setters | |
'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) |
The xaccSplitSetAmount() method sets the amount in the account's commodity that the split should have. More... | |
gnc_numeric | xaccSplitGetAmount (const Split *split) |
Returns the amount of the split in the account's commodity. More... | |
void | xaccSplitSetValue (Split *split, gnc_numeric value) |
The xaccSplitSetValue() method sets the value of this split in the transaction's commodity. More... | |
gnc_numeric | xaccSplitGetValue (const Split *split) |
Returns the value of this split in the transaction's commodity. More... | |
void | xaccSplitSetSharePriceAndAmount (Split *split, gnc_numeric price, gnc_numeric amount) |
The xaccSplitSetSharePriceAndAmount() method will simultaneously update the share price and the number of shares. More... | |
gnc_numeric | xaccSplitGetSharePrice (const Split *split) |
Returns the price of the split, that is, the value divided by the amount. More... | |
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. More... | |
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. More... | |
gnc_numeric | xaccSplitGetBalance (const Split *split) |
Returns the running balance up to and including the indicated split. More... | |
gnc_numeric | xaccSplitGetNoclosingBalance (const Split *split) |
The noclosing-balance is the currency-denominated balance of all transactions except 'closing' transactions. More... | |
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. More... | |
gnc_numeric | xaccSplitGetReconciledBalance (const Split *split) |
Returns the reconciled-balance of this split. More... | |
Split utility functions | |
gboolean | xaccSplitEqual (const Split *sa, const Split *sb, gboolean check_guids, gboolean check_balances, gboolean check_txn_splits) |
Equality. More... | |
Split * | xaccSplitLookup (const GncGUID *guid, QofBook *book) |
The xaccSplitLookup() subroutine will return the split associated with the given id, or NULL if there is no such split. More... | |
void | xaccSplitAddPeerSplit (Split *split, const Split *other_split, const time64 timestamp) |
Add a peer split to this split's lot-split list. More... | |
gboolean | xaccSplitHasPeers (const Split *split) |
Does this split have peers? | |
gboolean | xaccSplitIsPeerSplit (const Split *split, const Split *other_split) |
Report if a split is a peer of this one. More... | |
void | xaccSplitRemovePeerSplit (Split *split, const Split *other_split) |
Remove a peer split from this split's lot-split list. More... | |
void | xaccSplitMergePeerSplits (Split *split, const Split *other_split) |
Merge the other_split's peer splits into split's peers. More... | |
Split * | xaccSplitGetOtherSplit (const Split *split) |
The xaccSplitGetOtherSplit() is a convenience routine that returns the other of a pair of splits. More... | |
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). More... | |
void | xaccSplitMakeStockSplit (Split *s) |
Mark a split to be of type stock split - after this, you shouldn't modify the value anymore, just the amount. More... | |
gint | xaccSplitOrder (const Split *sa, const Split *sb) |
The xaccSplitOrder(sa,sb) method is useful for sorting. More... | |
gint | xaccSplitOrderDateOnly (const Split *sa, const Split *sb) |
int | xaccSplitCompareAccountFullNames (const Split *sa, const Split *sb) |
Compare two splits by full name of account. More... | |
int | xaccSplitCompareAccountCodes (const Split *sa, const Split *sb) |
Compare two splits by code of account. More... | |
int | xaccSplitCompareOtherAccountFullNames (const Split *sa, const Split *sb) |
Compare two splits by full name of the other account. More... | |
int | xaccSplitCompareOtherAccountCodes (const Split *sa, const Split *sb) |
Compare two splits by code of the other account. More... | |
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". More... | |
const char * | xaccSplitGetCorrAccountName (const Split *sa) |
document me | |
const char * | xaccSplitGetCorrAccountCode (const Split *sa) |
document me | |
#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) |
Returns the original pre-void amount of a split. More... | |
gnc_numeric | xaccSplitVoidFormerValue (const Split *split) |
Returns the original pre-void value of a split. More... | |
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_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" |
for guid_match_all | |
#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_UNCACHED '?' /** Transaction type not yet cached */ |
#define | TXN_TYPE_NONE '\0' |
No transaction type. | |
#define | TXN_TYPE_INVOICE 'I' |
Transaction is an invoice. | |
#define | TXN_TYPE_PAYMENT 'P' |
Transaction is a payment. | |
#define | TXN_TYPE_LINK 'L' |
Transaction is a link between (invoice and payment) lots. | |
Transaction creation and editing | |
Transaction * | xaccMallocTransaction (QofBook *book) |
The xaccMallocTransaction() will malloc memory and initialize it. More... | |
void | xaccTransDestroy (Transaction *trans) |
Destroys a transaction. More... | |
Transaction * | xaccTransClone (const Transaction *t) |
The xaccTransClone() method will create a complete copy of an existing transaction. | |
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. | |
gboolean | xaccTransEqual (const Transaction *ta, const Transaction *tb, gboolean check_guids, gboolean check_splits, gboolean check_balances, gboolean assume_ordered) |
Equality. More... | |
void | xaccTransBeginEdit (Transaction *trans) |
The xaccTransBeginEdit() method must be called before any changes are made to a transaction or any of its component splits. More... | |
void | xaccTransCommitEdit (Transaction *trans) |
The xaccTransCommitEdit() method indicates that the changes to the transaction and its splits are complete and should be made permanent. More... | |
void | xaccTransRollbackEdit (Transaction *trans) |
The xaccTransRollbackEdit() routine rejects all edits made, and sets the transaction back to where it was before the editing started. More... | |
gboolean | xaccTransIsOpen (const Transaction *trans) |
The xaccTransIsOpen() method returns TRUE if the transaction is open for editing. More... | |
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. More... | |
Transaction * | xaccTransCopyToClipBoard (const Transaction *from_trans) |
Copy a transaction to the 'clipboard' transaction using dupe_transaction. More... | |
void | xaccTransCopyOnto (const Transaction *from_trans, Transaction *to_trans) |
Copy a transaction to another using the function below without changing any account information. | |
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. More... | |
Split * | xaccTransFindSplitByAccount (const Transaction *trans, const Account *acc) |
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. More... | |
guint | gnc_book_count_transactions (QofBook *book) |
#define | xaccTransLookupDirect(g, b) xaccTransLookup(&(g),b) |
Transaction general getters/setters | |
gboolean | xaccTransUseTradingAccounts (const Transaction *trans) |
Determine whether this transaction should use commodity trading accounts. | |
void | xaccTransSortSplits (Transaction *trans) |
Sorts the splits in a transaction, putting the debits first, followed by the credits. | |
void | xaccTransSetTxnType (Transaction *trans, char type) |
Set the Transaction Type: note the type will be saved into the Transaction kvp property as a backward compatibility measure, for previous GnuCash versions whose xaccTransGetTxnType reads from the kvp slots. More... | |
char | xaccTransGetTxnType (Transaction *trans) |
Returns the Transaction Type: note this type will be derived from the transaction splits, returning TXN_TYPE_NONE, TXN_TYPE_INVOICE, TXN_TYPE_LINK, or TXN_TYPE_PAYMENT according to heuristics. More... | |
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. | |
void | xaccTransSetDescription (Transaction *trans, const char *desc) |
Sets the transaction Description. | |
void | xaccTransSetDocLink (Transaction *trans, const char *doclink) |
Sets the transaction Document Link. | |
void | xaccTransSetNotes (Transaction *trans, const char *notes) |
Sets the transaction Notes. More... | |
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. | |
const char * | xaccTransGetDescription (const Transaction *trans) |
Gets the transaction Description. | |
const char * | xaccTransGetDocLink (const Transaction *trans) |
Gets the transaction Document Link. | |
const char * | xaccTransGetNotes (const Transaction *trans) |
Gets the transaction Notes. More... | |
void | xaccTransSetIsClosingTxn (Transaction *trans, gboolean is_closing) |
Sets whether or not this transaction is a "closing transaction". | |
gboolean | xaccTransGetIsClosingTxn (const Transaction *trans) |
Returns whether this transaction is a "closing transaction". | |
void | xaccTransClearSplits (Transaction *trans) |
Remove all splits from the transaction. More... | |
Split * | xaccTransGetSplit (const Transaction *trans, int i) |
Return a pointer to the indexed split in this transaction's split list. More... | |
int | xaccTransGetSplitIndex (const Transaction *trans, const Split *split) |
Inverse of xaccTransGetSplit() | |
SplitList * | xaccTransGetSplitList (const Transaction *trans) |
The xaccTransGetSplitList() method returns a GList of the splits in a transaction. More... | |
SplitList * | xaccTransGetPaymentAcctSplitList (const Transaction *trans) |
The xaccTransGetPaymentAcctSplitList() method returns a GList of the splits in a transaction that belong to an account which is considered a valid account for business payments. More... | |
SplitList * | xaccTransGetAPARAcctSplitList (const Transaction *trans, gboolean strict) |
The xaccTransGetAPARSplitList() method returns a GList of the splits in a transaction that belong to an AR or AP account. More... | |
gboolean | xaccTransStillHasSplit (const Transaction *trans, const Split *s) |
Split * | xaccTransGetFirstPaymentAcctSplit (const Transaction *trans) |
The xaccTransGetFirstPaymentAcctSplit() method returns a pointer to the first split in this transaction that belongs to an account which is considered a valid account for business payments. More... | |
Split * | xaccTransGetFirstAPARAcctSplit (const Transaction *trans, gboolean strict) |
The xaccTransGetFirstPaymentAcctSplit() method returns a pointer to the first split in this transaction that belongs to an AR or AP account. More... | |
void | xaccTransSetReadOnly (Transaction *trans, const char *reason) |
Set the transaction to be ReadOnly by setting a non-NULL value as "reason". More... | |
void | xaccTransClearReadOnly (Transaction *trans) |
const char * | xaccTransGetReadOnly (Transaction *trans) |
Returns a non-NULL value if this Transaction was marked as read-only with some specific "reason" text. More... | |
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. More... | |
int | xaccTransCountSplits (const Transaction *trans) |
Returns the number of splits in this transaction. More... | |
gboolean | xaccTransHasReconciledSplits (const Transaction *trans) |
FIXME: document me. | |
gboolean | xaccTransHasReconciledSplitsByAccount (const Transaction *trans, const Account *account) |
FIXME: document me. | |
gboolean | xaccTransHasSplitsInState (const Transaction *trans, const char state) |
FIXME: document me. | |
gboolean | xaccTransHasSplitsInStateByAccount (const Transaction *trans, const char state, const Account *account) |
FIXME: document me. | |
gnc_commodity * | xaccTransGetCurrency (const Transaction *trans) |
Returns the valuation commodity of this transaction. More... | |
void | xaccTransSetCurrency (Transaction *trans, gnc_commodity *curr) |
Set the commodity of this transaction. More... | |
gnc_numeric | xaccTransGetImbalanceValue (const Transaction *trans) |
The xaccTransGetImbalanceValue() method returns the total value of the transaction. More... | |
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. More... | |
gboolean | xaccTransIsBalanced (const Transaction *trans) |
Returns true if the transaction is balanced according to the rules currently in effect. More... | |
gnc_numeric | xaccTransGetAccountValue (const Transaction *trans, const Account *account) |
The xaccTransGetAccountValue() method returns the total value applied to a particular account. More... | |
gnc_numeric | xaccTransGetAccountAmount (const Transaction *trans, const Account *account) |
Same as xaccTransGetAccountValue, but uses the Account's commodity. More... | |
gnc_numeric | xaccTransGetAccountConvRate (const Transaction *txn, const Account *acc) |
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. More... | |
int | xaccTransOrder (const Transaction *ta, const Transaction *tb) |
The xaccTransOrder(ta,tb) method is useful for sorting. More... | |
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. More... | |
#define | xaccTransAppendSplit(t, s) xaccSplitSetParent((s), (t)) |
Add a split to the transaction. More... | |
Transaction date setters/getters | |
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. More... | |
void | xaccTransSetDatePostedGDate (Transaction *trans, GDate date) |
This method modifies posted date of the transaction, specified by a GDate. More... | |
void | xaccTransSetDatePostedSecs (Transaction *trans, time64 time) |
The xaccTransSetDatePostedSecs() method will modify the posted date of the transaction, specified by a time64 (see ctime(3)). More... | |
void | xaccTransSetDatePostedSecsNormalized (Transaction *trans, time64 time) |
This function sets the posted date of the transaction, specified by a time64 (see ctime(3)). More... | |
void | xaccTransSetDateEnteredSecs (Transaction *trans, time64 time) |
Modify the date of when the transaction was entered. More... | |
void | xaccTransSetDateDue (Transaction *trans, time64 time) |
Dates and txn-type for A/R and A/P "invoice" postings. | |
time64 | xaccTransGetDate (const Transaction *trans) |
Retrieve the posted date of the transaction. More... | |
time64 | xaccTransRetDatePosted (const Transaction *trans) |
Retrieve the posted date of the transaction. More... | |
GDate | xaccTransGetDatePostedGDate (const Transaction *trans) |
Retrieve the posted date of the transaction. More... | |
time64 | xaccTransGetDateEntered (const Transaction *trans) |
Retrieve the date of when the transaction was entered. More... | |
time64 | xaccTransRetDateEntered (const Transaction *trans) |
Retrieve the date of when the transaction was entered. More... | |
time64 | xaccTransRetDateDue (const Transaction *trans) |
Dates and txn-type for A/R and A/P "invoice" postings. | |
Transaction voiding | |
void | xaccTransVoid (Transaction *transaction, const char *reason) |
xaccTransVoid voids a transaction. More... | |
void | xaccTransUnvoid (Transaction *transaction) |
xaccTransUnvoid restores a voided transaction to its original state. More... | |
Transaction * | xaccTransReverse (Transaction *transaction) |
xaccTransReverse creates a Transaction that reverses the given transaction by inverting all the numerical values in the given transaction. More... | |
Transaction * | xaccTransGetReversedBy (const Transaction *trans) |
Returns the transaction that reversed the given transaction. More... | |
gboolean | xaccTransGetVoidStatus (const Transaction *transaction) |
Retrieve information on whether or not a transaction has been voided. More... | |
const char * | xaccTransGetVoidReason (const Transaction *transaction) |
Returns the user supplied textual reason why a transaction was voided. More... | |
time64 | xaccTransGetVoidTime (const Transaction *tr) |
Returns the time that a transaction was voided. More... | |
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 cannot 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 xaccSplitGetGUID | ( | X | ) | qof_entity_get_guid(QOF_INSTANCE(X)) |
#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 381 of file Transaction.h.
#define xaccTransGetBook | ( | X | ) | qof_instance_get_book (QOF_INSTANCE(X)) |
Definition at line 786 of file Transaction.h.
#define xaccTransGetGUID | ( | X | ) | qof_entity_get_guid(QOF_INSTANCE(X)) |
Definition at line 788 of file Transaction.h.
guint gnc_book_count_transactions | ( | QofBook * | book | ) |
Definition at line 2627 of file Transaction.cpp.
Split* xaccMallocSplit | ( | QofBook * | book | ) |
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 502 of file Transaction.cpp.
void xaccSplitAddPeerSplit | ( | Split * | split, |
const Split * | other_split, | ||
const time64 | timestamp | ||
) |
Add a peer split to this split's lot-split list.
other_split | The split whose guid to add |
timestamp | The time to be recorded for the split. |
Definition at line 2014 of file Split.cpp.
int xaccSplitCompareAccountCodes | ( | const Split * | sa, |
const Split * | sb | ||
) |
Compare two splits by code of account.
Returns similar to strcmp.
Definition at line 1674 of file Split.cpp.
int xaccSplitCompareAccountFullNames | ( | const Split * | sa, |
const Split * | sb | ||
) |
Compare two splits by full name of account.
Returns similar to strcmp.
Definition at line 1653 of file Split.cpp.
int xaccSplitCompareOtherAccountCodes | ( | const Split * | sa, |
const Split * | sb | ||
) |
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 1709 of file Split.cpp.
int xaccSplitCompareOtherAccountFullNames | ( | const Split * | sa, |
const Split * | sb | ||
) |
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 1688 of file Split.cpp.
void xaccSplitCopyOnto | ( | const Split * | from_split, |
Split * | to_split | ||
) |
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 638 of file Split.cpp.
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.
It begins and commits an edit on the transaction, so if after the split is removed the transaction has no more splits and if is not open it too will be destroyed, as it will if the outer edits are committed without adding transactions.
Definition at line 1471 of file Split.cpp.
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), then, when comparing the parenting transactions with xaccTransEqual(), set its argument check_splits to be TRUE. |
Definition at line 801 of file Split.cpp.
Account* xaccSplitGetAccount | ( | const Split * | split | ) |
Returns the account of this split, which was set through xaccAccountInsertSplit().
Definition at line 53 of file gmock-Split.cpp.
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
Definition at line 136 of file gmock-Split.cpp.
gnc_numeric xaccSplitGetAmount | ( | const Split * | split | ) |
Returns the amount of the split in the account's commodity.
Note that for cap-gains splits, this is slaved to the transaction that is causing the gains to occur.
Definition at line 69 of file gmock-Split.cpp.
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 1375 of file Split.cpp.
QofBook* xaccSplitGetBook | ( | const Split * | split | ) |
Returns the book of this split, i.e.
the entity where this split is stored.
Definition at line 45 of file gmock-Split.cpp.
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.
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.
Note that this will only return a real value in case of a two-split transaction as that is the only situation in which a reliable value can be returned. In other situations "-- Split Transaction --" will be returned as Account Name or "Split" for Account Code.
Definition at line 1620 of file Split.cpp.
time64 xaccSplitGetDateReconciled | ( | const Split * | split | ) |
GNCLot* xaccSplitGetLot | ( | const Split * | split | ) |
const char* xaccSplitGetMemo | ( | const Split * | split | ) |
Returns the memo string.
Definition at line 99 of file gmock-Split.cpp.
gnc_numeric xaccSplitGetNoclosingBalance | ( | const Split * | split | ) |
The noclosing-balance is the currency-denominated balance of all transactions except 'closing' transactions.
It is correctly adjusted for price fluctuations.
Returns the running balance up to & including the indicated split.
Split* xaccSplitGetOtherSplit | ( | 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 144 of file gmock-Split.cpp.
Transaction* xaccSplitGetParent | ( | const Split * | split | ) |
Returns the parent transaction of the split.
Definition at line 152 of file gmock-Split.cpp.
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 1928 of file Split.cpp.
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? :-).
Definition at line 1972 of file Split.cpp.
gnc_numeric xaccSplitGetValue | ( | const Split * | split | ) |
Returns the value of this split in the transaction's commodity.
Note that for cap-gains splits, this is slaved to the transaction that is causing the gains to occur.
Definition at line 84 of file gmock-Split.cpp.
gboolean xaccSplitIsPeerSplit | ( | const Split * | split, |
const Split * | other_split | ||
) |
Report if a split is a peer of this one.
other_split | The split to test for being a peer of this one. |
Definition at line 2038 of file Split.cpp.
Split* xaccSplitLookup | ( | const GncGUID * | guid, |
QofBook * | book | ||
) |
The xaccSplitLookup() subroutine will return the split associated with the given id, or NULL if there is no such split.
Definition at line 1070 of file Split.cpp.
void xaccSplitMakeStockSplit | ( | Split * | s | ) |
Mark a split to be of type stock split - after this, you shouldn't modify the value anymore, just the amount.
Definition at line 1997 of file Split.cpp.
void xaccSplitMergePeerSplits | ( | Split * | split, |
const Split * | other_split | ||
) |
Merge the other_split's peer splits into split's peers.
other_split | The split donating the peer splits. |
Definition at line 2068 of file Split.cpp.
gint xaccSplitOrder | ( | const Split * | sa, |
const Split * | sb | ||
) |
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 1501 of file Split.cpp.
void xaccSplitRemovePeerSplit | ( | Split * | split, |
const Split * | other_split | ||
) |
Remove a peer split from this split's lot-split list.
other_split | The split whose guid to remove |
Definition at line 2051 of file Split.cpp.
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. Note that the business features auto-fill this value, but doesn't depend on it. 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 1748 of file Split.cpp.
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 77 of file gmock-Split.cpp.
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 1320 of file Split.cpp.
void xaccSplitSetDateReconciledSecs | ( | Split * | split, |
time64 | time | ||
) |
Set the date on which this split was reconciled by specifying the time as time64.
Definition at line 129 of file gmock-Split.cpp.
void xaccSplitSetMemo | ( | Split * | split, |
const char * | memo | ||
) |
The memo is an arbitrary string associated with a split.
It is intended to hold a short (zero to forty character) string that is displayed by the GUI along with this split. Users typically type in free form text from the GUI.
Definition at line 107 of file gmock-Split.cpp.
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 122 of file gmock-Split.cpp.
void xaccSplitSetSharePrice | ( | Split * | split, |
gnc_numeric | price | ||
) |
DEPRECATED - set the value and amount instead.
Definition at line 1186 of file Split.cpp.
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 1158 of file Split.cpp.
void xaccSplitSetValue | ( | Split * | split, |
gnc_numeric | value | ||
) |
The xaccSplitSetValue() method sets the value of this split in the transaction's commodity.
Definition at line 92 of file gmock-Split.cpp.
gnc_numeric xaccSplitVoidFormerAmount | ( | const Split * | split | ) |
Returns the original pre-void amount of a split.
split | The split in question. |
Definition at line 2121 of file Split.cpp.
gnc_numeric xaccSplitVoidFormerValue | ( | const Split * | split | ) |
Returns the original pre-void value of a split.
split | The split in question. |
Definition at line 2136 of file Split.cpp.
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 35 of file gmock-Transaction.cpp.
void xaccTransClearSplits | ( | Transaction * | trans | ) |
Remove all splits from the transaction.
Clears the split list of the transaction. All splits that the transaction still owns will be destroyed, and others will be unlinked.
Opens and commits an edit on the transaction, so this will destroy the transaction if it isn't already open, as will committing the outer edits if new splits are not added before hand.
Definition at line 2153 of file Transaction.cpp.
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 42 of file gmock-Transaction.cpp.
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 745 of file Transaction.cpp.
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 705 of file Transaction.cpp.
int xaccTransCountSplits | ( | const Transaction * | trans | ) |
Returns the number of splits in this transaction.
Definition at line 2289 of file Transaction.cpp.
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 150 of file gmock-Transaction.cpp.
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 transaction 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 850 of file Transaction.cpp.
gnc_numeric xaccTransGetAccountAmount | ( | const Transaction * | trans, |
const Account * | account | ||
) |
Same as xaccTransGetAccountValue, but uses the Account's commodity.
Definition at line 1180 of file Transaction.cpp.
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 1254 of file Transaction.cpp.
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 convenience to view everything at once.
Definition at line 1164 of file Transaction.cpp.
SplitList* xaccTransGetAPARAcctSplitList | ( | const Transaction * | trans, |
gboolean | strict | ||
) |
The xaccTransGetAPARSplitList() method returns a GList of the splits in a transaction that belong to an AR or AP account.
trans | The transaction |
strict | This slightly modifies the test to only consider splits in an AR or AP account and the split is part of a business lot |
Definition at line 2226 of file Transaction.cpp.
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 134 of file gmock-Transaction.cpp.
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 73 of file gmock-Transaction.cpp.
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 2363 of file Transaction.cpp.
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 2376 of file Transaction.cpp.
Split* xaccTransGetFirstAPARAcctSplit | ( | const Transaction * | trans, |
gboolean | strict | ||
) |
The xaccTransGetFirstPaymentAcctSplit() method returns a pointer to the first split in this transaction that belongs to an AR or AP account.
trans | The transaction |
strict | This slightly modifies the test to only consider splits in an AR or AP account and the split is part of a business lot |
If there is no such split in the transaction NULL will be returned.
Definition at line 2265 of file Transaction.cpp.
Split* xaccTransGetFirstPaymentAcctSplit | ( | const Transaction * | trans | ) |
The xaccTransGetFirstPaymentAcctSplit() method returns a pointer to the first split in this transaction that belongs to an account which is considered a valid account for business payments.
trans | The transaction |
If there is no such split in the transaction NULL will be returned.
Definition at line 2254 of file Transaction.cpp.
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 1046 of file Transaction.cpp.
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 118 of file gmock-Transaction.cpp.
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 103 of file gmock-Transaction.cpp.
SplitList* xaccTransGetPaymentAcctSplitList | ( | const Transaction * | trans | ) |
The xaccTransGetPaymentAcctSplitList() method returns a GList of the splits in a transaction that belong to an account which is considered a valid account for business payments.
trans | The transaction |
Definition at line 2212 of file Transaction.cpp.
const char* xaccTransGetReadOnly | ( | Transaction * | trans | ) |
Returns a non-NULL value if this Transaction was marked as read-only with some specific "reason" text.
Definition at line 2473 of file Transaction.cpp.
Transaction* xaccTransGetReversedBy | ( | const Transaction * | trans | ) |
Returns the transaction that reversed the given transaction.
trans | a Transaction that has been reversed |
Definition at line 2784 of file Transaction.cpp.
Split* xaccTransGetSplit | ( | const Transaction * | trans, |
int | i | ||
) |
Return a pointer to the indexed split in this transaction's split list.
Note that the split list is a linked list and that indexed access is O(N). Do not use this method for iteration.
trans | The transaction |
i | The split number. Valid values for i are zero to (number_of__splits-1). |
Definition at line 49 of file gmock-Transaction.cpp.
SplitList* xaccTransGetSplitList | ( | const Transaction * | trans | ) |
The xaccTransGetSplitList() method returns a GList of the splits in a transaction.
trans | The transaction |
Definition at line 57 of file gmock-Transaction.cpp.
char xaccTransGetTxnType | ( | Transaction * | trans | ) |
Returns the Transaction Type: note this type will be derived from the transaction splits, returning TXN_TYPE_NONE, TXN_TYPE_INVOICE, TXN_TYPE_LINK, or TXN_TYPE_PAYMENT according to heuristics.
It does not query the transaction kvp slots.
See TXN_TYPE_NONE, TXN_TYPE_INVOICE and TXN_TYPE_PAYMENT
Definition at line 2434 of file Transaction.cpp.
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 2686 of file Transaction.cpp.
gboolean xaccTransGetVoidStatus | ( | const Transaction * | transaction | ) |
Retrieve information on whether or not a transaction has been voided.
transaction | The transaction in question. |
Definition at line 2679 of file Transaction.cpp.
time64 xaccTransGetVoidTime | ( | const Transaction * | tr | ) |
Returns the time that a transaction was voided.
tr | The transaction in question. |
Definition at line 2699 of file Transaction.cpp.
gboolean xaccTransIsBalanced | ( | const Transaction * | trans | ) |
Returns true if the transaction is balanced according to the rules currently in effect.
Definition at line 1118 of file Transaction.cpp.
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 142 of file gmock-Transaction.cpp.
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 2509 of file Transaction.cpp.
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 1018 of file Transaction.cpp.
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 1797 of file Transaction.cpp.
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.cpp.
void xaccTransRecordPrice | ( | Transaction * | trans, |
PriceSource | source | ||
) |
The xaccTransRecordPrice() method iterates through the splits and and record the non-currency equivalent prices in the price database.
trans | The transaction whose price is recorded |
source | The price priority level |
Definition at line 157 of file gmock-Transaction.cpp.
time64 xaccTransRetDateEntered | ( | 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 2411 of file Transaction.cpp.
time64 xaccTransRetDatePosted | ( | 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 2370 of file Transaction.cpp.
Transaction* xaccTransReverse | ( | Transaction * | transaction | ) |
xaccTransReverse creates a Transaction that reverses the given transaction 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 2744 of file Transaction.cpp.
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 1630 of file Transaction.cpp.
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 2842 of file Transaction.cpp.
void xaccTransSetCurrency | ( | Transaction * | trans, |
gnc_commodity * | curr | ||
) |
Set the commodity of this transaction.
Set the commodity of this transaction.
When we do that to a transaction with splits we need to re-value all of the splits in the new currency.
trans | The transaction to change |
curr | The new currency to set. |
Definition at line 1351 of file Transaction.cpp.
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 1961 of file Transaction.cpp.
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 1954 of file Transaction.cpp.
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 1935 of file Transaction.cpp.
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 1919 of file Transaction.cpp.
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 81 of file gmock-Transaction.cpp.
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 111 of file gmock-Transaction.cpp.
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 2024 of file Transaction.cpp.
void xaccTransSetTxnType | ( | Transaction * | trans, |
char | type | ||
) |
Set the Transaction Type: note the type will be saved into the Transaction kvp property as a backward compatibility measure, for previous GnuCash versions whose xaccTransGetTxnType reads from the kvp slots.
See TXN_TYPE_NONE, TXN_TYPE_INVOICE and TXN_TYPE_PAYMENT
Definition at line 1992 of file Transaction.cpp.
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 2718 of file Transaction.cpp.
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 2639 of file Transaction.cpp.