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 *
|
|
|
|
* *
|
|
|
|
\********************************************************************/
|
|
|
|
|
2003-03-14 17:59:25 -06:00
|
|
|
/** @file Scrub.h
|
2001-08-07 18:36:04 -05:00
|
|
|
*
|
2003-03-14 17:59:25 -06:00
|
|
|
* Provides a set of functions and utilities for checking and
|
2003-03-29 18:21:41 -06:00
|
|
|
* repairing (formerly called 'scrubbing clean') single-entry accounts
|
2003-03-14 17:59:25 -06:00
|
|
|
* 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.
|
2001-08-07 18:36:04 -05:00
|
|
|
*
|
|
|
|
* HISTORY:
|
|
|
|
* Created by Linas Vepstas December 1998
|
2003-03-29 18:21:41 -06:00
|
|
|
* Copyright (c) 1998, 1999, 2000 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
|
|
|
|
2003-03-14 17:59:25 -06:00
|
|
|
/** The ScrubOrphans() methods search for transacations that contain
|
2001-08-07 18:36:04 -05:00
|
|
|
* 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
|
|
|
|
* given transaction. A root account group must be provided.
|
|
|
|
*
|
|
|
|
* The xaccAccountScrubOrphans() method performs this scrub only for the
|
|
|
|
* indicated account, and not for any of its children.
|
|
|
|
*
|
|
|
|
* The xaccAccountTreeScrubOrphans() method performs this scrub for the
|
|
|
|
* indicated account and its children.
|
|
|
|
*
|
|
|
|
* The xaccGroupScrubOrphans() method performs this scrub for the
|
|
|
|
* child accounts of this group.
|
|
|
|
*/
|
2001-10-03 19:36:28 -05:00
|
|
|
void xaccTransScrubOrphans (Transaction *trans, AccountGroup *root,
|
2001-11-24 06:10:42 -06:00
|
|
|
GNCBook *book);
|
|
|
|
void xaccAccountScrubOrphans (Account *acc, GNCBook *book);
|
|
|
|
void xaccAccountTreeScrubOrphans (Account *acc, GNCBook *book);
|
|
|
|
void xaccGroupScrubOrphans (AccountGroup *grp, GNCBook *book);
|
2001-08-07 18:36:04 -05:00
|
|
|
|
2003-03-14 17:59:25 -06:00
|
|
|
/** The ScrubSplit methods ensure that splits with the same commodity
|
2001-08-07 18:36:04 -05:00
|
|
|
* and command currency have the same amount and value.
|
|
|
|
*/
|
|
|
|
void xaccSplitScrub (Split *split);
|
|
|
|
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,
|
2001-11-24 06:10:42 -06:00
|
|
|
Account *parent, GNCBook *book);
|
|
|
|
void xaccAccountScrubImbalance (Account *acc, GNCBook *book);
|
|
|
|
void xaccAccountTreeScrubImbalance (Account *acc, GNCBook *book);
|
|
|
|
void xaccGroupScrubImbalance (AccountGroup *grp, GNCBook *book);
|
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. */
|
2001-11-24 06:10:42 -06:00
|
|
|
void xaccTransScrubCurrency (Transaction *trans, GNCBook *book);
|
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. */
|
2001-11-24 06:10:42 -06:00
|
|
|
void xaccAccountScrubCommodity (Account *account, GNCBook *book);
|
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. */
|
2001-11-24 06:10:42 -06:00
|
|
|
void xaccGroupScrubCommodities (AccountGroup *group, GNCBook *book);
|
2001-08-07 18:36:04 -05:00
|
|
|
|
|
|
|
#endif /* XACC_SCRUB_H */
|