2001-08-07 18:36:04 -05:00
|
|
|
/********************************************************************\
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License as *
|
|
|
|
* published by the Free Software Foundation; either version 2 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License*
|
|
|
|
* along with this program; if not, contact: *
|
|
|
|
* *
|
|
|
|
* Free Software Foundation Voice: +1-617-542-5942 *
|
2005-11-16 23:35:02 -06:00
|
|
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
|
|
|
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
2001-08-07 18:36:04 -05:00
|
|
|
* *
|
|
|
|
\********************************************************************/
|
2002-12-07 15:16:01 -06:00
|
|
|
/** @addtogroup Engine
|
|
|
|
@{ */
|
2011-05-16 04:13:40 -05:00
|
|
|
/** @addtogroup Transaction Transaction, Split
|
2010-02-17 23:31:54 -06:00
|
|
|
A good overview of transactions, splits and accounts can be
|
2004-07-10 09:56:53 -05:00
|
|
|
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.
|
2010-02-17 23:31:54 -06:00
|
|
|
|
|
|
|
Transactions embody the notion of "double entry" accounting.
|
|
|
|
A Transaction consists of a date, a description, an ID number,
|
2004-07-10 09:56:53 -05:00
|
|
|
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.
|
2010-02-17 23:31:54 -06:00
|
|
|
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,
|
2004-07-10 09:56:53 -05:00
|
|
|
and another is credited by an equal amount. By forcing the value of the
|
2005-11-01 21:32:36 -06:00
|
|
|
splits to always 'add up' to zero, we can guarantee that the balances
|
2004-07-10 09:56:53 -05:00
|
|
|
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
|
2010-02-17 23:31:54 -06:00
|
|
|
that they are in balance.
|
2004-07-10 09:56:53 -05:00
|
|
|
|
|
|
|
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.
|
2010-02-17 23:31:54 -06:00
|
|
|
|
2004-07-10 09:56:53 -05:00
|
|
|
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
|
2010-02-17 23:31:54 -06:00
|
|
|
commodity can be the name of anything traded and tradable: a stock
|
2004-07-10 09:56:53 -05:00
|
|
|
(e.g. "IBM", "McDonald's"), a currency (e.g. "USD", "GBP"), or anything
|
2010-02-17 23:31:54 -06:00
|
|
|
added to the commodity table.
|
2004-07-10 09:56:53 -05:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2004-05-06 21:36:40 -05:00
|
|
|
@{ */
|
2010-02-17 23:31:54 -06:00
|
|
|
/** @file Transaction.h
|
2002-12-07 15:16:01 -06:00
|
|
|
@brief API for Transactions and Splits (journal entries)
|
|
|
|
@author Copyright (C) 1997 Robin D. Clark
|
|
|
|
@author Copyright (C) 1997-2001 Linas Vepstas <linas@linas.org>
|
|
|
|
*/
|
2002-12-07 07:05:45 -06:00
|
|
|
|
2001-08-07 18:36:04 -05:00
|
|
|
#ifndef XACC_TRANSACTION_H
|
|
|
|
#define XACC_TRANSACTION_H
|
|
|
|
|
2007-04-04 19:23:58 -05:00
|
|
|
typedef struct _TransactionClass TransactionClass;
|
|
|
|
|
2001-08-07 18:36:04 -05:00
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include "gnc-commodity.h"
|
2001-10-03 05:07:45 -05:00
|
|
|
#include "gnc-engine.h"
|
2006-02-22 15:52:46 -06:00
|
|
|
#include "Split.h"
|
2002-12-07 15:16:01 -06:00
|
|
|
|
2017-08-14 13:32:45 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2007-04-04 19:23:58 -05:00
|
|
|
/* --- type macros --- */
|
|
|
|
#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))
|
|
|
|
GType gnc_transaction_get_type(void);
|
|
|
|
|
|
|
|
|
2006-08-08 16:57:28 -05:00
|
|
|
/* FIXME: These macros are not consistent with the type name */
|
2007-04-04 19:23:58 -05:00
|
|
|
#define GNC_IS_TRANS(obj) GNC_IS_TRANSACTION(obj)
|
|
|
|
#define GNC_TRANS(obj) GNC_TRANSACTION(obj)
|
2006-03-12 15:54:04 -06:00
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
/** @name Transaction Type field values
|
|
|
|
@{
|
|
|
|
*/
|
2002-12-07 15:16:01 -06:00
|
|
|
#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 */
|
2012-02-10 09:34:18 -06:00
|
|
|
#define TXN_TYPE_LINK 'L' /**< Transaction is a link between (invoice and payment) lots */
|
2005-11-01 21:32:36 -06:00
|
|
|
/** @} */
|
2001-11-29 22:25:17 -06:00
|
|
|
|
2004-07-10 10:17:28 -05:00
|
|
|
/* --------------------------------------------------------------- */
|
|
|
|
/* Transactions */
|
2002-12-07 20:19:10 -06:00
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
/** @name Transaction creation and editing
|
|
|
|
@{
|
|
|
|
*/
|
2010-02-17 23:31:54 -06:00
|
|
|
/**
|
2002-12-07 15:16:01 -06:00
|
|
|
The xaccMallocTransaction() will malloc memory and initialize it.
|
|
|
|
Once created, it is usually unsafe to merely "free" this memory;
|
2010-02-17 23:31:54 -06:00
|
|
|
the xaccTransDestroy() method should be called. */
|
|
|
|
Transaction * xaccMallocTransaction (QofBook *book);
|
2001-08-07 18:36:04 -05:00
|
|
|
|
2009-02-11 23:47:34 -06:00
|
|
|
/** Destroys a transaction.
|
|
|
|
* Each split in transaction @a 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
|
2010-02-17 23:31:54 -06:00
|
|
|
* split memory will be freed, or xaccTransRollbackEdit(), in which
|
|
|
|
* case nothing at all is freed, and everything is put back into
|
2009-02-11 23:47:34 -06:00
|
|
|
* original order.
|
|
|
|
*
|
|
|
|
* @param trans the transaction to destroy
|
|
|
|
*/
|
2002-12-07 15:16:01 -06:00
|
|
|
void xaccTransDestroy (Transaction *trans);
|
|
|
|
|
2003-06-15 22:48:59 -05:00
|
|
|
/**
|
|
|
|
The xaccTransClone() method will create a complete copy of an
|
|
|
|
existing transaction.
|
|
|
|
*/
|
2005-12-31 17:35:55 -06:00
|
|
|
Transaction * xaccTransClone (const Transaction *t);
|
2003-06-15 22:48:59 -05:00
|
|
|
|
2014-05-07 08:37:14 -05:00
|
|
|
/**
|
|
|
|
The xaccTransCloneNoKvp() method will create a complete copy of an
|
|
|
|
existing transaction except that the KVP slots will be empty.
|
|
|
|
*/
|
|
|
|
Transaction * xaccTransCloneNoKvp (const Transaction *t);
|
|
|
|
|
2003-06-15 22:48:59 -05:00
|
|
|
/** Equality.
|
|
|
|
*
|
|
|
|
* @param ta First transaction to compare
|
|
|
|
* @param tb Second transaction to compare
|
|
|
|
*
|
|
|
|
* @param 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.
|
|
|
|
*
|
|
|
|
* @param check_splits If TRUE, after checking the transaction data
|
|
|
|
* structures for equality, also check all splits attached to the
|
|
|
|
* transation for equality.
|
|
|
|
*
|
|
|
|
* @param 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.
|
|
|
|
*
|
|
|
|
* @param assume_ordered If TRUE, assume that the splits in each
|
|
|
|
* transaction appear in the same order. This saves some time looking
|
2010-03-27 16:01:21 -05:00
|
|
|
* up splits by GncGUID, and is required for checking duplicated
|
2003-06-15 22:48:59 -05:00
|
|
|
* transactions because all the splits have new GUIDs.
|
|
|
|
*/
|
2001-10-04 03:17:14 -05:00
|
|
|
gboolean xaccTransEqual(const Transaction *ta,
|
|
|
|
const Transaction *tb,
|
2001-08-07 18:36:04 -05:00
|
|
|
gboolean check_guids,
|
2003-06-15 22:48:59 -05:00
|
|
|
gboolean check_splits,
|
|
|
|
gboolean check_balances,
|
|
|
|
gboolean assume_ordered);
|
2001-08-07 18:36:04 -05:00
|
|
|
|
2002-12-07 15:16:01 -06:00
|
|
|
/** The xaccTransBeginEdit() method must be called before any changes
|
2010-02-17 23:31:54 -06:00
|
|
|
are made to a transaction or any of its component splits. If
|
2002-12-07 15:16:01 -06:00
|
|
|
this is not done, errors will result. */
|
2001-08-07 18:36:04 -05:00
|
|
|
void xaccTransBeginEdit (Transaction *trans);
|
2002-12-07 15:16:01 -06:00
|
|
|
|
|
|
|
/** 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. */
|
2001-08-07 18:36:04 -05:00
|
|
|
void xaccTransCommitEdit (Transaction *trans);
|
2002-12-07 15:16:01 -06:00
|
|
|
|
2010-02-17 23:31:54 -06:00
|
|
|
/** The xaccTransRollbackEdit() routine rejects all edits made, and
|
|
|
|
sets the transaction back to where it was before the editing
|
2002-12-07 15:16:01 -06:00
|
|
|
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. */
|
2001-08-07 18:36:04 -05:00
|
|
|
void xaccTransRollbackEdit (Transaction *trans);
|
|
|
|
|
2002-12-07 15:16:01 -06:00
|
|
|
/** The xaccTransIsOpen() method returns TRUE if the transaction
|
2010-02-17 23:31:54 -06:00
|
|
|
is open for editing. Otherwise, it returns false.
|
2014-08-16 08:52:43 -05:00
|
|
|
XXX this routine should probably be deprecated. its, umm,
|
2009-02-03 15:19:31 -06:00
|
|
|
hard to imagine legitimate uses (but it is used by
|
2003-10-16 23:25:53 -05:00
|
|
|
the import/export code for reasons I can't understand.)
|
|
|
|
*/
|
2002-12-07 07:05:45 -06:00
|
|
|
gboolean xaccTransIsOpen (const Transaction *trans);
|
2001-08-07 18:36:04 -05:00
|
|
|
|
2002-12-07 20:19:10 -06:00
|
|
|
/** The xaccTransLookup() subroutine will return the
|
|
|
|
transaction associated with the given id, or NULL
|
|
|
|
if there is no such transaction. */
|
2010-02-17 23:31:54 -06:00
|
|
|
/*@ dependent @*//*@ null @*/
|
2010-03-27 16:01:21 -05:00
|
|
|
Transaction * xaccTransLookup (const GncGUID *guid, QofBook *book);
|
2003-10-16 23:25:53 -05:00
|
|
|
#define xaccTransLookupDirect(g,b) xaccTransLookup(&(g),b)
|
2003-06-09 23:30:54 -05:00
|
|
|
|
2013-02-28 03:52:12 -06:00
|
|
|
/*################## Added for Reg2 #################*/
|
|
|
|
|
|
|
|
/** Copy a transaction to the 'clipboard' transaction using
|
2014-05-07 08:37:14 -05:00
|
|
|
* dupe_transaction. The 'clipboard' transaction must never
|
2013-02-28 03:52:12 -06:00
|
|
|
* be dereferenced.
|
|
|
|
*/
|
|
|
|
Transaction * xaccTransCopyToClipBoard(const Transaction *from_trans);
|
|
|
|
|
|
|
|
/** Copy a transaction to another using the function below without
|
|
|
|
* changing any account information.
|
|
|
|
*/
|
|
|
|
void xaccTransCopyOnto(const Transaction *from_trans, Transaction *to_trans);
|
|
|
|
|
|
|
|
/** 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.
|
|
|
|
*
|
2013-05-18 09:23:12 -05:00
|
|
|
* 'no_date' if TRUE will not copy the date posted.
|
2013-03-11 13:08:08 -05:00
|
|
|
*
|
2013-02-28 03:52:12 -06:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
void xaccTransCopyFromClipBoard(const Transaction *from_trans, Transaction *to_trans,
|
2013-05-18 09:23:12 -05:00
|
|
|
const Account *from_acc, Account *to_acc, gboolean no_date);
|
2013-02-28 03:52:12 -06:00
|
|
|
|
|
|
|
/*################## Added for Reg2 #################*/
|
|
|
|
|
|
|
|
|
2010-02-17 23:31:54 -06:00
|
|
|
Split * xaccTransFindSplitByAccount(const Transaction *trans,
|
2006-05-04 19:40:15 -05:00
|
|
|
const Account *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
|
2010-02-17 23:31:54 -06:00
|
|
|
* assignments of all the splits are good, and that the lots
|
2006-05-04 19:40:15 -05:00
|
|
|
* balance appropriately.
|
|
|
|
*/
|
|
|
|
void xaccTransScrubGains (Transaction *trans, Account *gain_acc);
|
|
|
|
|
2006-03-03 18:10:12 -06:00
|
|
|
|
2010-02-17 23:31:54 -06:00
|
|
|
/** \warning XXX FIXME
|
|
|
|
* gnc_book_count_transactions is a utility function,
|
2003-06-09 23:30:54 -05:00
|
|
|
* probably needs to be moved to a utility file somewhere.
|
|
|
|
*/
|
2003-06-24 19:52:46 -05:00
|
|
|
guint gnc_book_count_transactions(QofBook *book);
|
2003-06-09 23:30:54 -05:00
|
|
|
|
2004-07-10 10:17:28 -05:00
|
|
|
/** @} */
|
2002-12-07 20:19:10 -06:00
|
|
|
|
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
/** @name Transaction general getters/setters
|
|
|
|
@{
|
|
|
|
*/
|
2001-08-07 18:36:04 -05:00
|
|
|
|
Bug #537476: Implement currency trading accounts optionally, to be enabled per-book.
Patch by Mike Alexander:
This patch implements trading accounts somewhat as described in Peter
Selinger's document at
<http://www.mathstat.dal.ca/~selinger/accounting/gnucash.html>. Although he
describes it as a multiple currency problem, it really applies to any
transactions involving multiple commodities (for example buying or selling a
stock) Hence I've called the trading accounts "commodity exchange accounts"
which seems more descriptive.
In summary these patches add an option to use commodity exchange accounts and
if it is on a transaction must be balanced both in value (in the transaction
currency) and in each commodity or currency used in any split in the
transaction. If a transaction only contains splits in the transaction currency
then this is the same rule as Gnucash has always enforced.
In this patch, the option to use trading accounts has been moved from
Edit->Preferences to File->Properties and is now associated with the active
book instead of being a global option. If you have set the global value on in
a previous version you will need to set it on again in each file for which you
want trading accounts, the previous global setting will be ignored.
A more detailed list of changes follows:
1. Added a "Use commodity exchange accounts" per-book option.
2. Added gnc_monetary and MonetaryList data types.
3. Renamed xaccTransGetImbalance to xaccTransGetImbalanceValue and added a new
xaccTransGetImbalance that returns a MonetaryList. Also added
xaccTransIsBalanced to see if the transaction is balanced without returning a
GList that needs to be freed. It calls both xaccTransGetImbalance and
xaccTransGetImbalanceValue since a transaction may be unbalanced with regard to
either without being unbalanced with regard to the other.
4. Changed gnc_split_register_get_debcred_bg_color to use xaccTransIsBalanced.
5. Changed gnc_split_register_balance_trans to not offer to adjust an existing
split if there imbalances in multiple currencies. Because of bugs in the
register code this is rarely called.
6. Changed importers to use xaccTransGetImbalanceValue to check for imbalance,
assuming that they won't create multiple currency trasactions.
7. Changed xaccTransScrubImbalance to create a balancing split for each
imbalanced commodity in the transaction. Also balances the transaction value.
The commodity balancing splits go into accounts in the hierarchy
Trading:NAMESPACE:COMMODITY. The value balancing splits go into
Imbalance-CURRENCY as before.
8. Changed xaccSplitConvertAmount to use xaccTransIsBalanced instead of
xaccTransGetImbalance.
9. Changed gnc_split_register_get_debcred_entry to sometimes use the split
amount instead of value if using currency accounts.
If the register is a stock register (i.e., shows shares and prices), it uses
the value if the split is in the register commodity (i.e. is for the stock) and
the amount otherwise. It shows the currency symbol unless the commodity is the
default currency.
If the register is not a stock register it always uses the amount and shows the
currency symbol if the split is not in the register commodity.
Also changed it to not return a value for a null split unless the transaction
is unbalanced in exactly one currency. This is what goes in a blank split as
the proposed value.
10. Changed refresh_model_row to use xaccTransGetImbalanceValue to get the
imbalance, assuming that importers don't create transactions in multiple
currencies. Also same change in gnc_import_process_trans_item,
downloaded_transaction_append, and gnc_import_TransInfo_is_balanced.
11. Changed the TRANS_IMBALANCE accessor method in xaccTransRegister to use
xaccTransGetImbalanceValue. As far as I can tell this is only used by the
"pd-balance" query type in gnc_scm2query_term_query_v1() defined in
engine-helpers.c. This query type only tests the result for zero/non-zero.
12. Changed xaccTransGetAccountConvRate to accept any split into the correct
commodity instead of insisting on one into the provided account. Then can use
it in xaccTransScrubImbalance to set the value of the imbalance split from its
amount, however later changed xaccTransScrubImbalance to not use it. Instead
it sets the value for the new split correctly to keep the value of the whole
transaction balanced.
13. Changed the balance sheet report to include a new option to not compute
unrealized gains and losses.
14. Related to 9 above, changed gnc_split_register_auto_calc to not do anything
if given a stock register where the value cell doesn't contain the value.
15. Also related to 9, changed gnc_split_register_save_amount_values to set the
amount and value fields in the split correctly when using trading accounts.
16. Changed the new account and edit account dialogs to allow any commodity or
currency for an income account if using trading accounts. It would be better
to add a new account type for trading accounts, but that's a big deal and I'll
leave that for later after we see whether this set of changes is going to be
accepted or rejected.
17. Change gnc_xfer_dialog_run_exchange_dialog to understand that the new value
is really the split's amount if using trading accounts.
18. Changed xaccSplitGetOtherSplit to ignore trading splits if using commodity
exchange accounts.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18429 57a11ea4-9604-0410-9ed3-97b8803252fd
2009-11-20 14:11:03 -06:00
|
|
|
/** Determine whether this transaction should use commodity trading accounts
|
|
|
|
*/
|
|
|
|
gboolean xaccTransUseTradingAccounts(const Transaction *trans);
|
|
|
|
|
2003-06-15 22:48:59 -05:00
|
|
|
/** Sorts the splits in a transaction, putting the debits first,
|
|
|
|
* followed by the credits.
|
|
|
|
*/
|
|
|
|
void xaccTransSortSplits (Transaction *trans);
|
|
|
|
|
2002-12-07 20:19:10 -06:00
|
|
|
/** Set the Transaction Type
|
2002-12-07 15:16:01 -06:00
|
|
|
*
|
2005-11-01 21:32:36 -06:00
|
|
|
* See #TXN_TYPE_NONE, #TXN_TYPE_INVOICE and #TXN_TYPE_PAYMENT */
|
2002-12-07 15:16:01 -06:00
|
|
|
void xaccTransSetTxnType (Transaction *trans, char type);
|
2002-12-07 20:19:10 -06:00
|
|
|
/** Returns the Transaction Type
|
|
|
|
*
|
2005-11-01 21:32:36 -06:00
|
|
|
* See #TXN_TYPE_NONE, #TXN_TYPE_INVOICE and #TXN_TYPE_PAYMENT */
|
2002-12-07 07:05:45 -06:00
|
|
|
char xaccTransGetTxnType (const Transaction *trans);
|
2002-12-07 15:16:01 -06:00
|
|
|
|
Implement a Book Option to give users the choice to use the transaction number field (default and current behaviour) or, alternatively, the split action field of the anchor split for 'Num' column on registers, reports, import and export, where applicable. The difference between the two is that with the default, the same 'Num' is displayed for a given transaction regardless of what register it is viewed in and with the new option, a different 'Num' can be entered/displayed for a given transaction in each register it is viewed in. In both cases, the 'next number logic' of the 'Num' cell is based on the account of the register the transaction is entered/viewed from but in one case it fills the transaction number, in the other, it fills the split action field of the anchor split (with the transaction number field displayed in the register cell labeled 'T-Num'). In both cases, both fields are visible and can be used as free-form text in double-line mode for any value the user wants. If the new option is not selected, there should be no change in Gnucash's behaviour with the exception of displaying the book options dialog in 'new book' situations.
The changes made are:
1. Implement the new book option to select source for 'num' cell:
libqof/qof/qofbookslots.h - define num source option
engine/engine.i - define 'NUM-FIELD-SOURCE' as an option name and
'SPLIT-ACTION' as a term for sorting queries
app-utils/business-prefs.scm - define book option for num-field-source
app-utils/app-utils.scm - define and export book option for num-field-source
2. Implement functions to get book option setting and to test:
libqof/qof/qofbook.c & .h - define function to get number source book option
libqof/qof/test/test-qofbook.c - test function to get number source book option
3. Implement a notification mechanism for book option changes:
engine/engine-helpers.c & .h - define functions to register callbacks,
define function to remove callbacks and
define function to initiate callbacks on book num-source option changes
core-utils/gnc-features.c & .h - define feature for num-source
app-utils/gnc-ui-util.c & .h - define gnc_book_option_num_field_source_change_cb;
include setting of feature flag on initial use
gnome-utils/gnc-main-window.c - change name of gnc_options_dialog_apply_cb
function to gnc_book_options_dialog_apply_cb and adjust function to
call function gnc_book_option_num_field_source_change_cb when book
option for num-field-source changes; change name of
gnc_options_dialog_close_cb to gnc_book_options_dialog_close_cb
4. Implement 'help' button response on Book Option Dialog:
gnome-utils/gnc-ui.h - define "book-options" section of help manual
gnome-utils/gnc-gnome-utils.c & .h - implement Book Options help callback
gnome-utils/gnc-main-window.c - use gnc_options_dialog_set_book_options_help_cb
to make help button active
5. Implement utility functions to get/set number/action based on book option:
engine/engine-helpers.c & .h - define 'gnc_get_num_action' function
define 'gnc_get_action_num' function
define 'gnc_set_num_action' function
engine/engine.i - make get/set num/action functions available to guile &
allow #f to be used in place of NULL from guile
engine/Transaction.h - add reference to utility functions in comments to
xaccTransSetNum and xaccTransGetNum functions
engine/Split.h - add reference to utility functions in comments to
xaccSplitSetAction and xaccSplitGetAction functions
6. Implement register use of num source book option; for General, Income and Search
Ledgers, since there is no anchor split, always show tran-num in transaction
cursor, but vary label to correspond to book option:
register/ledger-core/split-register.h - define TNUM_CELL
define CURSOR_DOUBLE_LEDGER_NUM_ACTN cursor name to use TNUM_CELL
define CURSOR_DOUBLE_JOURNAL_NUM_ACTN cursor name to use TNUM_CELL
add boolean to split_reg structure to hold num source book option
register/ledger-core/split-register-layout.c -
add logic to define and set up new ledger/journal cursors with TNUM_CELLs
add logic to add the new cursors to a layout
add logic to add TNUM_CELL to a layout
register/ledger-core/split-register-model.c -
define function to get TNUM_CELL label
add logic to recognize ledger/journal cursors with TNUM_CELL
modify function to get NUM_CELL value based on book option and register
type
define function to get TNUM_CELL value
adjust num help text to reflect book option choice
define function to get TNUM_CELL help
modify function to get action help to reflect book option choice
set up handlers for TNUM_CELL
register/ledger-core/split-register-model-save.c -
use 'gnc_set_num_action' function to set num/action for NUM_CELL based
on book option
define function to save TNUM_CELL using 'gnc_set_num_action' function
set save handler for TNUM_CELL
register/ledger-core/split-register-util.c -
modify logic to recognize ledger/journal cursors with tnum_cell
register/ledger-core/split-register.c -
define split_register_book_option_changed function
register split_register_book_option_changed function in register init
initialize register structure setting to book option
remove split_register_book_option_changed function in register destroy
modify gnc_split_register_save_to_scm to handle TNUM_CELL
7. Enhance transaction copy/duplicate logic to accommodate new book option:
gnome/gtkbuilder/gnc-plugin-page-register.glade -
add widgets to handle trans number and/or split action based on book option
gnome-utils/dialog-dup-trans.c & .h -
add capability to display and handle 'Num' field according to book option
gnome/gnc-plugin-page-register.c - define gnc_find_register_by_account
register/ledger-core/split-register.c -
modify gnc_split_register_duplicate_current to accomodate book option
setting
register/ledger-core/Makefile.am - add GNOME_CFLAGS
register/ledger-core/test/Makefile.am - add libgnc-gnome.la
8. Adjust register sort and sort labels related to Num/Action radio buttons to
correspond to book option for clarity:
gnome/gnc-plugin-page-register.c -
define gnc_plugin_page_register_sort_book_option_changed to adjust labels
register function in gnc_plugin_page_register_cmd_view_sort_by
and save num and action radio widgets
initialize radio widget labels to correspond to book option
remove function in gnc_plugin_page_register_sort_response_cb
and clear num and action radio widgets
gnome/gnc-split-reg.c & h. -
create versions of gnc_split_reg_sort and gnc_split_reg_set_sort to force
a re-sort to be used when num-source book option changes
engine/Transaction.c & .h -
modify default sort to use split action in place of tran num per book
option if called from xaccSplitOrder
engine/Split.c -
modify xaccSplitOrder to call xaccTransOrder_num_action to switch use of
split action and tran num per book option
engine/test/utest-Split.c -
modify test_xaccSplitOrder to call xaccTransOrder_num_action based on
book option
9. Adjust transaction find labels related to Num/Action to correspond to book option
for clarity:
gnome/dialog-find-transactions.c - adjust labels in search criteria based
on book option
gnome-search/dialog-search.c -
define gnc_search_dialog_book_option_changed to adjust labels
register function in gnc_search_dialog_init_widgets when searching
for splits
remove function in gnc_search_dialog_close_cb if registered
10. Modify new file process to allow setting of num-source (actually, all) book
option(s) during New Account Hierarchy Setup:
gnome-utils/gtkbuilder/dialog-preferences.glade - add a user preference for
the default setting for 'num-source' for new books
core-utils/gnc-gconf-utils.h - define KEY_NUM_SOURCE
gnome-utils/gnc-gnome-utils.c & h. -
define gnc_options_dialog_set_new_book_option_values to retrieve
preference values
gnome-utils/dialog-options.c & .h - define gnc_options_dialog_new_modal to
surpress apply button
gnome-utils/gnc-main-window.c - define function gnc_book_options_dialog_cb
with arguments so that the window can be called in modal mode and the
title changed and return dialog widget; call gnc_options_dialog_new_modal
instead of gnc_options_dialog_new; call this function from
gnc_main_window_cmd_file_properties with new arguments; for modal mode,
call gnc-options-dialog-set-new-book-option-values to initialize values
from preferences
app-utils/gnc-ui-util.c & h. - create function gnc_is_new_book for
determining when a new book is being created
gnome-utils/dialog-utils.c & h. - define gnc_new_book_option_display to
display book options dialog in modal mode
gnome/gtkbuilder/assistant-hierarchy.glade - add notification about book
options to currency page
gnome/assistant-hierarchy.c - add ability to set book option initialized
from preferences value for new books by using functions gnc_is_new_book
and gnc_new_book_option_display
11. Modify Import QIF process to recognize a new-book situation and allow setting
of book options during first import into a new book; also follow book option
setting for num source in importing number whether new book or not:
import-export/qif-import/assistant-qif-import.glade - add notification about
book options to currency page
import-export/qif-import/assistant-qif-import.c - using function
gnc_is_new_book to identify 'new book' situation and set flag; add
logic to handle 'new-book' situation by calling
gnc_new_book_option_display function
import-export/qif-import/qif-to-gnc.scm - use 'gnc_set_num_action' function
to import number to correct field based on book option
12. Modify Import OFX/QFX process to recognize a new-book situation and allow setting
of book options during first import into a new book; also follow book option
setting for num source in importing number whether new book or not:
import-export/ofx/gnc-ofx-import.c - use 'gnc_set_num_action' function to import
number based on book option; identify 'new book' situation using function
gnc_is_new_book and set flag; add logic to handle 'new-book' situation
by raising book options dialog by calling gnc_new_book_option_display
function
import-export/import-backend.c - use 'gnc_get_num_action' function to
retrieve number from transactions to be matched based on book option
13. Modify Import AqBanking process to recognize a new-book situation and allow
setting of book options during first import into a new book; also follow
book option setting for num source in importing number:
import-export/aqbanking/gnc-file-aqb-import.c - identify 'new book'
situation using function gnc_is_new_book and handle by raising book
options dialog by calling gnc_new_book_option_display function
import-export/aqbanking/gnc-ab-utils.c - use 'gnc_set_num_action' function
to set number based on book option
14. Modify Import Transactions from CSV process to recognize a new-book situation
and allow setting of book options during first import into a new book; also
follow book option setting for num source in importing number whether new
book or not:
import-export/csv-import/assistant-csv-trans-import.glade - modify
commments to alert user of raising book options dialog in cases of csv
import into a new book
import-export/csv-import/gnc-csv-model.c & h. - use 'gnc_set_num_action'
function to import number based on book option
import-export/csv-import/assistant-csv-trans-import.c - add logic to handle
'new-book' situation by raising book options dialog by calling
gnc_new_book_option_display function; identify 'new book' situation
using function gnc_is_new_book and set flag
15. Modify Import Accounts from CSV process to recognize a new-book situation
and allow setting of book options during first import into a new book
import-export/csv-import/assistant-csv-account-import.c & .h - add logic to
handle 'new-book' situation by raising book options dialog by calling
gnc_new_book_option_display function; identify 'new book' situation
using function gnc_is_new_book and set flag
16. Modify Export Transactions to CSV process to follow book option setting
for num source in exporting transactions:
import-export/csv-export/csv-transactions-export.c - modify headings to
reflect num-source book option and use 'gnc_get_num_action' function
to retrieve number and action
17. Modify register reporting to reflect book option setting for num source:
gnome/gnc-plugin-page-register.c - determine and pass along ledger-type?
argument to gnc:register-report-create function
gnome/gnc-plugin-page-register2.c - determine and pass along ledger-type?
argument to gnc:register-report-create function
report/standard-reports/standard-reports.scm - add ledger-type? argument
to gnc:register-report-create function; pass it along to
gnc:register-report-create-internal function
report/standard-reports/register.scm - add ledger-type? argument to
gnc:register-report-create-internal function; use 'gnc-get-num-action'
function in place of xaccTransGetNum and 'gnc-get-action-num' function
in place of xaccSplitGetAction and modify report headings and option
text accordingly
18. Modify all places that use xaccTransSetNum and/or xaccSplitSetAction to use
'gnc_set_num_action' function to set number based on book option except
engine/Transaction.c & .h, engine/test-core/test-engine-stuff.c,
engine/Split.c & .h, engine/test/utest-Split.c, engine/engine-helpers.c & .h,
engine/engine-interface.scm, backend/xml/gnc-transaction-xml-v2.c,
backend/xml/io-gncxml-v1.c, import-export/log-replay/gnc-log-replay.c:
engine/gncOwner.c - use 'gnc_set_num_action' function to set number based
on book option
engine/gncInvoice.c - use 'gnc_set_num_action' function to set number based
on book option
engine/SchedXaction.c - use 'gnc_set_num_action' function to set number and
action
engine/cap-gains.c - use 'gnc_set_num_action' function to set split-action
gnome-utils/dialog-transfer.c - use 'gnc_set_num_action' function to set
number based on book option
gnome-utils/gnc-tree-view-split-reg.c - use 'gnc_set_num_action' function
to set number/action based on book option
gnome/assistant-stock-split.c - use 'gnc_set_num_action' function to set
split-action
19. Modify all places that use xaccTransGetNum and/or xaccSplitGetAction to use
'gnc_get_num_action' or 'gnc_get_action_num' functions to get number based
on book option except engine/Transaction.c & .h,
engine/test-core/test-engine-stuff.c, engine/Split.c & h.,
engine/test/utest-Split.c, engine/engine-helpers.c,
engine/engine-interface.scm, backend/xml/gnc-transaction-xml-v2.c,
backend/xml/test/test-xml-transaction.c:
gnome/dialog-lot-viewer.c - use 'gnc_get_num_action' function to retrieve
number based on book option
gnome/dialog-sx-from-trans.c - use 'gnc_get_num_action' function to
retrieve number and action
gnome/dialog-print-check.c - use 'gnc_get_num_action' function to
retrieve number and 'gnc_get_action_num' function to retrieve action
register/ledger-core/split-register-model.c - use 'gnc_get_num_action'
function to retrieve number based on book option
register/ledger-core/split-register-load.c - use 'gnc_get_num_action'
function to retrieve number based on book option
register/ledger-core/split-register-control.c - use 'gnc_get_num_action'
function to retrieve action
register/ledger-core/split-register.c - use 'gnc_get_num_action'
function to retrieve transaction-num
engine/cap-gains.c - use 'gnc_get_num_action' function to get split-action
gnome-utils/gnc-tree-view-split-reg.c - use 'gnc_get_num_action' function
to retrieve number and 'gnc_get_action_num' function to retrieve action
gnome-utils/gnc-tree-model-split-reg.c - use 'gnc_get_num_action' function
to retrieve transaction-number but may not be getting what is expected
if book option to use split-action for 'num' is set
report/locale-specific/us/taxtxf.scm - use 'gnc-get-num-action' function in
place of xaccTransGetNum and 'gnc-get-action-num' function in place of
xaccSplitGetAction and modify report headings and option text accordingly
report/standard-reports/transaction.scm - use 'gnc-get-num-action' function
in place of xaccTransGetNum, adjust sorting based on book option and
modify report headings and option text accordingly; add 'SPLIT-ACTION'
as a term for sorting queries
report/business-reports/customer-summary.scm - use 'gnc-get-num-action'
function in place of xaccTransGetNum
report/business-reports/owner-report.scm - use 'gnc-get-num-action'
function in place of xaccTransGetNum
report/business-reports/job-report.scm - use 'gnc-get-num-action' function
in place of xaccTransGetNum
business/business-gnome/dialog-payment.c - use 'gnc_get_num_action'
function to retrieve number based on book option
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22681 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-12-22 00:00:54 -06:00
|
|
|
/** 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 */
|
2002-12-07 15:16:01 -06:00
|
|
|
void xaccTransSetNum (Transaction *trans, const char *num);
|
2012-08-07 12:24:33 -05:00
|
|
|
|
2003-03-14 17:59:25 -06:00
|
|
|
/** Sets the transaction Description */
|
2002-12-07 15:16:01 -06:00
|
|
|
void xaccTransSetDescription (Transaction *trans, const char *desc);
|
2012-08-07 12:24:33 -05:00
|
|
|
|
2013-11-15 16:02:34 -06:00
|
|
|
/** Sets the transaction Association */
|
|
|
|
void xaccTransSetAssociation (Transaction *trans, const char *assoc);
|
|
|
|
|
2003-03-14 17:59:25 -06:00
|
|
|
/** Sets the transaction Notes
|
2002-12-07 15:16:01 -06:00
|
|
|
*
|
|
|
|
The Notes field is only visible in the register in double-line mode */
|
|
|
|
void xaccTransSetNotes (Transaction *trans, const char *notes);
|
|
|
|
|
Implement a Book Option to give users the choice to use the transaction number field (default and current behaviour) or, alternatively, the split action field of the anchor split for 'Num' column on registers, reports, import and export, where applicable. The difference between the two is that with the default, the same 'Num' is displayed for a given transaction regardless of what register it is viewed in and with the new option, a different 'Num' can be entered/displayed for a given transaction in each register it is viewed in. In both cases, the 'next number logic' of the 'Num' cell is based on the account of the register the transaction is entered/viewed from but in one case it fills the transaction number, in the other, it fills the split action field of the anchor split (with the transaction number field displayed in the register cell labeled 'T-Num'). In both cases, both fields are visible and can be used as free-form text in double-line mode for any value the user wants. If the new option is not selected, there should be no change in Gnucash's behaviour with the exception of displaying the book options dialog in 'new book' situations.
The changes made are:
1. Implement the new book option to select source for 'num' cell:
libqof/qof/qofbookslots.h - define num source option
engine/engine.i - define 'NUM-FIELD-SOURCE' as an option name and
'SPLIT-ACTION' as a term for sorting queries
app-utils/business-prefs.scm - define book option for num-field-source
app-utils/app-utils.scm - define and export book option for num-field-source
2. Implement functions to get book option setting and to test:
libqof/qof/qofbook.c & .h - define function to get number source book option
libqof/qof/test/test-qofbook.c - test function to get number source book option
3. Implement a notification mechanism for book option changes:
engine/engine-helpers.c & .h - define functions to register callbacks,
define function to remove callbacks and
define function to initiate callbacks on book num-source option changes
core-utils/gnc-features.c & .h - define feature for num-source
app-utils/gnc-ui-util.c & .h - define gnc_book_option_num_field_source_change_cb;
include setting of feature flag on initial use
gnome-utils/gnc-main-window.c - change name of gnc_options_dialog_apply_cb
function to gnc_book_options_dialog_apply_cb and adjust function to
call function gnc_book_option_num_field_source_change_cb when book
option for num-field-source changes; change name of
gnc_options_dialog_close_cb to gnc_book_options_dialog_close_cb
4. Implement 'help' button response on Book Option Dialog:
gnome-utils/gnc-ui.h - define "book-options" section of help manual
gnome-utils/gnc-gnome-utils.c & .h - implement Book Options help callback
gnome-utils/gnc-main-window.c - use gnc_options_dialog_set_book_options_help_cb
to make help button active
5. Implement utility functions to get/set number/action based on book option:
engine/engine-helpers.c & .h - define 'gnc_get_num_action' function
define 'gnc_get_action_num' function
define 'gnc_set_num_action' function
engine/engine.i - make get/set num/action functions available to guile &
allow #f to be used in place of NULL from guile
engine/Transaction.h - add reference to utility functions in comments to
xaccTransSetNum and xaccTransGetNum functions
engine/Split.h - add reference to utility functions in comments to
xaccSplitSetAction and xaccSplitGetAction functions
6. Implement register use of num source book option; for General, Income and Search
Ledgers, since there is no anchor split, always show tran-num in transaction
cursor, but vary label to correspond to book option:
register/ledger-core/split-register.h - define TNUM_CELL
define CURSOR_DOUBLE_LEDGER_NUM_ACTN cursor name to use TNUM_CELL
define CURSOR_DOUBLE_JOURNAL_NUM_ACTN cursor name to use TNUM_CELL
add boolean to split_reg structure to hold num source book option
register/ledger-core/split-register-layout.c -
add logic to define and set up new ledger/journal cursors with TNUM_CELLs
add logic to add the new cursors to a layout
add logic to add TNUM_CELL to a layout
register/ledger-core/split-register-model.c -
define function to get TNUM_CELL label
add logic to recognize ledger/journal cursors with TNUM_CELL
modify function to get NUM_CELL value based on book option and register
type
define function to get TNUM_CELL value
adjust num help text to reflect book option choice
define function to get TNUM_CELL help
modify function to get action help to reflect book option choice
set up handlers for TNUM_CELL
register/ledger-core/split-register-model-save.c -
use 'gnc_set_num_action' function to set num/action for NUM_CELL based
on book option
define function to save TNUM_CELL using 'gnc_set_num_action' function
set save handler for TNUM_CELL
register/ledger-core/split-register-util.c -
modify logic to recognize ledger/journal cursors with tnum_cell
register/ledger-core/split-register.c -
define split_register_book_option_changed function
register split_register_book_option_changed function in register init
initialize register structure setting to book option
remove split_register_book_option_changed function in register destroy
modify gnc_split_register_save_to_scm to handle TNUM_CELL
7. Enhance transaction copy/duplicate logic to accommodate new book option:
gnome/gtkbuilder/gnc-plugin-page-register.glade -
add widgets to handle trans number and/or split action based on book option
gnome-utils/dialog-dup-trans.c & .h -
add capability to display and handle 'Num' field according to book option
gnome/gnc-plugin-page-register.c - define gnc_find_register_by_account
register/ledger-core/split-register.c -
modify gnc_split_register_duplicate_current to accomodate book option
setting
register/ledger-core/Makefile.am - add GNOME_CFLAGS
register/ledger-core/test/Makefile.am - add libgnc-gnome.la
8. Adjust register sort and sort labels related to Num/Action radio buttons to
correspond to book option for clarity:
gnome/gnc-plugin-page-register.c -
define gnc_plugin_page_register_sort_book_option_changed to adjust labels
register function in gnc_plugin_page_register_cmd_view_sort_by
and save num and action radio widgets
initialize radio widget labels to correspond to book option
remove function in gnc_plugin_page_register_sort_response_cb
and clear num and action radio widgets
gnome/gnc-split-reg.c & h. -
create versions of gnc_split_reg_sort and gnc_split_reg_set_sort to force
a re-sort to be used when num-source book option changes
engine/Transaction.c & .h -
modify default sort to use split action in place of tran num per book
option if called from xaccSplitOrder
engine/Split.c -
modify xaccSplitOrder to call xaccTransOrder_num_action to switch use of
split action and tran num per book option
engine/test/utest-Split.c -
modify test_xaccSplitOrder to call xaccTransOrder_num_action based on
book option
9. Adjust transaction find labels related to Num/Action to correspond to book option
for clarity:
gnome/dialog-find-transactions.c - adjust labels in search criteria based
on book option
gnome-search/dialog-search.c -
define gnc_search_dialog_book_option_changed to adjust labels
register function in gnc_search_dialog_init_widgets when searching
for splits
remove function in gnc_search_dialog_close_cb if registered
10. Modify new file process to allow setting of num-source (actually, all) book
option(s) during New Account Hierarchy Setup:
gnome-utils/gtkbuilder/dialog-preferences.glade - add a user preference for
the default setting for 'num-source' for new books
core-utils/gnc-gconf-utils.h - define KEY_NUM_SOURCE
gnome-utils/gnc-gnome-utils.c & h. -
define gnc_options_dialog_set_new_book_option_values to retrieve
preference values
gnome-utils/dialog-options.c & .h - define gnc_options_dialog_new_modal to
surpress apply button
gnome-utils/gnc-main-window.c - define function gnc_book_options_dialog_cb
with arguments so that the window can be called in modal mode and the
title changed and return dialog widget; call gnc_options_dialog_new_modal
instead of gnc_options_dialog_new; call this function from
gnc_main_window_cmd_file_properties with new arguments; for modal mode,
call gnc-options-dialog-set-new-book-option-values to initialize values
from preferences
app-utils/gnc-ui-util.c & h. - create function gnc_is_new_book for
determining when a new book is being created
gnome-utils/dialog-utils.c & h. - define gnc_new_book_option_display to
display book options dialog in modal mode
gnome/gtkbuilder/assistant-hierarchy.glade - add notification about book
options to currency page
gnome/assistant-hierarchy.c - add ability to set book option initialized
from preferences value for new books by using functions gnc_is_new_book
and gnc_new_book_option_display
11. Modify Import QIF process to recognize a new-book situation and allow setting
of book options during first import into a new book; also follow book option
setting for num source in importing number whether new book or not:
import-export/qif-import/assistant-qif-import.glade - add notification about
book options to currency page
import-export/qif-import/assistant-qif-import.c - using function
gnc_is_new_book to identify 'new book' situation and set flag; add
logic to handle 'new-book' situation by calling
gnc_new_book_option_display function
import-export/qif-import/qif-to-gnc.scm - use 'gnc_set_num_action' function
to import number to correct field based on book option
12. Modify Import OFX/QFX process to recognize a new-book situation and allow setting
of book options during first import into a new book; also follow book option
setting for num source in importing number whether new book or not:
import-export/ofx/gnc-ofx-import.c - use 'gnc_set_num_action' function to import
number based on book option; identify 'new book' situation using function
gnc_is_new_book and set flag; add logic to handle 'new-book' situation
by raising book options dialog by calling gnc_new_book_option_display
function
import-export/import-backend.c - use 'gnc_get_num_action' function to
retrieve number from transactions to be matched based on book option
13. Modify Import AqBanking process to recognize a new-book situation and allow
setting of book options during first import into a new book; also follow
book option setting for num source in importing number:
import-export/aqbanking/gnc-file-aqb-import.c - identify 'new book'
situation using function gnc_is_new_book and handle by raising book
options dialog by calling gnc_new_book_option_display function
import-export/aqbanking/gnc-ab-utils.c - use 'gnc_set_num_action' function
to set number based on book option
14. Modify Import Transactions from CSV process to recognize a new-book situation
and allow setting of book options during first import into a new book; also
follow book option setting for num source in importing number whether new
book or not:
import-export/csv-import/assistant-csv-trans-import.glade - modify
commments to alert user of raising book options dialog in cases of csv
import into a new book
import-export/csv-import/gnc-csv-model.c & h. - use 'gnc_set_num_action'
function to import number based on book option
import-export/csv-import/assistant-csv-trans-import.c - add logic to handle
'new-book' situation by raising book options dialog by calling
gnc_new_book_option_display function; identify 'new book' situation
using function gnc_is_new_book and set flag
15. Modify Import Accounts from CSV process to recognize a new-book situation
and allow setting of book options during first import into a new book
import-export/csv-import/assistant-csv-account-import.c & .h - add logic to
handle 'new-book' situation by raising book options dialog by calling
gnc_new_book_option_display function; identify 'new book' situation
using function gnc_is_new_book and set flag
16. Modify Export Transactions to CSV process to follow book option setting
for num source in exporting transactions:
import-export/csv-export/csv-transactions-export.c - modify headings to
reflect num-source book option and use 'gnc_get_num_action' function
to retrieve number and action
17. Modify register reporting to reflect book option setting for num source:
gnome/gnc-plugin-page-register.c - determine and pass along ledger-type?
argument to gnc:register-report-create function
gnome/gnc-plugin-page-register2.c - determine and pass along ledger-type?
argument to gnc:register-report-create function
report/standard-reports/standard-reports.scm - add ledger-type? argument
to gnc:register-report-create function; pass it along to
gnc:register-report-create-internal function
report/standard-reports/register.scm - add ledger-type? argument to
gnc:register-report-create-internal function; use 'gnc-get-num-action'
function in place of xaccTransGetNum and 'gnc-get-action-num' function
in place of xaccSplitGetAction and modify report headings and option
text accordingly
18. Modify all places that use xaccTransSetNum and/or xaccSplitSetAction to use
'gnc_set_num_action' function to set number based on book option except
engine/Transaction.c & .h, engine/test-core/test-engine-stuff.c,
engine/Split.c & .h, engine/test/utest-Split.c, engine/engine-helpers.c & .h,
engine/engine-interface.scm, backend/xml/gnc-transaction-xml-v2.c,
backend/xml/io-gncxml-v1.c, import-export/log-replay/gnc-log-replay.c:
engine/gncOwner.c - use 'gnc_set_num_action' function to set number based
on book option
engine/gncInvoice.c - use 'gnc_set_num_action' function to set number based
on book option
engine/SchedXaction.c - use 'gnc_set_num_action' function to set number and
action
engine/cap-gains.c - use 'gnc_set_num_action' function to set split-action
gnome-utils/dialog-transfer.c - use 'gnc_set_num_action' function to set
number based on book option
gnome-utils/gnc-tree-view-split-reg.c - use 'gnc_set_num_action' function
to set number/action based on book option
gnome/assistant-stock-split.c - use 'gnc_set_num_action' function to set
split-action
19. Modify all places that use xaccTransGetNum and/or xaccSplitGetAction to use
'gnc_get_num_action' or 'gnc_get_action_num' functions to get number based
on book option except engine/Transaction.c & .h,
engine/test-core/test-engine-stuff.c, engine/Split.c & h.,
engine/test/utest-Split.c, engine/engine-helpers.c,
engine/engine-interface.scm, backend/xml/gnc-transaction-xml-v2.c,
backend/xml/test/test-xml-transaction.c:
gnome/dialog-lot-viewer.c - use 'gnc_get_num_action' function to retrieve
number based on book option
gnome/dialog-sx-from-trans.c - use 'gnc_get_num_action' function to
retrieve number and action
gnome/dialog-print-check.c - use 'gnc_get_num_action' function to
retrieve number and 'gnc_get_action_num' function to retrieve action
register/ledger-core/split-register-model.c - use 'gnc_get_num_action'
function to retrieve number based on book option
register/ledger-core/split-register-load.c - use 'gnc_get_num_action'
function to retrieve number based on book option
register/ledger-core/split-register-control.c - use 'gnc_get_num_action'
function to retrieve action
register/ledger-core/split-register.c - use 'gnc_get_num_action'
function to retrieve transaction-num
engine/cap-gains.c - use 'gnc_get_num_action' function to get split-action
gnome-utils/gnc-tree-view-split-reg.c - use 'gnc_get_num_action' function
to retrieve number and 'gnc_get_action_num' function to retrieve action
gnome-utils/gnc-tree-model-split-reg.c - use 'gnc_get_num_action' function
to retrieve transaction-number but may not be getting what is expected
if book option to use split-action for 'num' is set
report/locale-specific/us/taxtxf.scm - use 'gnc-get-num-action' function in
place of xaccTransGetNum and 'gnc-get-action-num' function in place of
xaccSplitGetAction and modify report headings and option text accordingly
report/standard-reports/transaction.scm - use 'gnc-get-num-action' function
in place of xaccTransGetNum, adjust sorting based on book option and
modify report headings and option text accordingly; add 'SPLIT-ACTION'
as a term for sorting queries
report/business-reports/customer-summary.scm - use 'gnc-get-num-action'
function in place of xaccTransGetNum
report/business-reports/owner-report.scm - use 'gnc-get-num-action'
function in place of xaccTransGetNum
report/business-reports/job-report.scm - use 'gnc-get-num-action' function
in place of xaccTransGetNum
business/business-gnome/dialog-payment.c - use 'gnc_get_num_action'
function to retrieve number based on book option
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22681 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-12-22 00:00:54 -06:00
|
|
|
/** 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 */
|
2002-12-07 15:16:01 -06:00
|
|
|
const char * xaccTransGetNum (const Transaction *trans);
|
2003-03-14 17:59:25 -06:00
|
|
|
/** Gets the transaction Description */
|
2002-12-07 15:16:01 -06:00
|
|
|
const char * xaccTransGetDescription (const Transaction *trans);
|
2013-11-15 16:02:34 -06:00
|
|
|
/** Gets the transaction association */
|
|
|
|
const char * xaccTransGetAssociation(const Transaction *trans);
|
2003-03-14 17:59:25 -06:00
|
|
|
/** Gets the transaction Notes
|
2002-12-07 15:16:01 -06:00
|
|
|
*
|
|
|
|
The Notes field is only visible in the register in double-line mode */
|
|
|
|
const char * xaccTransGetNotes (const Transaction *trans);
|
|
|
|
|
|
|
|
|
2010-12-15 20:11:53 -06:00
|
|
|
/** Sets whether or not this transaction is a "closing transaction" */
|
|
|
|
void xaccTransSetIsClosingTxn (Transaction *trans, gboolean is_closing);
|
|
|
|
|
|
|
|
/** Returns whether this transaction is a "closing transaction" */
|
|
|
|
gboolean xaccTransGetIsClosingTxn (const Transaction *trans);
|
|
|
|
|
|
|
|
|
2003-03-14 17:59:25 -06:00
|
|
|
/** Add a split to the transaction
|
2010-02-17 23:31:54 -06:00
|
|
|
*
|
|
|
|
The xaccTransAppendSplit() method will append the indicated
|
2002-12-07 15:16:01 -06:00
|
|
|
split to the collection of splits in this transaction.
|
|
|
|
@note If the split is already a part of another transaction,
|
|
|
|
it will be removed from that transaction first.
|
|
|
|
*/
|
2006-03-03 18:10:12 -06:00
|
|
|
#define xaccTransAppendSplit(t, s) xaccSplitSetParent((s), (t))
|
2002-12-07 15:16:01 -06:00
|
|
|
|
2010-02-17 23:31:54 -06:00
|
|
|
/** The xaccTransGetSplit() method returns a pointer to each of the
|
2002-12-07 15:16:01 -06:00
|
|
|
splits in this transaction.
|
2010-02-17 23:31:54 -06:00
|
|
|
@param trans The transaction
|
|
|
|
@param i The split number. Valid values for i are zero to
|
2002-12-07 15:16:01 -06:00
|
|
|
(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. */
|
|
|
|
Split * xaccTransGetSplit (const Transaction *trans, int i);
|
|
|
|
|
2006-03-07 23:47:36 -06:00
|
|
|
/** Inverse of xaccTransGetSplit() */
|
|
|
|
int xaccTransGetSplitIndex(const Transaction *trans, const Split *split);
|
|
|
|
|
2002-12-07 15:16:01 -06:00
|
|
|
/** The xaccTransGetSplitList() method returns a GList of the splits
|
2010-02-17 23:31:54 -06:00
|
|
|
in a transaction.
|
2017-11-13 12:15:04 -06:00
|
|
|
@param trans The transaction
|
2002-12-07 15:16:01 -06:00
|
|
|
@return The list of splits. This list must NOT be modified. Do *NOT* free
|
|
|
|
this list when you are done with it. */
|
2010-02-17 23:31:54 -06:00
|
|
|
/*@ dependent @*/
|
|
|
|
SplitList * xaccTransGetSplitList (const Transaction *trans);
|
2017-11-13 12:15:04 -06:00
|
|
|
|
|
|
|
/** 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.
|
|
|
|
@param trans The transaction
|
|
|
|
@return The list of splits. This list must be freed when you are done with it. */
|
|
|
|
SplitList * xaccTransGetPaymentAcctSplitList (const Transaction *trans);
|
|
|
|
|
|
|
|
/** The xaccTransGetAPARSplitList() method returns a GList of the splits
|
|
|
|
in a transaction that belong to an AR or AP account.
|
|
|
|
@param trans The transaction
|
|
|
|
@param 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
|
|
|
|
@return The list of splits. This list must be freed when you are done with it. */
|
|
|
|
SplitList * xaccTransGetAPARAcctSplitList (const Transaction *trans, gboolean strict);
|
|
|
|
|
|
|
|
|
2012-08-07 12:24:33 -05:00
|
|
|
gboolean xaccTransStillHasSplit(const Transaction *trans, const Split *s);
|
2002-12-07 15:16:01 -06:00
|
|
|
|
2016-03-25 06:10:10 -05:00
|
|
|
/** 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.
|
|
|
|
@param trans The transaction
|
|
|
|
|
|
|
|
If there is no such split in the transaction NULL will be returned. */
|
|
|
|
Split * xaccTransGetFirstPaymentAcctSplit (const Transaction *trans);
|
|
|
|
|
|
|
|
/** The xaccTransGetFirstPaymentAcctSplit() method returns a pointer to the first
|
|
|
|
split in this transaction that belongs to an AR or AP account.
|
|
|
|
@param trans The transaction
|
2017-11-13 12:15:04 -06:00
|
|
|
@param 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
|
2016-03-25 06:10:10 -05:00
|
|
|
|
|
|
|
If there is no such split in the transaction NULL will be returned. */
|
2017-11-13 12:15:04 -06:00
|
|
|
Split * xaccTransGetFirstAPARAcctSplit (const Transaction *trans, gboolean strict);
|
2016-03-25 06:10:10 -05:00
|
|
|
|
2012-03-24 17:34:44 -05:00
|
|
|
/** 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(). */
|
2002-11-05 00:41:45 -06:00
|
|
|
void xaccTransSetReadOnly (Transaction *trans, const char *reason);
|
2003-01-01 22:07:58 -06:00
|
|
|
void xaccTransClearReadOnly (Transaction *trans);
|
2012-03-24 17:34:44 -05:00
|
|
|
|
|
|
|
/** Returns a non-NULL value if this Transaction was marked as read-only with
|
|
|
|
* some specific "reason" text. */
|
2018-09-09 15:49:52 -05:00
|
|
|
const char * xaccTransGetReadOnly (Transaction *trans);
|
2002-11-05 00:41:45 -06:00
|
|
|
|
2012-03-24 17:34:44 -05:00
|
|
|
/** 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(). */
|
|
|
|
gboolean xaccTransIsReadonlyByPostedDate(const Transaction *trans);
|
|
|
|
|
2012-10-18 03:15:21 -05:00
|
|
|
/*################## Added for Reg2 #################*/
|
|
|
|
|
|
|
|
/** Returns TRUE if this Transaction's posted-date is in the future */
|
|
|
|
gboolean xaccTransInFutureByPostedDate (const Transaction *trans);
|
|
|
|
|
|
|
|
/*################## Added for Reg2 #################*/
|
|
|
|
|
2002-12-07 20:19:10 -06:00
|
|
|
/** Returns the number of splits in this transaction. */
|
2002-12-07 07:05:45 -06:00
|
|
|
int xaccTransCountSplits (const Transaction *trans);
|
2001-08-07 18:36:04 -05:00
|
|
|
|
2002-12-07 20:19:10 -06:00
|
|
|
/** FIXME: document me */
|
2002-12-07 07:05:45 -06:00
|
|
|
gboolean xaccTransHasReconciledSplits (const Transaction *trans);
|
2002-12-07 20:19:10 -06:00
|
|
|
/** FIXME: document me */
|
2002-12-07 07:05:45 -06:00
|
|
|
gboolean xaccTransHasReconciledSplitsByAccount (const Transaction *trans,
|
2010-02-17 23:31:54 -06:00
|
|
|
const Account *account);
|
2002-10-25 22:54:14 -05:00
|
|
|
|
2003-06-15 22:48:59 -05:00
|
|
|
/** FIXME: document me */
|
|
|
|
gboolean xaccTransHasSplitsInState (const Transaction *trans, const char state);
|
|
|
|
/** FIXME: document me */
|
|
|
|
gboolean xaccTransHasSplitsInStateByAccount (const Transaction *trans,
|
2010-02-17 23:31:54 -06:00
|
|
|
const char state,
|
|
|
|
const Account *account);
|
2003-06-15 22:48:59 -05:00
|
|
|
|
2002-12-07 15:16:01 -06:00
|
|
|
|
2003-04-01 22:22:02 -06:00
|
|
|
/** Returns the valuation commodity of this transaction.
|
2002-12-07 15:16:01 -06:00
|
|
|
*
|
2003-04-01 22:22:02 -06:00
|
|
|
* Each transaction's valuation commodity, or 'currency' is, by definition,
|
|
|
|
* the common currency in which all splits in the transaction can be valued.
|
2010-02-17 23:31:54 -06:00
|
|
|
* The total value of the transaction must be zero when all splits
|
2003-04-01 22:22:02 -06:00
|
|
|
* are valued in this currency.
|
|
|
|
* @note What happens if the Currency isn't set? Ans: bad things. */
|
2010-02-17 23:31:54 -06:00
|
|
|
/*@ dependent @*/
|
|
|
|
gnc_commodity * xaccTransGetCurrency (const Transaction *trans);
|
2002-12-07 20:19:10 -06:00
|
|
|
|
|
|
|
/** Set the commodity of this transaction. */
|
2001-08-07 18:36:04 -05:00
|
|
|
void xaccTransSetCurrency (Transaction *trans, gnc_commodity *curr);
|
2002-12-07 15:16:01 -06:00
|
|
|
|
Bug #537476: Implement currency trading accounts optionally, to be enabled per-book.
Patch by Mike Alexander:
This patch implements trading accounts somewhat as described in Peter
Selinger's document at
<http://www.mathstat.dal.ca/~selinger/accounting/gnucash.html>. Although he
describes it as a multiple currency problem, it really applies to any
transactions involving multiple commodities (for example buying or selling a
stock) Hence I've called the trading accounts "commodity exchange accounts"
which seems more descriptive.
In summary these patches add an option to use commodity exchange accounts and
if it is on a transaction must be balanced both in value (in the transaction
currency) and in each commodity or currency used in any split in the
transaction. If a transaction only contains splits in the transaction currency
then this is the same rule as Gnucash has always enforced.
In this patch, the option to use trading accounts has been moved from
Edit->Preferences to File->Properties and is now associated with the active
book instead of being a global option. If you have set the global value on in
a previous version you will need to set it on again in each file for which you
want trading accounts, the previous global setting will be ignored.
A more detailed list of changes follows:
1. Added a "Use commodity exchange accounts" per-book option.
2. Added gnc_monetary and MonetaryList data types.
3. Renamed xaccTransGetImbalance to xaccTransGetImbalanceValue and added a new
xaccTransGetImbalance that returns a MonetaryList. Also added
xaccTransIsBalanced to see if the transaction is balanced without returning a
GList that needs to be freed. It calls both xaccTransGetImbalance and
xaccTransGetImbalanceValue since a transaction may be unbalanced with regard to
either without being unbalanced with regard to the other.
4. Changed gnc_split_register_get_debcred_bg_color to use xaccTransIsBalanced.
5. Changed gnc_split_register_balance_trans to not offer to adjust an existing
split if there imbalances in multiple currencies. Because of bugs in the
register code this is rarely called.
6. Changed importers to use xaccTransGetImbalanceValue to check for imbalance,
assuming that they won't create multiple currency trasactions.
7. Changed xaccTransScrubImbalance to create a balancing split for each
imbalanced commodity in the transaction. Also balances the transaction value.
The commodity balancing splits go into accounts in the hierarchy
Trading:NAMESPACE:COMMODITY. The value balancing splits go into
Imbalance-CURRENCY as before.
8. Changed xaccSplitConvertAmount to use xaccTransIsBalanced instead of
xaccTransGetImbalance.
9. Changed gnc_split_register_get_debcred_entry to sometimes use the split
amount instead of value if using currency accounts.
If the register is a stock register (i.e., shows shares and prices), it uses
the value if the split is in the register commodity (i.e. is for the stock) and
the amount otherwise. It shows the currency symbol unless the commodity is the
default currency.
If the register is not a stock register it always uses the amount and shows the
currency symbol if the split is not in the register commodity.
Also changed it to not return a value for a null split unless the transaction
is unbalanced in exactly one currency. This is what goes in a blank split as
the proposed value.
10. Changed refresh_model_row to use xaccTransGetImbalanceValue to get the
imbalance, assuming that importers don't create transactions in multiple
currencies. Also same change in gnc_import_process_trans_item,
downloaded_transaction_append, and gnc_import_TransInfo_is_balanced.
11. Changed the TRANS_IMBALANCE accessor method in xaccTransRegister to use
xaccTransGetImbalanceValue. As far as I can tell this is only used by the
"pd-balance" query type in gnc_scm2query_term_query_v1() defined in
engine-helpers.c. This query type only tests the result for zero/non-zero.
12. Changed xaccTransGetAccountConvRate to accept any split into the correct
commodity instead of insisting on one into the provided account. Then can use
it in xaccTransScrubImbalance to set the value of the imbalance split from its
amount, however later changed xaccTransScrubImbalance to not use it. Instead
it sets the value for the new split correctly to keep the value of the whole
transaction balanced.
13. Changed the balance sheet report to include a new option to not compute
unrealized gains and losses.
14. Related to 9 above, changed gnc_split_register_auto_calc to not do anything
if given a stock register where the value cell doesn't contain the value.
15. Also related to 9, changed gnc_split_register_save_amount_values to set the
amount and value fields in the split correctly when using trading accounts.
16. Changed the new account and edit account dialogs to allow any commodity or
currency for an income account if using trading accounts. It would be better
to add a new account type for trading accounts, but that's a big deal and I'll
leave that for later after we see whether this set of changes is going to be
accepted or rejected.
17. Change gnc_xfer_dialog_run_exchange_dialog to understand that the new value
is really the split's amount if using trading accounts.
18. Changed xaccSplitGetOtherSplit to ignore trading splits if using commodity
exchange accounts.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18429 57a11ea4-9604-0410-9ed3-97b8803252fd
2009-11-20 14:11:03 -06:00
|
|
|
/** The xaccTransGetImbalanceValue() method returns the total value of the
|
2002-12-07 15:16:01 -06:00
|
|
|
* 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()
|
2010-02-17 23:31:54 -06:00
|
|
|
* method.
|
Bug #537476: Implement currency trading accounts optionally, to be enabled per-book.
Patch by Mike Alexander:
This patch implements trading accounts somewhat as described in Peter
Selinger's document at
<http://www.mathstat.dal.ca/~selinger/accounting/gnucash.html>. Although he
describes it as a multiple currency problem, it really applies to any
transactions involving multiple commodities (for example buying or selling a
stock) Hence I've called the trading accounts "commodity exchange accounts"
which seems more descriptive.
In summary these patches add an option to use commodity exchange accounts and
if it is on a transaction must be balanced both in value (in the transaction
currency) and in each commodity or currency used in any split in the
transaction. If a transaction only contains splits in the transaction currency
then this is the same rule as Gnucash has always enforced.
In this patch, the option to use trading accounts has been moved from
Edit->Preferences to File->Properties and is now associated with the active
book instead of being a global option. If you have set the global value on in
a previous version you will need to set it on again in each file for which you
want trading accounts, the previous global setting will be ignored.
A more detailed list of changes follows:
1. Added a "Use commodity exchange accounts" per-book option.
2. Added gnc_monetary and MonetaryList data types.
3. Renamed xaccTransGetImbalance to xaccTransGetImbalanceValue and added a new
xaccTransGetImbalance that returns a MonetaryList. Also added
xaccTransIsBalanced to see if the transaction is balanced without returning a
GList that needs to be freed. It calls both xaccTransGetImbalance and
xaccTransGetImbalanceValue since a transaction may be unbalanced with regard to
either without being unbalanced with regard to the other.
4. Changed gnc_split_register_get_debcred_bg_color to use xaccTransIsBalanced.
5. Changed gnc_split_register_balance_trans to not offer to adjust an existing
split if there imbalances in multiple currencies. Because of bugs in the
register code this is rarely called.
6. Changed importers to use xaccTransGetImbalanceValue to check for imbalance,
assuming that they won't create multiple currency trasactions.
7. Changed xaccTransScrubImbalance to create a balancing split for each
imbalanced commodity in the transaction. Also balances the transaction value.
The commodity balancing splits go into accounts in the hierarchy
Trading:NAMESPACE:COMMODITY. The value balancing splits go into
Imbalance-CURRENCY as before.
8. Changed xaccSplitConvertAmount to use xaccTransIsBalanced instead of
xaccTransGetImbalance.
9. Changed gnc_split_register_get_debcred_entry to sometimes use the split
amount instead of value if using currency accounts.
If the register is a stock register (i.e., shows shares and prices), it uses
the value if the split is in the register commodity (i.e. is for the stock) and
the amount otherwise. It shows the currency symbol unless the commodity is the
default currency.
If the register is not a stock register it always uses the amount and shows the
currency symbol if the split is not in the register commodity.
Also changed it to not return a value for a null split unless the transaction
is unbalanced in exactly one currency. This is what goes in a blank split as
the proposed value.
10. Changed refresh_model_row to use xaccTransGetImbalanceValue to get the
imbalance, assuming that importers don't create transactions in multiple
currencies. Also same change in gnc_import_process_trans_item,
downloaded_transaction_append, and gnc_import_TransInfo_is_balanced.
11. Changed the TRANS_IMBALANCE accessor method in xaccTransRegister to use
xaccTransGetImbalanceValue. As far as I can tell this is only used by the
"pd-balance" query type in gnc_scm2query_term_query_v1() defined in
engine-helpers.c. This query type only tests the result for zero/non-zero.
12. Changed xaccTransGetAccountConvRate to accept any split into the correct
commodity instead of insisting on one into the provided account. Then can use
it in xaccTransScrubImbalance to set the value of the imbalance split from its
amount, however later changed xaccTransScrubImbalance to not use it. Instead
it sets the value for the new split correctly to keep the value of the whole
transaction balanced.
13. Changed the balance sheet report to include a new option to not compute
unrealized gains and losses.
14. Related to 9 above, changed gnc_split_register_auto_calc to not do anything
if given a stock register where the value cell doesn't contain the value.
15. Also related to 9, changed gnc_split_register_save_amount_values to set the
amount and value fields in the split correctly when using trading accounts.
16. Changed the new account and edit account dialogs to allow any commodity or
currency for an income account if using trading accounts. It would be better
to add a new account type for trading accounts, but that's a big deal and I'll
leave that for later after we see whether this set of changes is going to be
accepted or rejected.
17. Change gnc_xfer_dialog_run_exchange_dialog to understand that the new value
is really the split's amount if using trading accounts.
18. Changed xaccSplitGetOtherSplit to ignore trading splits if using commodity
exchange accounts.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18429 57a11ea4-9604-0410-9ed3-97b8803252fd
2009-11-20 14:11:03 -06:00
|
|
|
*
|
2010-02-17 23:31:54 -06:00
|
|
|
* If the use of currency exchange accounts is enabled then the a
|
Bug #537476: Implement currency trading accounts optionally, to be enabled per-book.
Patch by Mike Alexander:
This patch implements trading accounts somewhat as described in Peter
Selinger's document at
<http://www.mathstat.dal.ca/~selinger/accounting/gnucash.html>. Although he
describes it as a multiple currency problem, it really applies to any
transactions involving multiple commodities (for example buying or selling a
stock) Hence I've called the trading accounts "commodity exchange accounts"
which seems more descriptive.
In summary these patches add an option to use commodity exchange accounts and
if it is on a transaction must be balanced both in value (in the transaction
currency) and in each commodity or currency used in any split in the
transaction. If a transaction only contains splits in the transaction currency
then this is the same rule as Gnucash has always enforced.
In this patch, the option to use trading accounts has been moved from
Edit->Preferences to File->Properties and is now associated with the active
book instead of being a global option. If you have set the global value on in
a previous version you will need to set it on again in each file for which you
want trading accounts, the previous global setting will be ignored.
A more detailed list of changes follows:
1. Added a "Use commodity exchange accounts" per-book option.
2. Added gnc_monetary and MonetaryList data types.
3. Renamed xaccTransGetImbalance to xaccTransGetImbalanceValue and added a new
xaccTransGetImbalance that returns a MonetaryList. Also added
xaccTransIsBalanced to see if the transaction is balanced without returning a
GList that needs to be freed. It calls both xaccTransGetImbalance and
xaccTransGetImbalanceValue since a transaction may be unbalanced with regard to
either without being unbalanced with regard to the other.
4. Changed gnc_split_register_get_debcred_bg_color to use xaccTransIsBalanced.
5. Changed gnc_split_register_balance_trans to not offer to adjust an existing
split if there imbalances in multiple currencies. Because of bugs in the
register code this is rarely called.
6. Changed importers to use xaccTransGetImbalanceValue to check for imbalance,
assuming that they won't create multiple currency trasactions.
7. Changed xaccTransScrubImbalance to create a balancing split for each
imbalanced commodity in the transaction. Also balances the transaction value.
The commodity balancing splits go into accounts in the hierarchy
Trading:NAMESPACE:COMMODITY. The value balancing splits go into
Imbalance-CURRENCY as before.
8. Changed xaccSplitConvertAmount to use xaccTransIsBalanced instead of
xaccTransGetImbalance.
9. Changed gnc_split_register_get_debcred_entry to sometimes use the split
amount instead of value if using currency accounts.
If the register is a stock register (i.e., shows shares and prices), it uses
the value if the split is in the register commodity (i.e. is for the stock) and
the amount otherwise. It shows the currency symbol unless the commodity is the
default currency.
If the register is not a stock register it always uses the amount and shows the
currency symbol if the split is not in the register commodity.
Also changed it to not return a value for a null split unless the transaction
is unbalanced in exactly one currency. This is what goes in a blank split as
the proposed value.
10. Changed refresh_model_row to use xaccTransGetImbalanceValue to get the
imbalance, assuming that importers don't create transactions in multiple
currencies. Also same change in gnc_import_process_trans_item,
downloaded_transaction_append, and gnc_import_TransInfo_is_balanced.
11. Changed the TRANS_IMBALANCE accessor method in xaccTransRegister to use
xaccTransGetImbalanceValue. As far as I can tell this is only used by the
"pd-balance" query type in gnc_scm2query_term_query_v1() defined in
engine-helpers.c. This query type only tests the result for zero/non-zero.
12. Changed xaccTransGetAccountConvRate to accept any split into the correct
commodity instead of insisting on one into the provided account. Then can use
it in xaccTransScrubImbalance to set the value of the imbalance split from its
amount, however later changed xaccTransScrubImbalance to not use it. Instead
it sets the value for the new split correctly to keep the value of the whole
transaction balanced.
13. Changed the balance sheet report to include a new option to not compute
unrealized gains and losses.
14. Related to 9 above, changed gnc_split_register_auto_calc to not do anything
if given a stock register where the value cell doesn't contain the value.
15. Also related to 9, changed gnc_split_register_save_amount_values to set the
amount and value fields in the split correctly when using trading accounts.
16. Changed the new account and edit account dialogs to allow any commodity or
currency for an income account if using trading accounts. It would be better
to add a new account type for trading accounts, but that's a big deal and I'll
leave that for later after we see whether this set of changes is going to be
accepted or rejected.
17. Change gnc_xfer_dialog_run_exchange_dialog to understand that the new value
is really the split's amount if using trading accounts.
18. Changed xaccSplitGetOtherSplit to ignore trading splits if using commodity
exchange accounts.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18429 57a11ea4-9604-0410-9ed3-97b8803252fd
2009-11-20 14:11:03 -06:00
|
|
|
* 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. */
|
|
|
|
gnc_numeric xaccTransGetImbalanceValue (const Transaction * trans);
|
|
|
|
|
2010-02-17 23:31:54 -06:00
|
|
|
/** The xaccTransGetImbalance method returns a list giving the value of
|
|
|
|
* the transaction in each currency for which the balance is not zero.
|
Bug #537476: Implement currency trading accounts optionally, to be enabled per-book.
Patch by Mike Alexander:
This patch implements trading accounts somewhat as described in Peter
Selinger's document at
<http://www.mathstat.dal.ca/~selinger/accounting/gnucash.html>. Although he
describes it as a multiple currency problem, it really applies to any
transactions involving multiple commodities (for example buying or selling a
stock) Hence I've called the trading accounts "commodity exchange accounts"
which seems more descriptive.
In summary these patches add an option to use commodity exchange accounts and
if it is on a transaction must be balanced both in value (in the transaction
currency) and in each commodity or currency used in any split in the
transaction. If a transaction only contains splits in the transaction currency
then this is the same rule as Gnucash has always enforced.
In this patch, the option to use trading accounts has been moved from
Edit->Preferences to File->Properties and is now associated with the active
book instead of being a global option. If you have set the global value on in
a previous version you will need to set it on again in each file for which you
want trading accounts, the previous global setting will be ignored.
A more detailed list of changes follows:
1. Added a "Use commodity exchange accounts" per-book option.
2. Added gnc_monetary and MonetaryList data types.
3. Renamed xaccTransGetImbalance to xaccTransGetImbalanceValue and added a new
xaccTransGetImbalance that returns a MonetaryList. Also added
xaccTransIsBalanced to see if the transaction is balanced without returning a
GList that needs to be freed. It calls both xaccTransGetImbalance and
xaccTransGetImbalanceValue since a transaction may be unbalanced with regard to
either without being unbalanced with regard to the other.
4. Changed gnc_split_register_get_debcred_bg_color to use xaccTransIsBalanced.
5. Changed gnc_split_register_balance_trans to not offer to adjust an existing
split if there imbalances in multiple currencies. Because of bugs in the
register code this is rarely called.
6. Changed importers to use xaccTransGetImbalanceValue to check for imbalance,
assuming that they won't create multiple currency trasactions.
7. Changed xaccTransScrubImbalance to create a balancing split for each
imbalanced commodity in the transaction. Also balances the transaction value.
The commodity balancing splits go into accounts in the hierarchy
Trading:NAMESPACE:COMMODITY. The value balancing splits go into
Imbalance-CURRENCY as before.
8. Changed xaccSplitConvertAmount to use xaccTransIsBalanced instead of
xaccTransGetImbalance.
9. Changed gnc_split_register_get_debcred_entry to sometimes use the split
amount instead of value if using currency accounts.
If the register is a stock register (i.e., shows shares and prices), it uses
the value if the split is in the register commodity (i.e. is for the stock) and
the amount otherwise. It shows the currency symbol unless the commodity is the
default currency.
If the register is not a stock register it always uses the amount and shows the
currency symbol if the split is not in the register commodity.
Also changed it to not return a value for a null split unless the transaction
is unbalanced in exactly one currency. This is what goes in a blank split as
the proposed value.
10. Changed refresh_model_row to use xaccTransGetImbalanceValue to get the
imbalance, assuming that importers don't create transactions in multiple
currencies. Also same change in gnc_import_process_trans_item,
downloaded_transaction_append, and gnc_import_TransInfo_is_balanced.
11. Changed the TRANS_IMBALANCE accessor method in xaccTransRegister to use
xaccTransGetImbalanceValue. As far as I can tell this is only used by the
"pd-balance" query type in gnc_scm2query_term_query_v1() defined in
engine-helpers.c. This query type only tests the result for zero/non-zero.
12. Changed xaccTransGetAccountConvRate to accept any split into the correct
commodity instead of insisting on one into the provided account. Then can use
it in xaccTransScrubImbalance to set the value of the imbalance split from its
amount, however later changed xaccTransScrubImbalance to not use it. Instead
it sets the value for the new split correctly to keep the value of the whole
transaction balanced.
13. Changed the balance sheet report to include a new option to not compute
unrealized gains and losses.
14. Related to 9 above, changed gnc_split_register_auto_calc to not do anything
if given a stock register where the value cell doesn't contain the value.
15. Also related to 9, changed gnc_split_register_save_amount_values to set the
amount and value fields in the split correctly when using trading accounts.
16. Changed the new account and edit account dialogs to allow any commodity or
currency for an income account if using trading accounts. It would be better
to add a new account type for trading accounts, but that's a big deal and I'll
leave that for later after we see whether this set of changes is going to be
accepted or rejected.
17. Change gnc_xfer_dialog_run_exchange_dialog to understand that the new value
is really the split's amount if using trading accounts.
18. Changed xaccSplitGetOtherSplit to ignore trading splits if using commodity
exchange accounts.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18429 57a11ea4-9604-0410-9ed3-97b8803252fd
2009-11-20 14:11:03 -06:00
|
|
|
* 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. */
|
|
|
|
MonetaryList *xaccTransGetImbalance (const Transaction * trans);
|
|
|
|
|
|
|
|
/** Returns true if the transaction is balanced according to the rules
|
|
|
|
* currently in effect. */
|
|
|
|
gboolean xaccTransIsBalanced(const Transaction * trans);
|
2001-08-07 18:36:04 -05:00
|
|
|
|
2002-12-07 15:16:01 -06:00
|
|
|
/** The xaccTransGetAccountValue() method returns the total value applied
|
2002-12-07 20:19:10 -06:00
|
|
|
* to a particular account. In some cases there may be multiple Splits
|
2002-12-07 15:16:01 -06:00
|
|
|
* 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.
|
2002-06-26 21:11:17 -05:00
|
|
|
*/
|
2010-02-17 23:31:54 -06:00
|
|
|
gnc_numeric xaccTransGetAccountValue (const Transaction *trans,
|
|
|
|
const Account *account);
|
2002-06-26 21:11:17 -05:00
|
|
|
|
2006-01-29 20:59:43 -06:00
|
|
|
/** Same as xaccTransGetAccountValue, but uses the Account's commodity. */
|
|
|
|
gnc_numeric xaccTransGetAccountAmount (const Transaction *trans,
|
|
|
|
const Account *account);
|
|
|
|
|
2012-10-18 03:15:21 -05:00
|
|
|
/*################## Added for Reg2 #################*/
|
2012-08-07 12:24:33 -05:00
|
|
|
/* Gets the amt/val rate, i.e. rate from the transaction currency to
|
|
|
|
the 'split_com' */
|
|
|
|
gboolean
|
|
|
|
xaccTransGetRateForCommodity(const Transaction *trans,
|
|
|
|
const gnc_commodity *split_com,
|
|
|
|
const Split *split_to_exclude, gnc_numeric *rate);
|
2012-10-18 03:15:21 -05:00
|
|
|
/*################## Added for Reg2 #################*/
|
2012-08-07 12:24:33 -05:00
|
|
|
|
2006-01-29 20:59:43 -06:00
|
|
|
/* Compute the conversion rate for the transaction to this account.
|
|
|
|
* Any "split value" (which is in the transaction currency),
|
|
|
|
* multiplied by this conversion rate, will give you the value you
|
|
|
|
* should display for this account.
|
|
|
|
*
|
|
|
|
* If 'acc' is NULL, return unity.
|
|
|
|
*/
|
2010-03-07 15:28:15 -06:00
|
|
|
gnc_numeric xaccTransGetAccountConvRate(const Transaction *txn, const Account *acc);
|
2006-01-29 20:59:43 -06:00
|
|
|
|
|
|
|
/** Get the account balance for the specified account after the last
|
|
|
|
split in the specified transaction. */
|
|
|
|
gnc_numeric xaccTransGetAccountBalance (const Transaction *trans,
|
|
|
|
const Account *account);
|
|
|
|
|
2002-12-07 20:19:10 -06:00
|
|
|
/**
|
|
|
|
* The xaccTransOrder(ta,tb) method is useful for sorting.
|
2004-01-07 15:09:05 -06:00
|
|
|
* 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())
|
2010-03-27 16:01:21 -05:00
|
|
|
* GncGUID (compare as a guid)
|
2002-12-07 20:19:10 -06:00
|
|
|
* Finally, it returns zero if all of the above match.
|
|
|
|
* Note that it does *NOT* compare its member splits.
|
Implement a Book Option to give users the choice to use the transaction number field (default and current behaviour) or, alternatively, the split action field of the anchor split for 'Num' column on registers, reports, import and export, where applicable. The difference between the two is that with the default, the same 'Num' is displayed for a given transaction regardless of what register it is viewed in and with the new option, a different 'Num' can be entered/displayed for a given transaction in each register it is viewed in. In both cases, the 'next number logic' of the 'Num' cell is based on the account of the register the transaction is entered/viewed from but in one case it fills the transaction number, in the other, it fills the split action field of the anchor split (with the transaction number field displayed in the register cell labeled 'T-Num'). In both cases, both fields are visible and can be used as free-form text in double-line mode for any value the user wants. If the new option is not selected, there should be no change in Gnucash's behaviour with the exception of displaying the book options dialog in 'new book' situations.
The changes made are:
1. Implement the new book option to select source for 'num' cell:
libqof/qof/qofbookslots.h - define num source option
engine/engine.i - define 'NUM-FIELD-SOURCE' as an option name and
'SPLIT-ACTION' as a term for sorting queries
app-utils/business-prefs.scm - define book option for num-field-source
app-utils/app-utils.scm - define and export book option for num-field-source
2. Implement functions to get book option setting and to test:
libqof/qof/qofbook.c & .h - define function to get number source book option
libqof/qof/test/test-qofbook.c - test function to get number source book option
3. Implement a notification mechanism for book option changes:
engine/engine-helpers.c & .h - define functions to register callbacks,
define function to remove callbacks and
define function to initiate callbacks on book num-source option changes
core-utils/gnc-features.c & .h - define feature for num-source
app-utils/gnc-ui-util.c & .h - define gnc_book_option_num_field_source_change_cb;
include setting of feature flag on initial use
gnome-utils/gnc-main-window.c - change name of gnc_options_dialog_apply_cb
function to gnc_book_options_dialog_apply_cb and adjust function to
call function gnc_book_option_num_field_source_change_cb when book
option for num-field-source changes; change name of
gnc_options_dialog_close_cb to gnc_book_options_dialog_close_cb
4. Implement 'help' button response on Book Option Dialog:
gnome-utils/gnc-ui.h - define "book-options" section of help manual
gnome-utils/gnc-gnome-utils.c & .h - implement Book Options help callback
gnome-utils/gnc-main-window.c - use gnc_options_dialog_set_book_options_help_cb
to make help button active
5. Implement utility functions to get/set number/action based on book option:
engine/engine-helpers.c & .h - define 'gnc_get_num_action' function
define 'gnc_get_action_num' function
define 'gnc_set_num_action' function
engine/engine.i - make get/set num/action functions available to guile &
allow #f to be used in place of NULL from guile
engine/Transaction.h - add reference to utility functions in comments to
xaccTransSetNum and xaccTransGetNum functions
engine/Split.h - add reference to utility functions in comments to
xaccSplitSetAction and xaccSplitGetAction functions
6. Implement register use of num source book option; for General, Income and Search
Ledgers, since there is no anchor split, always show tran-num in transaction
cursor, but vary label to correspond to book option:
register/ledger-core/split-register.h - define TNUM_CELL
define CURSOR_DOUBLE_LEDGER_NUM_ACTN cursor name to use TNUM_CELL
define CURSOR_DOUBLE_JOURNAL_NUM_ACTN cursor name to use TNUM_CELL
add boolean to split_reg structure to hold num source book option
register/ledger-core/split-register-layout.c -
add logic to define and set up new ledger/journal cursors with TNUM_CELLs
add logic to add the new cursors to a layout
add logic to add TNUM_CELL to a layout
register/ledger-core/split-register-model.c -
define function to get TNUM_CELL label
add logic to recognize ledger/journal cursors with TNUM_CELL
modify function to get NUM_CELL value based on book option and register
type
define function to get TNUM_CELL value
adjust num help text to reflect book option choice
define function to get TNUM_CELL help
modify function to get action help to reflect book option choice
set up handlers for TNUM_CELL
register/ledger-core/split-register-model-save.c -
use 'gnc_set_num_action' function to set num/action for NUM_CELL based
on book option
define function to save TNUM_CELL using 'gnc_set_num_action' function
set save handler for TNUM_CELL
register/ledger-core/split-register-util.c -
modify logic to recognize ledger/journal cursors with tnum_cell
register/ledger-core/split-register.c -
define split_register_book_option_changed function
register split_register_book_option_changed function in register init
initialize register structure setting to book option
remove split_register_book_option_changed function in register destroy
modify gnc_split_register_save_to_scm to handle TNUM_CELL
7. Enhance transaction copy/duplicate logic to accommodate new book option:
gnome/gtkbuilder/gnc-plugin-page-register.glade -
add widgets to handle trans number and/or split action based on book option
gnome-utils/dialog-dup-trans.c & .h -
add capability to display and handle 'Num' field according to book option
gnome/gnc-plugin-page-register.c - define gnc_find_register_by_account
register/ledger-core/split-register.c -
modify gnc_split_register_duplicate_current to accomodate book option
setting
register/ledger-core/Makefile.am - add GNOME_CFLAGS
register/ledger-core/test/Makefile.am - add libgnc-gnome.la
8. Adjust register sort and sort labels related to Num/Action radio buttons to
correspond to book option for clarity:
gnome/gnc-plugin-page-register.c -
define gnc_plugin_page_register_sort_book_option_changed to adjust labels
register function in gnc_plugin_page_register_cmd_view_sort_by
and save num and action radio widgets
initialize radio widget labels to correspond to book option
remove function in gnc_plugin_page_register_sort_response_cb
and clear num and action radio widgets
gnome/gnc-split-reg.c & h. -
create versions of gnc_split_reg_sort and gnc_split_reg_set_sort to force
a re-sort to be used when num-source book option changes
engine/Transaction.c & .h -
modify default sort to use split action in place of tran num per book
option if called from xaccSplitOrder
engine/Split.c -
modify xaccSplitOrder to call xaccTransOrder_num_action to switch use of
split action and tran num per book option
engine/test/utest-Split.c -
modify test_xaccSplitOrder to call xaccTransOrder_num_action based on
book option
9. Adjust transaction find labels related to Num/Action to correspond to book option
for clarity:
gnome/dialog-find-transactions.c - adjust labels in search criteria based
on book option
gnome-search/dialog-search.c -
define gnc_search_dialog_book_option_changed to adjust labels
register function in gnc_search_dialog_init_widgets when searching
for splits
remove function in gnc_search_dialog_close_cb if registered
10. Modify new file process to allow setting of num-source (actually, all) book
option(s) during New Account Hierarchy Setup:
gnome-utils/gtkbuilder/dialog-preferences.glade - add a user preference for
the default setting for 'num-source' for new books
core-utils/gnc-gconf-utils.h - define KEY_NUM_SOURCE
gnome-utils/gnc-gnome-utils.c & h. -
define gnc_options_dialog_set_new_book_option_values to retrieve
preference values
gnome-utils/dialog-options.c & .h - define gnc_options_dialog_new_modal to
surpress apply button
gnome-utils/gnc-main-window.c - define function gnc_book_options_dialog_cb
with arguments so that the window can be called in modal mode and the
title changed and return dialog widget; call gnc_options_dialog_new_modal
instead of gnc_options_dialog_new; call this function from
gnc_main_window_cmd_file_properties with new arguments; for modal mode,
call gnc-options-dialog-set-new-book-option-values to initialize values
from preferences
app-utils/gnc-ui-util.c & h. - create function gnc_is_new_book for
determining when a new book is being created
gnome-utils/dialog-utils.c & h. - define gnc_new_book_option_display to
display book options dialog in modal mode
gnome/gtkbuilder/assistant-hierarchy.glade - add notification about book
options to currency page
gnome/assistant-hierarchy.c - add ability to set book option initialized
from preferences value for new books by using functions gnc_is_new_book
and gnc_new_book_option_display
11. Modify Import QIF process to recognize a new-book situation and allow setting
of book options during first import into a new book; also follow book option
setting for num source in importing number whether new book or not:
import-export/qif-import/assistant-qif-import.glade - add notification about
book options to currency page
import-export/qif-import/assistant-qif-import.c - using function
gnc_is_new_book to identify 'new book' situation and set flag; add
logic to handle 'new-book' situation by calling
gnc_new_book_option_display function
import-export/qif-import/qif-to-gnc.scm - use 'gnc_set_num_action' function
to import number to correct field based on book option
12. Modify Import OFX/QFX process to recognize a new-book situation and allow setting
of book options during first import into a new book; also follow book option
setting for num source in importing number whether new book or not:
import-export/ofx/gnc-ofx-import.c - use 'gnc_set_num_action' function to import
number based on book option; identify 'new book' situation using function
gnc_is_new_book and set flag; add logic to handle 'new-book' situation
by raising book options dialog by calling gnc_new_book_option_display
function
import-export/import-backend.c - use 'gnc_get_num_action' function to
retrieve number from transactions to be matched based on book option
13. Modify Import AqBanking process to recognize a new-book situation and allow
setting of book options during first import into a new book; also follow
book option setting for num source in importing number:
import-export/aqbanking/gnc-file-aqb-import.c - identify 'new book'
situation using function gnc_is_new_book and handle by raising book
options dialog by calling gnc_new_book_option_display function
import-export/aqbanking/gnc-ab-utils.c - use 'gnc_set_num_action' function
to set number based on book option
14. Modify Import Transactions from CSV process to recognize a new-book situation
and allow setting of book options during first import into a new book; also
follow book option setting for num source in importing number whether new
book or not:
import-export/csv-import/assistant-csv-trans-import.glade - modify
commments to alert user of raising book options dialog in cases of csv
import into a new book
import-export/csv-import/gnc-csv-model.c & h. - use 'gnc_set_num_action'
function to import number based on book option
import-export/csv-import/assistant-csv-trans-import.c - add logic to handle
'new-book' situation by raising book options dialog by calling
gnc_new_book_option_display function; identify 'new book' situation
using function gnc_is_new_book and set flag
15. Modify Import Accounts from CSV process to recognize a new-book situation
and allow setting of book options during first import into a new book
import-export/csv-import/assistant-csv-account-import.c & .h - add logic to
handle 'new-book' situation by raising book options dialog by calling
gnc_new_book_option_display function; identify 'new book' situation
using function gnc_is_new_book and set flag
16. Modify Export Transactions to CSV process to follow book option setting
for num source in exporting transactions:
import-export/csv-export/csv-transactions-export.c - modify headings to
reflect num-source book option and use 'gnc_get_num_action' function
to retrieve number and action
17. Modify register reporting to reflect book option setting for num source:
gnome/gnc-plugin-page-register.c - determine and pass along ledger-type?
argument to gnc:register-report-create function
gnome/gnc-plugin-page-register2.c - determine and pass along ledger-type?
argument to gnc:register-report-create function
report/standard-reports/standard-reports.scm - add ledger-type? argument
to gnc:register-report-create function; pass it along to
gnc:register-report-create-internal function
report/standard-reports/register.scm - add ledger-type? argument to
gnc:register-report-create-internal function; use 'gnc-get-num-action'
function in place of xaccTransGetNum and 'gnc-get-action-num' function
in place of xaccSplitGetAction and modify report headings and option
text accordingly
18. Modify all places that use xaccTransSetNum and/or xaccSplitSetAction to use
'gnc_set_num_action' function to set number based on book option except
engine/Transaction.c & .h, engine/test-core/test-engine-stuff.c,
engine/Split.c & .h, engine/test/utest-Split.c, engine/engine-helpers.c & .h,
engine/engine-interface.scm, backend/xml/gnc-transaction-xml-v2.c,
backend/xml/io-gncxml-v1.c, import-export/log-replay/gnc-log-replay.c:
engine/gncOwner.c - use 'gnc_set_num_action' function to set number based
on book option
engine/gncInvoice.c - use 'gnc_set_num_action' function to set number based
on book option
engine/SchedXaction.c - use 'gnc_set_num_action' function to set number and
action
engine/cap-gains.c - use 'gnc_set_num_action' function to set split-action
gnome-utils/dialog-transfer.c - use 'gnc_set_num_action' function to set
number based on book option
gnome-utils/gnc-tree-view-split-reg.c - use 'gnc_set_num_action' function
to set number/action based on book option
gnome/assistant-stock-split.c - use 'gnc_set_num_action' function to set
split-action
19. Modify all places that use xaccTransGetNum and/or xaccSplitGetAction to use
'gnc_get_num_action' or 'gnc_get_action_num' functions to get number based
on book option except engine/Transaction.c & .h,
engine/test-core/test-engine-stuff.c, engine/Split.c & h.,
engine/test/utest-Split.c, engine/engine-helpers.c,
engine/engine-interface.scm, backend/xml/gnc-transaction-xml-v2.c,
backend/xml/test/test-xml-transaction.c:
gnome/dialog-lot-viewer.c - use 'gnc_get_num_action' function to retrieve
number based on book option
gnome/dialog-sx-from-trans.c - use 'gnc_get_num_action' function to
retrieve number and action
gnome/dialog-print-check.c - use 'gnc_get_num_action' function to
retrieve number and 'gnc_get_action_num' function to retrieve action
register/ledger-core/split-register-model.c - use 'gnc_get_num_action'
function to retrieve number based on book option
register/ledger-core/split-register-load.c - use 'gnc_get_num_action'
function to retrieve number based on book option
register/ledger-core/split-register-control.c - use 'gnc_get_num_action'
function to retrieve action
register/ledger-core/split-register.c - use 'gnc_get_num_action'
function to retrieve transaction-num
engine/cap-gains.c - use 'gnc_get_num_action' function to get split-action
gnome-utils/gnc-tree-view-split-reg.c - use 'gnc_get_num_action' function
to retrieve number and 'gnc_get_action_num' function to retrieve action
gnome-utils/gnc-tree-model-split-reg.c - use 'gnc_get_num_action' function
to retrieve transaction-number but may not be getting what is expected
if book option to use split-action for 'num' is set
report/locale-specific/us/taxtxf.scm - use 'gnc-get-num-action' function in
place of xaccTransGetNum and 'gnc-get-action-num' function in place of
xaccSplitGetAction and modify report headings and option text accordingly
report/standard-reports/transaction.scm - use 'gnc-get-num-action' function
in place of xaccTransGetNum, adjust sorting based on book option and
modify report headings and option text accordingly; add 'SPLIT-ACTION'
as a term for sorting queries
report/business-reports/customer-summary.scm - use 'gnc-get-num-action'
function in place of xaccTransGetNum
report/business-reports/owner-report.scm - use 'gnc-get-num-action'
function in place of xaccTransGetNum
report/business-reports/job-report.scm - use 'gnc-get-num-action' function
in place of xaccTransGetNum
business/business-gnome/dialog-payment.c - use 'gnc_get_num_action'
function to retrieve number based on book option
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22681 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-12-22 00:00:54 -06:00
|
|
|
* Note also that it calls xaccTransOrder_num_action with actna and actnb
|
|
|
|
* set as NULL.
|
2002-12-07 20:19:10 -06:00
|
|
|
*/
|
|
|
|
int xaccTransOrder (const Transaction *ta, const Transaction *tb);
|
|
|
|
|
Implement a Book Option to give users the choice to use the transaction number field (default and current behaviour) or, alternatively, the split action field of the anchor split for 'Num' column on registers, reports, import and export, where applicable. The difference between the two is that with the default, the same 'Num' is displayed for a given transaction regardless of what register it is viewed in and with the new option, a different 'Num' can be entered/displayed for a given transaction in each register it is viewed in. In both cases, the 'next number logic' of the 'Num' cell is based on the account of the register the transaction is entered/viewed from but in one case it fills the transaction number, in the other, it fills the split action field of the anchor split (with the transaction number field displayed in the register cell labeled 'T-Num'). In both cases, both fields are visible and can be used as free-form text in double-line mode for any value the user wants. If the new option is not selected, there should be no change in Gnucash's behaviour with the exception of displaying the book options dialog in 'new book' situations.
The changes made are:
1. Implement the new book option to select source for 'num' cell:
libqof/qof/qofbookslots.h - define num source option
engine/engine.i - define 'NUM-FIELD-SOURCE' as an option name and
'SPLIT-ACTION' as a term for sorting queries
app-utils/business-prefs.scm - define book option for num-field-source
app-utils/app-utils.scm - define and export book option for num-field-source
2. Implement functions to get book option setting and to test:
libqof/qof/qofbook.c & .h - define function to get number source book option
libqof/qof/test/test-qofbook.c - test function to get number source book option
3. Implement a notification mechanism for book option changes:
engine/engine-helpers.c & .h - define functions to register callbacks,
define function to remove callbacks and
define function to initiate callbacks on book num-source option changes
core-utils/gnc-features.c & .h - define feature for num-source
app-utils/gnc-ui-util.c & .h - define gnc_book_option_num_field_source_change_cb;
include setting of feature flag on initial use
gnome-utils/gnc-main-window.c - change name of gnc_options_dialog_apply_cb
function to gnc_book_options_dialog_apply_cb and adjust function to
call function gnc_book_option_num_field_source_change_cb when book
option for num-field-source changes; change name of
gnc_options_dialog_close_cb to gnc_book_options_dialog_close_cb
4. Implement 'help' button response on Book Option Dialog:
gnome-utils/gnc-ui.h - define "book-options" section of help manual
gnome-utils/gnc-gnome-utils.c & .h - implement Book Options help callback
gnome-utils/gnc-main-window.c - use gnc_options_dialog_set_book_options_help_cb
to make help button active
5. Implement utility functions to get/set number/action based on book option:
engine/engine-helpers.c & .h - define 'gnc_get_num_action' function
define 'gnc_get_action_num' function
define 'gnc_set_num_action' function
engine/engine.i - make get/set num/action functions available to guile &
allow #f to be used in place of NULL from guile
engine/Transaction.h - add reference to utility functions in comments to
xaccTransSetNum and xaccTransGetNum functions
engine/Split.h - add reference to utility functions in comments to
xaccSplitSetAction and xaccSplitGetAction functions
6. Implement register use of num source book option; for General, Income and Search
Ledgers, since there is no anchor split, always show tran-num in transaction
cursor, but vary label to correspond to book option:
register/ledger-core/split-register.h - define TNUM_CELL
define CURSOR_DOUBLE_LEDGER_NUM_ACTN cursor name to use TNUM_CELL
define CURSOR_DOUBLE_JOURNAL_NUM_ACTN cursor name to use TNUM_CELL
add boolean to split_reg structure to hold num source book option
register/ledger-core/split-register-layout.c -
add logic to define and set up new ledger/journal cursors with TNUM_CELLs
add logic to add the new cursors to a layout
add logic to add TNUM_CELL to a layout
register/ledger-core/split-register-model.c -
define function to get TNUM_CELL label
add logic to recognize ledger/journal cursors with TNUM_CELL
modify function to get NUM_CELL value based on book option and register
type
define function to get TNUM_CELL value
adjust num help text to reflect book option choice
define function to get TNUM_CELL help
modify function to get action help to reflect book option choice
set up handlers for TNUM_CELL
register/ledger-core/split-register-model-save.c -
use 'gnc_set_num_action' function to set num/action for NUM_CELL based
on book option
define function to save TNUM_CELL using 'gnc_set_num_action' function
set save handler for TNUM_CELL
register/ledger-core/split-register-util.c -
modify logic to recognize ledger/journal cursors with tnum_cell
register/ledger-core/split-register.c -
define split_register_book_option_changed function
register split_register_book_option_changed function in register init
initialize register structure setting to book option
remove split_register_book_option_changed function in register destroy
modify gnc_split_register_save_to_scm to handle TNUM_CELL
7. Enhance transaction copy/duplicate logic to accommodate new book option:
gnome/gtkbuilder/gnc-plugin-page-register.glade -
add widgets to handle trans number and/or split action based on book option
gnome-utils/dialog-dup-trans.c & .h -
add capability to display and handle 'Num' field according to book option
gnome/gnc-plugin-page-register.c - define gnc_find_register_by_account
register/ledger-core/split-register.c -
modify gnc_split_register_duplicate_current to accomodate book option
setting
register/ledger-core/Makefile.am - add GNOME_CFLAGS
register/ledger-core/test/Makefile.am - add libgnc-gnome.la
8. Adjust register sort and sort labels related to Num/Action radio buttons to
correspond to book option for clarity:
gnome/gnc-plugin-page-register.c -
define gnc_plugin_page_register_sort_book_option_changed to adjust labels
register function in gnc_plugin_page_register_cmd_view_sort_by
and save num and action radio widgets
initialize radio widget labels to correspond to book option
remove function in gnc_plugin_page_register_sort_response_cb
and clear num and action radio widgets
gnome/gnc-split-reg.c & h. -
create versions of gnc_split_reg_sort and gnc_split_reg_set_sort to force
a re-sort to be used when num-source book option changes
engine/Transaction.c & .h -
modify default sort to use split action in place of tran num per book
option if called from xaccSplitOrder
engine/Split.c -
modify xaccSplitOrder to call xaccTransOrder_num_action to switch use of
split action and tran num per book option
engine/test/utest-Split.c -
modify test_xaccSplitOrder to call xaccTransOrder_num_action based on
book option
9. Adjust transaction find labels related to Num/Action to correspond to book option
for clarity:
gnome/dialog-find-transactions.c - adjust labels in search criteria based
on book option
gnome-search/dialog-search.c -
define gnc_search_dialog_book_option_changed to adjust labels
register function in gnc_search_dialog_init_widgets when searching
for splits
remove function in gnc_search_dialog_close_cb if registered
10. Modify new file process to allow setting of num-source (actually, all) book
option(s) during New Account Hierarchy Setup:
gnome-utils/gtkbuilder/dialog-preferences.glade - add a user preference for
the default setting for 'num-source' for new books
core-utils/gnc-gconf-utils.h - define KEY_NUM_SOURCE
gnome-utils/gnc-gnome-utils.c & h. -
define gnc_options_dialog_set_new_book_option_values to retrieve
preference values
gnome-utils/dialog-options.c & .h - define gnc_options_dialog_new_modal to
surpress apply button
gnome-utils/gnc-main-window.c - define function gnc_book_options_dialog_cb
with arguments so that the window can be called in modal mode and the
title changed and return dialog widget; call gnc_options_dialog_new_modal
instead of gnc_options_dialog_new; call this function from
gnc_main_window_cmd_file_properties with new arguments; for modal mode,
call gnc-options-dialog-set-new-book-option-values to initialize values
from preferences
app-utils/gnc-ui-util.c & h. - create function gnc_is_new_book for
determining when a new book is being created
gnome-utils/dialog-utils.c & h. - define gnc_new_book_option_display to
display book options dialog in modal mode
gnome/gtkbuilder/assistant-hierarchy.glade - add notification about book
options to currency page
gnome/assistant-hierarchy.c - add ability to set book option initialized
from preferences value for new books by using functions gnc_is_new_book
and gnc_new_book_option_display
11. Modify Import QIF process to recognize a new-book situation and allow setting
of book options during first import into a new book; also follow book option
setting for num source in importing number whether new book or not:
import-export/qif-import/assistant-qif-import.glade - add notification about
book options to currency page
import-export/qif-import/assistant-qif-import.c - using function
gnc_is_new_book to identify 'new book' situation and set flag; add
logic to handle 'new-book' situation by calling
gnc_new_book_option_display function
import-export/qif-import/qif-to-gnc.scm - use 'gnc_set_num_action' function
to import number to correct field based on book option
12. Modify Import OFX/QFX process to recognize a new-book situation and allow setting
of book options during first import into a new book; also follow book option
setting for num source in importing number whether new book or not:
import-export/ofx/gnc-ofx-import.c - use 'gnc_set_num_action' function to import
number based on book option; identify 'new book' situation using function
gnc_is_new_book and set flag; add logic to handle 'new-book' situation
by raising book options dialog by calling gnc_new_book_option_display
function
import-export/import-backend.c - use 'gnc_get_num_action' function to
retrieve number from transactions to be matched based on book option
13. Modify Import AqBanking process to recognize a new-book situation and allow
setting of book options during first import into a new book; also follow
book option setting for num source in importing number:
import-export/aqbanking/gnc-file-aqb-import.c - identify 'new book'
situation using function gnc_is_new_book and handle by raising book
options dialog by calling gnc_new_book_option_display function
import-export/aqbanking/gnc-ab-utils.c - use 'gnc_set_num_action' function
to set number based on book option
14. Modify Import Transactions from CSV process to recognize a new-book situation
and allow setting of book options during first import into a new book; also
follow book option setting for num source in importing number whether new
book or not:
import-export/csv-import/assistant-csv-trans-import.glade - modify
commments to alert user of raising book options dialog in cases of csv
import into a new book
import-export/csv-import/gnc-csv-model.c & h. - use 'gnc_set_num_action'
function to import number based on book option
import-export/csv-import/assistant-csv-trans-import.c - add logic to handle
'new-book' situation by raising book options dialog by calling
gnc_new_book_option_display function; identify 'new book' situation
using function gnc_is_new_book and set flag
15. Modify Import Accounts from CSV process to recognize a new-book situation
and allow setting of book options during first import into a new book
import-export/csv-import/assistant-csv-account-import.c & .h - add logic to
handle 'new-book' situation by raising book options dialog by calling
gnc_new_book_option_display function; identify 'new book' situation
using function gnc_is_new_book and set flag
16. Modify Export Transactions to CSV process to follow book option setting
for num source in exporting transactions:
import-export/csv-export/csv-transactions-export.c - modify headings to
reflect num-source book option and use 'gnc_get_num_action' function
to retrieve number and action
17. Modify register reporting to reflect book option setting for num source:
gnome/gnc-plugin-page-register.c - determine and pass along ledger-type?
argument to gnc:register-report-create function
gnome/gnc-plugin-page-register2.c - determine and pass along ledger-type?
argument to gnc:register-report-create function
report/standard-reports/standard-reports.scm - add ledger-type? argument
to gnc:register-report-create function; pass it along to
gnc:register-report-create-internal function
report/standard-reports/register.scm - add ledger-type? argument to
gnc:register-report-create-internal function; use 'gnc-get-num-action'
function in place of xaccTransGetNum and 'gnc-get-action-num' function
in place of xaccSplitGetAction and modify report headings and option
text accordingly
18. Modify all places that use xaccTransSetNum and/or xaccSplitSetAction to use
'gnc_set_num_action' function to set number based on book option except
engine/Transaction.c & .h, engine/test-core/test-engine-stuff.c,
engine/Split.c & .h, engine/test/utest-Split.c, engine/engine-helpers.c & .h,
engine/engine-interface.scm, backend/xml/gnc-transaction-xml-v2.c,
backend/xml/io-gncxml-v1.c, import-export/log-replay/gnc-log-replay.c:
engine/gncOwner.c - use 'gnc_set_num_action' function to set number based
on book option
engine/gncInvoice.c - use 'gnc_set_num_action' function to set number based
on book option
engine/SchedXaction.c - use 'gnc_set_num_action' function to set number and
action
engine/cap-gains.c - use 'gnc_set_num_action' function to set split-action
gnome-utils/dialog-transfer.c - use 'gnc_set_num_action' function to set
number based on book option
gnome-utils/gnc-tree-view-split-reg.c - use 'gnc_set_num_action' function
to set number/action based on book option
gnome/assistant-stock-split.c - use 'gnc_set_num_action' function to set
split-action
19. Modify all places that use xaccTransGetNum and/or xaccSplitGetAction to use
'gnc_get_num_action' or 'gnc_get_action_num' functions to get number based
on book option except engine/Transaction.c & .h,
engine/test-core/test-engine-stuff.c, engine/Split.c & h.,
engine/test/utest-Split.c, engine/engine-helpers.c,
engine/engine-interface.scm, backend/xml/gnc-transaction-xml-v2.c,
backend/xml/test/test-xml-transaction.c:
gnome/dialog-lot-viewer.c - use 'gnc_get_num_action' function to retrieve
number based on book option
gnome/dialog-sx-from-trans.c - use 'gnc_get_num_action' function to
retrieve number and action
gnome/dialog-print-check.c - use 'gnc_get_num_action' function to
retrieve number and 'gnc_get_action_num' function to retrieve action
register/ledger-core/split-register-model.c - use 'gnc_get_num_action'
function to retrieve number based on book option
register/ledger-core/split-register-load.c - use 'gnc_get_num_action'
function to retrieve number based on book option
register/ledger-core/split-register-control.c - use 'gnc_get_num_action'
function to retrieve action
register/ledger-core/split-register.c - use 'gnc_get_num_action'
function to retrieve transaction-num
engine/cap-gains.c - use 'gnc_get_num_action' function to get split-action
gnome-utils/gnc-tree-view-split-reg.c - use 'gnc_get_num_action' function
to retrieve number and 'gnc_get_action_num' function to retrieve action
gnome-utils/gnc-tree-model-split-reg.c - use 'gnc_get_num_action' function
to retrieve transaction-number but may not be getting what is expected
if book option to use split-action for 'num' is set
report/locale-specific/us/taxtxf.scm - use 'gnc-get-num-action' function in
place of xaccTransGetNum and 'gnc-get-action-num' function in place of
xaccSplitGetAction and modify report headings and option text accordingly
report/standard-reports/transaction.scm - use 'gnc-get-num-action' function
in place of xaccTransGetNum, adjust sorting based on book option and
modify report headings and option text accordingly; add 'SPLIT-ACTION'
as a term for sorting queries
report/business-reports/customer-summary.scm - use 'gnc-get-num-action'
function in place of xaccTransGetNum
report/business-reports/owner-report.scm - use 'gnc-get-num-action'
function in place of xaccTransGetNum
report/business-reports/job-report.scm - use 'gnc-get-num-action' function
in place of xaccTransGetNum
business/business-gnome/dialog-payment.c - use 'gnc_get_num_action'
function to retrieve number based on book option
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22681 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-12-22 00:00:54 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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).
|
|
|
|
*/
|
|
|
|
int xaccTransOrder_num_action (const Transaction *ta, const char *actna,
|
|
|
|
const Transaction *tb, const char *actnb);
|
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
/** @} */
|
2002-12-07 20:19:10 -06:00
|
|
|
|
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
/** @name Transaction date setters/getters
|
|
|
|
@{
|
|
|
|
*/
|
2010-02-17 23:31:54 -06:00
|
|
|
|
2002-12-07 20:19:10 -06:00
|
|
|
/** 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.)
|
|
|
|
*/
|
|
|
|
void xaccTransSetDate (Transaction *trans,
|
|
|
|
int day, int mon, int year);
|
|
|
|
|
2010-03-17 14:23:40 -05:00
|
|
|
/** This method modifies <i>posted</i> 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. */
|
|
|
|
void xaccTransSetDatePostedGDate (Transaction *trans, GDate date);
|
|
|
|
|
2003-09-01 15:20:52 -05:00
|
|
|
/** The xaccTransSetDatePostedSecs() method will modify the <i>posted</i>
|
2013-06-09 16:32:06 -05:00
|
|
|
* 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().
|
|
|
|
*/
|
2012-12-01 16:44:53 -06:00
|
|
|
void xaccTransSetDatePostedSecs (Transaction *trans, time64 time);
|
2002-12-07 20:19:10 -06:00
|
|
|
|
2013-06-09 16:32:06 -05:00
|
|
|
/** This function sets the <i>posted</i> 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. */
|
|
|
|
void xaccTransSetDatePostedSecsNormalized (Transaction *trans, time64 time);
|
|
|
|
|
2003-03-14 17:59:25 -06:00
|
|
|
/** Modify the date of when the transaction was entered. The entered
|
|
|
|
* date is the date when the register entry was made. */
|
2012-12-01 16:44:53 -06:00
|
|
|
void xaccTransSetDateEnteredSecs (Transaction *trans, time64 time);
|
2002-12-07 20:19:10 -06:00
|
|
|
|
|
|
|
/** Dates and txn-type for A/R and A/P "invoice" postings */
|
2017-12-29 15:07:08 -06:00
|
|
|
void xaccTransSetDateDue (Transaction * trans, time64 time);
|
2002-12-07 20:19:10 -06:00
|
|
|
|
2003-03-14 17:59:25 -06:00
|
|
|
/** 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.)*/
|
2012-12-01 16:44:53 -06:00
|
|
|
time64 xaccTransGetDate (const Transaction *trans);
|
2003-03-14 17:59:25 -06:00
|
|
|
/** 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.)*/
|
2017-12-16 10:29:25 -06:00
|
|
|
time64 xaccTransRetDatePosted (const Transaction *trans);
|
2010-03-17 14:23:40 -05:00
|
|
|
/** Retrieve the posted date of the transaction. The posted date is
|
|
|
|
the date when this transaction was posted at the bank. */
|
|
|
|
GDate xaccTransGetDatePostedGDate (const Transaction *trans);
|
2002-12-07 20:19:10 -06:00
|
|
|
|
2013-02-28 03:52:12 -06:00
|
|
|
/*################## Added for Reg2 #################*/
|
|
|
|
/** Retrieve the date of when the transaction was entered. The entered
|
|
|
|
* date is the date when the register entry was made.*/
|
|
|
|
time64 xaccTransGetDateEntered (const Transaction *trans);
|
|
|
|
/*################## Added for Reg2 #################*/
|
2003-03-14 17:59:25 -06:00
|
|
|
/** Retrieve the date of when the transaction was entered. The entered
|
|
|
|
* date is the date when the register entry was made.*/
|
2017-12-16 10:29:25 -06:00
|
|
|
time64 xaccTransRetDateEntered (const Transaction *trans);
|
2002-12-07 20:19:10 -06:00
|
|
|
|
|
|
|
/** Dates and txn-type for A/R and A/P "invoice" postings */
|
2017-12-17 06:58:22 -06:00
|
|
|
time64 xaccTransRetDateDue (const Transaction *trans);
|
2005-11-01 21:32:36 -06:00
|
|
|
/** @} */
|
2001-08-07 18:36:04 -05:00
|
|
|
|
|
|
|
|
2002-12-07 07:05:45 -06:00
|
|
|
|
|
|
|
/********************************************************************\
|
|
|
|
* Miscellaneous utility routines.
|
|
|
|
\********************************************************************/
|
|
|
|
|
2001-08-07 18:36:04 -05:00
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
/** @name Transaction voiding
|
|
|
|
@{
|
|
|
|
*/
|
2003-06-15 22:48:59 -05:00
|
|
|
/** 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.
|
|
|
|
*
|
|
|
|
* @param transaction The transaction to void.
|
|
|
|
*
|
|
|
|
* @param reason The textual reason why this transaction is being
|
|
|
|
* voided.
|
2001-10-01 00:42:23 -05:00
|
|
|
*/
|
2010-02-17 23:31:54 -06:00
|
|
|
void xaccTransVoid(Transaction *transaction,
|
|
|
|
const char *reason);
|
2003-06-15 22:48:59 -05:00
|
|
|
|
|
|
|
/** 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.
|
|
|
|
*
|
|
|
|
* @param transaction The transaction to restore from voided state.
|
|
|
|
*/
|
|
|
|
void xaccTransUnvoid(Transaction *transaction);
|
|
|
|
|
2006-05-03 19:06:58 -05:00
|
|
|
/** 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).
|
2003-06-15 22:48:59 -05:00
|
|
|
*
|
2006-05-03 19:06:58 -05:00
|
|
|
* @param transaction The transaction to create a reverse of.
|
|
|
|
*
|
|
|
|
* @return a new transaction which reverses the given transaction
|
|
|
|
*/
|
|
|
|
Transaction * xaccTransReverse(Transaction *transaction);
|
|
|
|
|
|
|
|
/** Returns the transaction that reversed the given transaction.
|
|
|
|
*
|
|
|
|
* @param trans a Transaction that has been reversed
|
|
|
|
*
|
2009-01-22 15:14:08 -06:00
|
|
|
* @return the transaction that reversed the given transaction, or
|
2006-05-03 19:06:58 -05:00
|
|
|
* NULL if the given transaction has not been reversed.
|
2003-06-15 22:48:59 -05:00
|
|
|
*/
|
2006-05-03 19:06:58 -05:00
|
|
|
Transaction * xaccTransGetReversedBy(const Transaction *trans);
|
2003-06-15 22:48:59 -05:00
|
|
|
|
|
|
|
/** Retrieve information on whether or not a transaction has been voided.
|
|
|
|
*
|
|
|
|
* @param transaction The transaction in question.
|
|
|
|
*
|
|
|
|
* @return TRUE if the transaction is void, FALSE otherwise. Also
|
|
|
|
* returns FALSE upon an error.
|
|
|
|
*/
|
2002-12-07 07:05:45 -06:00
|
|
|
gboolean xaccTransGetVoidStatus(const Transaction *transaction);
|
2001-10-01 00:42:23 -05:00
|
|
|
|
2003-06-15 22:48:59 -05:00
|
|
|
/** Returns the user supplied textual reason why a transaction was
|
|
|
|
* voided.
|
|
|
|
*
|
|
|
|
* @param transaction The transaction in question.
|
|
|
|
*
|
|
|
|
* @return A pointer to the user supplied reason for voiding.
|
|
|
|
*/
|
2006-04-15 11:40:03 -05:00
|
|
|
const char *xaccTransGetVoidReason(const Transaction *transaction);
|
2001-10-01 00:42:23 -05:00
|
|
|
|
2003-06-15 22:48:59 -05:00
|
|
|
/** Returns the time that a transaction was voided.
|
|
|
|
*
|
2005-11-01 21:32:36 -06:00
|
|
|
* @param tr The transaction in question.
|
2003-06-15 22:48:59 -05:00
|
|
|
*
|
2017-12-23 12:06:59 -06:00
|
|
|
* @return A time64 containing the time that this transaction was
|
2003-06-15 22:48:59 -05:00
|
|
|
* voided. Returns a time of zero upon error.
|
|
|
|
*/
|
2017-12-23 12:06:59 -06:00
|
|
|
time64 xaccTransGetVoidTime(const Transaction *tr);
|
2005-11-01 21:32:36 -06:00
|
|
|
/** @} */
|
2002-06-05 16:59:35 -05:00
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
/** @name Transaction Parameter names
|
|
|
|
@{
|
|
|
|
*/
|
2002-06-05 16:59:35 -05:00
|
|
|
#define TRANS_KVP "kvp"
|
|
|
|
#define TRANS_NUM "num"
|
|
|
|
#define TRANS_DESCRIPTION "desc"
|
|
|
|
#define TRANS_DATE_ENTERED "date-entered"
|
|
|
|
#define TRANS_DATE_POSTED "date-posted"
|
|
|
|
#define TRANS_DATE_DUE "date-due"
|
|
|
|
#define TRANS_IMBALANCE "trans-imbalance"
|
|
|
|
#define TRANS_IS_BALANCED "trans-balanced?"
|
2010-12-15 20:11:53 -06:00
|
|
|
#define TRANS_IS_CLOSING "trans-is-closing?"
|
2003-01-04 21:46:21 -06:00
|
|
|
#define TRANS_NOTES "notes"
|
2013-11-15 16:02:34 -06:00
|
|
|
#define TRANS_ASSOCIATION "assoc"
|
2002-06-05 16:59:35 -05:00
|
|
|
#define TRANS_TYPE "type"
|
|
|
|
#define TRANS_VOID_STATUS "void-p"
|
|
|
|
#define TRANS_VOID_REASON "void-reason"
|
|
|
|
#define TRANS_VOID_TIME "void-time"
|
|
|
|
#define TRANS_SPLITLIST "split-list" /* for guid_match_all */
|
2002-12-07 15:16:01 -06:00
|
|
|
/**@}*/
|
2002-06-05 16:59:35 -05:00
|
|
|
|
2012-09-10 22:29:39 -05:00
|
|
|
#ifdef DUMP_FUNCTIONS
|
|
|
|
void xaccTransDump (const Transaction *trans, const char *tag);
|
|
|
|
#endif
|
|
|
|
|
2002-10-17 19:09:52 -05:00
|
|
|
#define RECONCILED_MATCH_TYPE "reconciled-match"
|
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
/** \deprecated */
|
2003-10-16 23:25:53 -05:00
|
|
|
#define xaccTransGetBook(X) qof_instance_get_book (QOF_INSTANCE(X))
|
2005-11-01 21:32:36 -06:00
|
|
|
/** \deprecated */
|
2007-06-25 12:18:28 -05:00
|
|
|
#define xaccTransGetGUID(X) qof_entity_get_guid(QOF_INSTANCE(X))
|
2005-11-01 21:32:36 -06:00
|
|
|
/** \deprecated */
|
2007-06-25 12:18:28 -05:00
|
|
|
#define xaccTransReturnGUID(X) (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
|
2003-10-16 23:25:53 -05:00
|
|
|
|
2017-08-14 13:32:45 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
|
|
|
#endif
|
|
|
|
|
2001-08-07 18:36:04 -05:00
|
|
|
#endif /* XACC_TRANSACTION_H */
|
2002-12-07 15:16:01 -06:00
|
|
|
/** @} */
|
2004-05-06 21:36:40 -05:00
|
|
|
/** @} */
|