start working on functions to cleanup up usage of Lots in trading accounts

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8116 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 2003-03-30 03:03:02 +00:00
parent 5fc7551350
commit f8e733bb52
2 changed files with 126 additions and 0 deletions

75
src/engine/Scrub2.c Normal file
View File

@ -0,0 +1,75 @@
/********************************************************************\
* 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 *
\********************************************************************/
/** @file Scrub2.c
* @breif Utilities to Convert Stock Accounts to use Lots
* @author Created by Linas Vepstas March 2003
* @author Copyright (c) 2003 Linas Vepstas <linas@linas.org>
* XXX under construction, just started, not done
*
* Provides a set of functions and utilities for checking and
* repairing ('scrubbing clean') stock and commodity accounts
* to use Lots & accounting schedules so that books can be closed.
*
*/
#include "gnc-engine.h"
#include "Scrub2.h"
/* ============================================================== */
gboolean
xaccAccountHasTrades (Account *acc)
{
gnc_commodity *acc_comm;
SplitList *node;
if (!acc) return FALSE;
acc_comm = acc->commodity;
for (node=acc->splits; node; node=node->next)
{
Split *s = node->data;
Transaction *t = s->parent;
if (acc_comm != t->common_currency) return TRUE;
}
return FALSE;
}
/* ============================================================== */
void
xaccAccountScrubLots (Account *acc)
{
if (!acc) return;
for (node=acc->splits; node; node=node->next)
{
Split * s = node->data;
GNCLot *lot = s->lot;
gnc_lot_is_closed (lot);
}
}
/* =========================== END OF FILE ======================= */

51
src/engine/Scrub2.h Normal file
View File

@ -0,0 +1,51 @@
/********************************************************************\
* 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 *
\********************************************************************/
/** @addtogroup Engine
@{ */
/** @file Scrub2.h
* @breif Utilities to Convert Stock Accounts to use Lots
* @author Created by Linas Vepstas March 2003
* @author Copyright (c) 2003 Linas Vepstas <linas@linas.org>
*
*
* Provides a set of functions and utilities for checking and
* repairing ('scrubbing clean') stock and commodity accounts
* to use Lots & accounting schedules so that books can be closed.
*
*/
#ifndef XACC_SCRUB2_H
#define XACC_SCRUB2_H
#include "gnc-engine.h"
/** The xaccAccountHasTrades() method checks to see if the
* indicated account is used in the trading of commodities.
* A 'trading' account will contain transactions whose
* transaction currency is not the same as the account
* commodity. The existance of such transactions is
* the very definition of a 'trade'. This routine returns
* TRUE if this is a trading account, else it returns
* FALSE.
*/
gboolean xaccAccountHasTrades (Account *);
#endif /* XACC_SCRUB2_H */
/** @} */