2001-08-07 18:36:04 -05:00
|
|
|
/********************************************************************\
|
|
|
|
* TransactionP.h -- private header for transaction & splits *
|
|
|
|
* Copyright (C) 1997 Robin D. Clark *
|
2003-03-29 21:01:23 -06:00
|
|
|
* Copyright (C) 1997-2000 Linas Vepstas <linas@linas.org> *
|
2001-08-07 18:36:04 -05:00
|
|
|
* Copyright (C) 2000 Bill Gribble *
|
|
|
|
* *
|
|
|
|
* 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
|
|
|
* *
|
|
|
|
\********************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FILE:
|
|
|
|
* TransactionP.h
|
|
|
|
*
|
|
|
|
* FUNCTION:
|
2010-02-17 23:31:54 -06:00
|
|
|
* The is the *private* transaction header file. Code outside of
|
2001-08-07 18:36:04 -05:00
|
|
|
* engine should *not* include this file. This is because code
|
|
|
|
* outside of the engine should *never* access any of the structure
|
|
|
|
* members directly.
|
|
|
|
*
|
|
|
|
* Note that this header file also defines prototypes for various
|
|
|
|
* routines that perform sub-atomic updates of the accounting
|
|
|
|
* structures. If these routines are not used properly, they
|
|
|
|
* can result in inconsistent, unbalanced accounting structures.
|
|
|
|
* In other words, their use is dangerous, and their use outside
|
|
|
|
* of the scope of the engine is forbidden.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef XACC_TRANSACTION_P_H
|
|
|
|
#define XACC_TRANSACTION_P_H
|
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
#include <glib.h>
|
|
|
|
|
2001-12-05 12:48:04 -06:00
|
|
|
#include "gnc-engine.h" /* for typedefs */
|
2006-02-22 15:52:46 -06:00
|
|
|
#include "SplitP.h"
|
2005-11-21 13:31:44 -06:00
|
|
|
#include "qof.h"
|
2001-08-07 18:36:04 -05:00
|
|
|
|
|
|
|
|
|
|
|
/** STRUCTS *********************************************************/
|
2010-02-17 23:31:54 -06:00
|
|
|
/*
|
2001-08-07 18:36:04 -05:00
|
|
|
* Double-entry is forced by having at least two splits in every
|
|
|
|
* transaction. By convention, (and only by convention, not by
|
|
|
|
* any innate requirement), the first split is considered to be
|
|
|
|
* the source split or the crediting split, and the others are
|
|
|
|
* the destination, or debiting splits. The grand total of all
|
|
|
|
* of the splits must always be kept zero.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* A split transaction is one which shows up as a credit (or debit) in
|
|
|
|
* one account, and pieces of it show up as debits (or credits) in other
|
|
|
|
* accounts. Thus, a single credit-card transaction might be split
|
|
|
|
* between "dining", "tips" and "taxes" categories.
|
|
|
|
*
|
2005-11-01 21:32:36 -06:00
|
|
|
* A "split" is more commonly referred to as an "entry" in a "transaction".
|
2001-08-07 18:36:04 -05:00
|
|
|
*/
|
|
|
|
|
2001-10-05 03:35:04 -05:00
|
|
|
struct transaction_s
|
2001-08-07 18:36:04 -05:00
|
|
|
{
|
2010-02-17 23:31:54 -06:00
|
|
|
QofInstance inst; /* glbally unique id */
|
|
|
|
|
2017-12-31 06:37:02 -06:00
|
|
|
time64 date_entered; /* date register entry was made */
|
|
|
|
time64 date_posted; /* date transaction was posted at bank */
|
2010-02-17 23:31:54 -06:00
|
|
|
|
|
|
|
/* The num field is a arbitrary user-assigned field.
|
|
|
|
* It is intended to store a short id number, typically the check number,
|
|
|
|
* deposit number, invoice number or other tracking number.
|
|
|
|
*/
|
|
|
|
char * num;
|
|
|
|
|
|
|
|
/* The description field is an arbitrary user-assigned value.
|
|
|
|
* It is meant to be a short descriptive phrase.
|
|
|
|
*/
|
|
|
|
char * description;
|
|
|
|
|
|
|
|
/* The common_currency field is the balancing common currency for
|
|
|
|
* all the splits in the transaction. Alternate, better(?) name:
|
|
|
|
* "valuation currency": it is the currency in which all of the
|
|
|
|
* splits can be valued. */
|
|
|
|
gnc_commodity *common_currency;
|
|
|
|
|
|
|
|
GList * splits; /* list of splits */
|
|
|
|
|
|
|
|
/* marker is used to track the progress of transaction traversals.
|
|
|
|
* 0 is never a legitimate marker value, so we can tell is we hit
|
|
|
|
* a new transaction in the middle of a traversal. All each new
|
|
|
|
* traversal cares about is whether or not the marker stored in
|
|
|
|
* a transaction is the same as or different than the one
|
|
|
|
* corresponding to the current traversal. */
|
|
|
|
unsigned char marker;
|
|
|
|
|
|
|
|
/* The orig pointer points at a copy of the original transaction,
|
|
|
|
* before editing was started. This orig copy is used to rollback
|
|
|
|
* any changes made if/when the edit is abandoned.
|
|
|
|
*/
|
|
|
|
Transaction *orig;
|
2018-09-09 15:49:52 -05:00
|
|
|
|
|
|
|
/* The readonly_reason is a string that indicates why a transaction
|
|
|
|
* is marked as read-only. If NULL, the transaction is read-write.
|
|
|
|
* This value is stored in kvp, but we cache a copy here for
|
|
|
|
* performance reasons. reason_cache_valid indicates whether the
|
|
|
|
* cached value is valid.
|
|
|
|
*/
|
|
|
|
char * readonly_reason;
|
|
|
|
gboolean reason_cache_valid;
|
2018-12-31 07:48:26 -06:00
|
|
|
|
|
|
|
/* Cached bool value to indicate whether this is a closing txn. This is
|
|
|
|
* cached from the KVP value because it is queried a lot. Tri-state value: -1
|
|
|
|
* = uninitialized; 0 = FALSE, 1 = TRUE. */
|
|
|
|
gint isClosingTxn_cached;
|
2001-08-07 18:36:04 -05:00
|
|
|
};
|
|
|
|
|
2007-04-04 19:23:58 -05:00
|
|
|
struct _TransactionClass
|
|
|
|
{
|
2010-02-17 23:31:54 -06:00
|
|
|
QofInstanceClass parent_class;
|
2007-04-04 19:23:58 -05:00
|
|
|
};
|
|
|
|
|
2010-03-27 16:01:21 -05:00
|
|
|
/* Set the transaction's GncGUID. This should only be done when reading
|
2001-08-07 18:36:04 -05:00
|
|
|
* a transaction from a datafile, or some other external source. Never
|
|
|
|
* call this on an existing transaction! */
|
2007-04-01 17:18:50 -05:00
|
|
|
#define xaccTransSetGUID(t,g) qof_instance_set_guid(QOF_INSTANCE(t),g)
|
2001-08-07 18:36:04 -05:00
|
|
|
|
2001-11-25 04:59:26 -06:00
|
|
|
/* This routine makes a 'duplicate' of the indicated transaction.
|
|
|
|
* This routine cannot be exposed publically since the duplicate
|
|
|
|
* is wrong in many ways: it is not issued a unique guid, and thus
|
|
|
|
* not a properly registered Entity. The splits are copied, but
|
2010-02-17 23:31:54 -06:00
|
|
|
* these are also funny: they aren't inserted into the accounts
|
2010-03-27 16:01:21 -05:00
|
|
|
* they claim to be in. The splits also have bogus GncGUID's.
|
2001-12-05 12:48:04 -06:00
|
|
|
* Another 'feature': the splits point at the old transaction
|
2010-02-17 23:31:54 -06:00
|
|
|
* as the parent, not the new transaction.
|
2001-11-25 04:59:26 -06:00
|
|
|
*/
|
2005-12-31 17:35:55 -06:00
|
|
|
Transaction * xaccDupeTransaction (const Transaction *t);
|
2001-11-25 04:59:26 -06:00
|
|
|
|
2001-08-07 18:36:04 -05:00
|
|
|
/* The xaccTransSet/GetVersion() routines set & get the version
|
|
|
|
* numbers on this transaction. The version number is used to manage
|
|
|
|
* multi-user updates. These routines are private because we don't
|
|
|
|
* want anyone except the backend to mess with them.
|
|
|
|
*/
|
|
|
|
void xaccTransSetVersion (Transaction*, gint32);
|
2002-12-07 07:05:45 -06:00
|
|
|
gint32 xaccTransGetVersion (const Transaction*);
|
2001-08-07 18:36:04 -05:00
|
|
|
|
2006-02-22 15:52:46 -06:00
|
|
|
/* Code to register Transaction type with the engine */
|
* src/engine/GNCId.c: Implement xaccForeachEntity() as a which
allows a traversal of all entities of a particular type.
* Register GncObject_t descriptions for Splits, Transactions, and
Accounts. Move the QueryObject definitions into the actual module
sources for Transactions, Splits, Accounts, and Books. This
allows QueryNew searches for Splits, Transactions, and Accounts.
* gnc-engine.c: call the registration functions for Splits,
Transactions, Accounts, and Books to enable searching using the
new search subsystem.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6913 57a11ea4-9604-0410-9ed3-97b8803252fd
2002-05-24 21:50:24 -05:00
|
|
|
gboolean xaccTransRegister (void);
|
|
|
|
|
2003-09-20 17:53:28 -05:00
|
|
|
/* The xaccTransactionGetBackend() subroutine will find the
|
2010-02-17 23:31:54 -06:00
|
|
|
* persistent-data storage backend associated with this
|
2003-06-10 20:23:18 -05:00
|
|
|
* transaction.
|
|
|
|
*/
|
2003-06-26 21:51:10 -05:00
|
|
|
QofBackend * xaccTransactionGetBackend (Transaction *trans);
|
* src/engine/GNCId.c: Implement xaccForeachEntity() as a which
allows a traversal of all entities of a particular type.
* Register GncObject_t descriptions for Splits, Transactions, and
Accounts. Move the QueryObject definitions into the actual module
sources for Transactions, Splits, Accounts, and Books. This
allows QueryNew searches for Splits, Transactions, and Accounts.
* gnc-engine.c: call the registration functions for Splits,
Transactions, Accounts, and Books to enable searching using the
new search subsystem.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6913 57a11ea4-9604-0410-9ed3-97b8803252fd
2002-05-24 21:50:24 -05:00
|
|
|
|
2003-09-20 17:53:28 -05:00
|
|
|
/* The xaccEnable/DisableDataScrubbing() routines affect what
|
|
|
|
* happens during transaction commit. When scrubbing is enabled,
|
2010-02-17 23:31:54 -06:00
|
|
|
* then transactions are fixed up during transaction commit,
|
2017-01-16 16:03:50 -06:00
|
|
|
* so that only consistent transactions are committed to the engine.
|
2003-09-20 17:53:28 -05:00
|
|
|
* However, when data is being loaded from a backend (in particular,
|
|
|
|
* from the file backend), the data might not be consistent until
|
|
|
|
* its completely loaded. In particular, gains transactions might
|
2017-01-16 16:03:50 -06:00
|
|
|
* be loaded at a different time than the transactions that caused
|
2003-09-20 17:53:28 -05:00
|
|
|
* the gains. Thus, scrubbing needs do be disabled during file
|
|
|
|
* load. These routines enable that.
|
|
|
|
*/
|
|
|
|
void xaccEnableDataScrubbing(void);
|
|
|
|
void xaccDisableDataScrubbing(void);
|
|
|
|
|
2006-02-22 15:52:46 -06:00
|
|
|
void xaccTransRemoveSplit (Transaction *trans, const Split *split);
|
2012-05-26 18:47:34 -05:00
|
|
|
void check_open (const Transaction *trans);
|
2006-02-22 15:52:46 -06:00
|
|
|
|
2013-08-16 11:44:28 -05:00
|
|
|
/* Structure for accessing static functions for testing */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
void (*mark_trans)(Transaction*);
|
|
|
|
void (*gen_event_trans)(Transaction*);
|
|
|
|
void (*xaccFreeTransaction)(Transaction*);
|
|
|
|
void (*destroy_gains)(Transaction*);
|
|
|
|
void (*do_destroy)(Transaction*);
|
|
|
|
gboolean (*was_trans_emptied)(Transaction*);
|
|
|
|
void (*trans_on_error)(Transaction*, QofBackendError);
|
|
|
|
void (*trans_cleanup_commit)(Transaction*);
|
|
|
|
void (*xaccTransScrubGainsDate)(Transaction*);
|
2014-05-07 08:37:14 -05:00
|
|
|
Transaction *(*dupe_trans)(const Transaction*);
|
2013-08-16 11:44:28 -05:00
|
|
|
|
|
|
|
} TransTestFunctions;
|
|
|
|
|
|
|
|
TransTestFunctions* _utest_trans_fill_functions (void);
|
|
|
|
|
2003-09-06 10:02:21 -05:00
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
|
2001-08-07 18:36:04 -05:00
|
|
|
#endif /* XACC_TRANSACTION_P_H */
|