2001-08-07 18:36:04 -05:00
|
|
|
/********************************************************************\
|
|
|
|
* Scrub.h -- convert single-entry accounts to clean double-entry *
|
|
|
|
* *
|
|
|
|
* 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 *
|
|
|
|
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
|
|
|
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
|
|
|
* *
|
|
|
|
\********************************************************************/
|
|
|
|
|
2004-05-06 22:26:31 -05:00
|
|
|
/** @addtogroup Engine
|
|
|
|
@{ */
|
|
|
|
/** @addtogroup Scrub
|
|
|
|
Data scrubbing, repairing and forward migration routines.
|
|
|
|
These routines check and repair data, making sure that it
|
|
|
|
is in a format that the current version of the GnuCash
|
|
|
|
Engine likes. These routines serve both to provide backwards
|
|
|
|
compatibility with older versions of GnuCash, and to fix
|
|
|
|
or at least paper over possible current problems.
|
|
|
|
|
|
|
|
It is typically expected that the scrub routines are run
|
|
|
|
over newly imported data, as well as during data file input.
|
|
|
|
|
|
|
|
In some cases, it is entirely appropriate to invoke these
|
|
|
|
routines from the GUI, to validate that the user input
|
|
|
|
through the GUI is in a format that the system likes.
|
|
|
|
This includes things like balancing individual transactions,
|
|
|
|
or assigning splits to lots, so that capital gains can be
|
|
|
|
computed.
|
|
|
|
@{ */
|
|
|
|
|
2003-03-14 17:59:25 -06:00
|
|
|
/** @file Scrub.h
|
2004-05-06 22:26:31 -05:00
|
|
|
* @brief convert single-entry accounts to clean double-entry
|
|
|
|
* @author Created by Linas Vepstas December 1998
|
|
|
|
* @author Copyright (c) 1998-2000, 2003 Linas Vepstas <linas@linas.org>
|
2001-08-07 18:36:04 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef XACC_SCRUB_H
|
|
|
|
#define XACC_SCRUB_H
|
|
|
|
|
|
|
|
#include "Group.h"
|
2001-10-03 19:36:28 -05:00
|
|
|
#include "gnc-engine.h"
|
2001-08-07 18:36:04 -05:00
|
|
|
|
2004-05-06 22:26:31 -05:00
|
|
|
/** @name Double-Entry Scrubbing
|
|
|
|
Convert single-entry accounts to clean double-entry
|
|
|
|
|
|
|
|
Provides a set of functions and utilities for checking and
|
|
|
|
repairing (formerly called 'scrubbing clean') single-entry accounts
|
|
|
|
so that they can be promoted into self-consistent, clean
|
|
|
|
double-entry accounts. Basically and additionally, this file
|
|
|
|
collects all functions that turn old (deprecated) data structures
|
|
|
|
into the current new data model.
|
|
|
|
|
|
|
|
The ScrubOrphans() methods search for transacations that contain
|
|
|
|
splits that do not have a parent account. These "orphaned splits"
|
|
|
|
are placed into an "orphan account" which the user will have to
|
|
|
|
go into and clean up. Kind of like the unix "Lost+Found" directory
|
|
|
|
for orphaned inodes.
|
|
|
|
@{ */
|
|
|
|
|
|
|
|
/** The xaccTransScrubOrphans() method scrubs only the splits in the
|
2003-04-04 23:38:12 -06:00
|
|
|
* given transaction.
|
2001-08-07 18:36:04 -05:00
|
|
|
*/
|
2003-04-04 23:38:12 -06:00
|
|
|
void xaccTransScrubOrphans (Transaction *trans);
|
2004-05-06 22:26:31 -05:00
|
|
|
|
|
|
|
/** The xaccAccountScrubOrphans() method performs this scrub only for the
|
|
|
|
* indicated account, and not for any of its children.
|
|
|
|
*/
|
2003-03-30 21:25:19 -06:00
|
|
|
void xaccAccountScrubOrphans (Account *acc);
|
2004-05-06 22:26:31 -05:00
|
|
|
|
|
|
|
/** The xaccAccountTreeScrubOrphans() method performs this scrub for the
|
|
|
|
* indicated account and its children.
|
|
|
|
*/
|
2003-03-30 21:25:19 -06:00
|
|
|
void xaccAccountTreeScrubOrphans (Account *acc);
|
2004-05-06 22:26:31 -05:00
|
|
|
|
|
|
|
/** The xaccGroupScrubOrphans() method performs this scrub for the
|
|
|
|
* child accounts of this group.
|
|
|
|
*/
|
2003-03-30 21:25:19 -06:00
|
|
|
void xaccGroupScrubOrphans (AccountGroup *grp);
|
2001-08-07 18:36:04 -05:00
|
|
|
|
2003-04-04 23:38:12 -06:00
|
|
|
/** The xaccSplitScrub method ensures that if this split has the same
|
|
|
|
* commodity and currency, then it will have the same amount and value.
|
|
|
|
* If the commoidty is the currency, the split->amount is set to the
|
|
|
|
* split value. In addition, if this split is an orphan, that is
|
|
|
|
* fixed first. If the split account doesn't have a commodity declared,
|
|
|
|
* an attempt is made to fix that first.
|
2001-08-07 18:36:04 -05:00
|
|
|
*/
|
|
|
|
void xaccSplitScrub (Split *split);
|
2003-04-04 23:38:12 -06:00
|
|
|
|
|
|
|
/** The xacc*ScrubSplits() calls xaccSplitScrub() on each split
|
|
|
|
* in the respective structure: transaction, account,
|
|
|
|
* account & it's children, account-group.
|
|
|
|
*/
|
2001-08-07 18:36:04 -05:00
|
|
|
void xaccTransScrubSplits (Transaction *trans);
|
|
|
|
void xaccAccountScrubSplits (Account *account);
|
|
|
|
void xaccAccountTreeScrubSplits (Account *account);
|
|
|
|
void xaccGroupScrubSplits (AccountGroup *group);
|
|
|
|
|
2003-03-14 17:59:25 -06:00
|
|
|
/** The xaccScrubImbalance() method searches for transactions that do
|
2001-08-07 18:36:04 -05:00
|
|
|
* not balance to zero. If any such transactions are found, a split
|
|
|
|
* is created to offset this amount and is added to an "imbalance"
|
|
|
|
* account.
|
|
|
|
*/
|
|
|
|
void xaccTransScrubImbalance (Transaction *trans, AccountGroup *root,
|
2003-03-30 21:25:19 -06:00
|
|
|
Account *parent);
|
|
|
|
void xaccAccountScrubImbalance (Account *acc);
|
|
|
|
void xaccAccountTreeScrubImbalance (Account *acc);
|
|
|
|
void xaccGroupScrubImbalance (AccountGroup *grp);
|
2001-08-07 18:36:04 -05:00
|
|
|
|
2003-03-14 17:59:25 -06:00
|
|
|
/** The xaccTransScrubCurrency method fixes transactions without a
|
2001-08-07 18:36:04 -05:00
|
|
|
* common_currency by using the old account currency and security
|
|
|
|
* fields of the parent accounts of the transaction's splits. */
|
2003-03-30 21:25:19 -06:00
|
|
|
void xaccTransScrubCurrency (Transaction *trans);
|
2001-08-07 18:36:04 -05:00
|
|
|
|
2003-03-14 17:59:25 -06:00
|
|
|
/** The xaccAccountScrubCommodity method fixed accounts without
|
2001-08-07 18:36:04 -05:00
|
|
|
* a commodity by using the old account currency and security. */
|
2003-03-30 21:25:19 -06:00
|
|
|
void xaccAccountScrubCommodity (Account *account);
|
2001-08-07 18:36:04 -05:00
|
|
|
|
2003-03-14 17:59:25 -06:00
|
|
|
/** The xaccGroupScrubCommodities will scrub the currency/commodity
|
2001-08-07 18:36:04 -05:00
|
|
|
* of all accounts & transactions in the group. */
|
2003-03-30 21:25:19 -06:00
|
|
|
void xaccGroupScrubCommodities (AccountGroup *group);
|
2001-08-07 18:36:04 -05:00
|
|
|
|
2003-05-10 19:45:03 -05:00
|
|
|
/** This routine will migrate the information about price quote
|
|
|
|
* sources from the account data structures to the commodity data
|
|
|
|
* structures. It first checks to see if this is necessary since,
|
|
|
|
* for the time being, the quote information will still be written
|
|
|
|
* out as part of the account. Just in case anyone needs to fall
|
|
|
|
* back from CVS to a production version of code.
|
|
|
|
*
|
|
|
|
* @param group A pointer to the account group containing all
|
|
|
|
* accounts in the current book.
|
|
|
|
*
|
|
|
|
* @param table A pointer to the commodity table for the current
|
|
|
|
* book.
|
|
|
|
*/
|
|
|
|
void xaccGroupScrubQuoteSources (AccountGroup *group, gnc_commodity_table *table);
|
|
|
|
|
2001-08-07 18:36:04 -05:00
|
|
|
#endif /* XACC_SCRUB_H */
|
2004-05-06 22:26:31 -05:00
|
|
|
/** @} */
|
|
|
|
/** @} */
|
|
|
|
/** @} */
|