2002-05-12 23:29:13 -05:00
|
|
|
/********************************************************************\
|
|
|
|
* gnc-lot.h -- AR/AP invoices; inventory lots; stock lots *
|
|
|
|
* *
|
|
|
|
* 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 gnc-lot.h
|
2002-05-12 23:29:13 -05:00
|
|
|
*
|
2003-07-27 12:21:50 -05:00
|
|
|
* One often needs to know that the item 'bought' in one transaction
|
|
|
|
* is the same one as the item 'sold' in a different transaction.
|
|
|
|
* Lots are used to make this association. One Lot holds all of the
|
|
|
|
* splits that involve the same item. A lot is typically formed when
|
|
|
|
* the item is bought, and is closed when the item is sold out.
|
|
|
|
* A lot need not be a single item, it can be a quantity of the same
|
|
|
|
* thing e.g. 500 gallons of paint (sold off a few gallons at a time).
|
|
|
|
*
|
|
|
|
* Lots are required to correctly implement invoices, inventory,
|
|
|
|
* depreciation and stock market investment gains. See the file
|
2002-05-12 23:29:13 -05:00
|
|
|
* src/doc/lots.txt for implmentation overview.
|
|
|
|
*
|
|
|
|
* HISTORY:
|
|
|
|
* Created by Linas Vepstas May 2002
|
2003-03-29 22:09:45 -06:00
|
|
|
* Copyright (c) 2002,2003 Linas Vepstas <linas@linas.org>
|
2002-05-12 23:29:13 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GNC_LOT_H
|
|
|
|
#define GNC_LOT_H
|
|
|
|
|
|
|
|
#include "gnc-engine.h"
|
2002-05-13 01:02:15 -05:00
|
|
|
#include "gnc-numeric.h"
|
2003-06-24 19:52:46 -05:00
|
|
|
#include "qofbook.h"
|
2002-05-12 23:29:13 -05:00
|
|
|
|
2003-06-24 19:52:46 -05:00
|
|
|
GNCLot * gnc_lot_new (QofBook *);
|
2002-05-12 23:29:13 -05:00
|
|
|
void gnc_lot_destroy (GNCLot *);
|
|
|
|
|
2002-05-21 00:16:47 -05:00
|
|
|
const GUID * gnc_lot_get_guid (GNCLot *p);
|
2003-06-24 19:52:46 -05:00
|
|
|
GNCLot * gnc_lot_lookup (const GUID *guid, QofBook *book);
|
|
|
|
QofBook * gnc_lot_get_book (GNCLot *);
|
2002-05-21 00:16:47 -05:00
|
|
|
|
2003-03-14 17:59:25 -06:00
|
|
|
/** The gnc_lot_add_split() routine adds a split to this lot. Note
|
2002-05-23 00:24:41 -05:00
|
|
|
* that *all* splits in a lot must also be in the same account.
|
2003-09-16 07:44:01 -05:00
|
|
|
* Note that this routine adds the split unconditionally, with
|
|
|
|
* no regard for the accounting policy. To enforce a particular
|
|
|
|
* accounting polciy, use the xaccSplitAssignToLot() routine
|
|
|
|
* instead.
|
2002-05-23 00:24:41 -05:00
|
|
|
*/
|
2002-05-12 23:29:13 -05:00
|
|
|
void gnc_lot_add_split (GNCLot *, Split *);
|
|
|
|
void gnc_lot_remove_split (GNCLot *, Split *);
|
|
|
|
|
2003-03-14 17:59:25 -06:00
|
|
|
/** The gnc_lot_get_split_list() routine returns a GList of all the
|
2002-05-23 00:24:41 -05:00
|
|
|
* splits in this lot. Do *not* not free this list when done;
|
|
|
|
* it is a pointer straight into the lots intenal list. Do
|
|
|
|
* *not* add to or remove from this list directly. Calling
|
|
|
|
* either gnc_lot_add_split() or gnc_lot_remove_split() will
|
|
|
|
* invalidate the returned pointer.
|
|
|
|
*/
|
|
|
|
SplitList * gnc_lot_get_split_list (GNCLot *);
|
2002-06-27 09:09:53 -05:00
|
|
|
gint gnc_lot_count_splits (GNCLot *);
|
2002-05-23 00:24:41 -05:00
|
|
|
|
2003-03-14 17:59:25 -06:00
|
|
|
/** The gnc_lot_get_account() routine returns the account with which
|
2002-05-12 23:29:13 -05:00
|
|
|
* this lot is associated. */
|
|
|
|
Account * gnc_lot_get_account (GNCLot *);
|
|
|
|
|
2003-03-14 17:59:25 -06:00
|
|
|
/** The gnc_lot_get_balance() routine returns the balance of the lot.
|
2002-05-12 23:29:13 -05:00
|
|
|
* The commodity in which this balance is expressed is the commodity
|
|
|
|
* of the account. */
|
|
|
|
gnc_numeric gnc_lot_get_balance (GNCLot *);
|
|
|
|
|
2003-03-14 17:59:25 -06:00
|
|
|
/** The gnc_lot_is_closed() routine returns a boolean flag: is this
|
2002-05-23 00:11:51 -05:00
|
|
|
* lot closed? A lot is closed if its balance is zero. This
|
|
|
|
* routine is faster than using gnc_lot_get_balance() because
|
|
|
|
* once the balance goes to zero, this fact is cached.
|
|
|
|
*/
|
2002-05-12 23:29:13 -05:00
|
|
|
gboolean gnc_lot_is_closed (GNCLot *);
|
|
|
|
|
2003-03-29 22:08:55 -06:00
|
|
|
/** The gnc_lot_get_earliest_split() routine is a convenience routine
|
|
|
|
* that helps identify the date this lot was opened. It simply
|
|
|
|
* loops over all of the splits in the lot, and returns the split
|
|
|
|
* with the earliest split->transaction->date_posted.
|
|
|
|
*/
|
|
|
|
Split * gnc_lot_get_earliest_split (GNCLot *lot);
|
|
|
|
|
2003-04-01 22:02:34 -06:00
|
|
|
/** The gnc_lot_get_latest_split() routine is a convenience routine
|
|
|
|
* that helps identify the date this lot was closed. It simply
|
|
|
|
* loops over all of the splits in the lot, and returns the split
|
|
|
|
* with the latest split->transaction->date_posted.
|
|
|
|
*/
|
|
|
|
Split * gnc_lot_get_latest_split (GNCLot *lot);
|
|
|
|
|
2003-03-14 17:59:25 -06:00
|
|
|
/** Every lot has a place to hang kvp data. This routine returns that
|
2002-05-23 00:24:41 -05:00
|
|
|
* place.
|
|
|
|
* */
|
2003-06-27 18:33:00 -05:00
|
|
|
KvpFrame * gnc_lot_get_slots (GNCLot *);
|
2002-05-12 23:29:13 -05:00
|
|
|
|
2003-05-18 21:47:48 -05:00
|
|
|
#define LOT_IS_CLOSED "is-closed?"
|
|
|
|
#define LOT_BALANCE "balance"
|
|
|
|
|
2002-05-12 23:29:13 -05:00
|
|
|
#endif /* GNC_LOT_H */
|