|
|
|
|
@ -1,17 +1,3 @@
|
|
|
|
|
/*
|
|
|
|
|
* FILE:
|
|
|
|
|
* Scrub.c
|
|
|
|
|
*
|
|
|
|
|
* FUNCTION:
|
|
|
|
|
* Provides a set of functions and utilities for scrubbing clean
|
|
|
|
|
* single-entry accounts so that they can be promoted into
|
|
|
|
|
* self-consistent, clean double-entry accounts.
|
|
|
|
|
*
|
|
|
|
|
* HISTORY:
|
|
|
|
|
* Created by Linas Vepstas December 1998
|
|
|
|
|
* Copyright (c) 1998 Linas Vepstas
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/********************************************************************\
|
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
|
* modify it under the terms of the GNU General Public License as *
|
|
|
|
|
@ -24,10 +10,28 @@
|
|
|
|
|
* 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, write to the Free Software *
|
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
|
|
|
|
* 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 *
|
|
|
|
|
* *
|
|
|
|
|
\********************************************************************/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* FILE:
|
|
|
|
|
* Scrub.c
|
|
|
|
|
*
|
|
|
|
|
* FUNCTION:
|
|
|
|
|
* Provides a set of functions and utilities for scrubbing clean
|
|
|
|
|
* single-entry accounts so that they can be promoted into
|
|
|
|
|
* self-consistent, clean double-entry accounts.
|
|
|
|
|
*
|
|
|
|
|
* HISTORY:
|
|
|
|
|
* Created by Linas Vepstas December 1998
|
|
|
|
|
* Copyright (c) 1998, 1999, 2000 Linas Vepstas
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
@ -37,6 +41,7 @@
|
|
|
|
|
#include "GroupP.h"
|
|
|
|
|
#include "Scrub.h"
|
|
|
|
|
#include "Transaction.h"
|
|
|
|
|
#include "messages.h"
|
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
|
|
static short module = MOD_SCRUB;
|
|
|
|
|
@ -70,8 +75,9 @@ xaccAccountTreeScrubOrphans (Account *acc)
|
|
|
|
|
xaccAccountScrubOrphans (acc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* hack alert -- this string should probably be i18n'ed */
|
|
|
|
|
#define ORPHAN_STR "Orphan-"
|
|
|
|
|
#ifndef ORPHAN_STR
|
|
|
|
|
# define ORPHAN_STR "Orphan"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
xaccAccountScrubOrphans (Account *acc)
|
|
|
|
|
@ -131,8 +137,9 @@ xaccAccountTreeScrubImbalance (Account *acc)
|
|
|
|
|
xaccAccountScrubImbalance (acc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* hack alert -- this string should probably be i18n'ed */
|
|
|
|
|
#define IMBALANCE_STR "Imbalance-"
|
|
|
|
|
#ifndef IMBALANCE_STR
|
|
|
|
|
# define IMBALANCE_STR "Imbalance"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
xaccAccountScrubImbalance (Account *acc)
|
|
|
|
|
@ -180,14 +187,15 @@ static Account *
|
|
|
|
|
GetOrMakeAccount (Account *peer, Transaction *trans, const char *name_root)
|
|
|
|
|
{
|
|
|
|
|
char * accname;
|
|
|
|
|
char * currency;
|
|
|
|
|
const char * currency;
|
|
|
|
|
Account * acc;
|
|
|
|
|
AccountGroup *root;
|
|
|
|
|
|
|
|
|
|
/* build the account name */
|
|
|
|
|
currency = xaccTransFindCommonCurrency (trans);
|
|
|
|
|
accname = alloca (strlen (name_root) + strlen (currency) + 1);
|
|
|
|
|
accname = alloca (strlen (name_root) + strlen (currency) + 2);
|
|
|
|
|
strcpy (accname, name_root);
|
|
|
|
|
strcat (accname, "-");
|
|
|
|
|
strcat (accname, currency);
|
|
|
|
|
|
|
|
|
|
/* see if we've got one of these going already ... */
|
|
|
|
|
|