2003-10-16 23:32:04 -05:00
|
|
|
/********************************************************************\
|
|
|
|
* gncOwner.h -- Business Interface: Object OWNERs *
|
|
|
|
* *
|
|
|
|
* 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 *
|
2005-11-16 23:35:02 -06:00
|
|
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
|
|
|
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
2003-10-16 23:32:04 -05:00
|
|
|
* *
|
|
|
|
\********************************************************************/
|
2004-05-07 00:11:49 -05:00
|
|
|
/** @addtogroup Business
|
|
|
|
@{ */
|
|
|
|
/** @addtogroup Owner
|
|
|
|
@{ */
|
|
|
|
/** @file gncOwner.h
|
|
|
|
@brief Business Interface: Object OWNERs
|
|
|
|
@author Copyright (C) 2001,2002 Derek Atkins <warlord@MIT.EDU>
|
2005-11-01 21:32:36 -06:00
|
|
|
@author Copyright (c) 2005 Neil Williams <linux@codehelp.co.uk>
|
2006-01-23 00:38:20 -06:00
|
|
|
@author Copyright (c) 2006 David Hampton <hampton@employees.org>
|
2004-05-07 00:11:49 -05:00
|
|
|
*/
|
2001-12-05 23:46:42 -06:00
|
|
|
|
|
|
|
#ifndef GNC_OWNER_H_
|
|
|
|
#define GNC_OWNER_H_
|
|
|
|
|
2002-01-22 09:51:14 -06:00
|
|
|
typedef struct gnc_owner_s GncOwner;
|
|
|
|
|
2003-10-19 00:13:59 -05:00
|
|
|
#define GNC_ID_OWNER "gncOwner"
|
2002-02-03 20:53:13 -06:00
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
#include "qof.h"
|
2001-12-05 23:46:42 -06:00
|
|
|
#include "gncCustomer.h"
|
|
|
|
#include "gncJob.h"
|
|
|
|
#include "gncVendor.h"
|
2003-03-03 00:47:54 -06:00
|
|
|
#include "gncEmployee.h"
|
2002-06-25 10:08:50 -05:00
|
|
|
#include "gnc-lot.h"
|
2001-12-05 23:46:42 -06:00
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
typedef enum {
|
|
|
|
GNC_OWNER_NONE ,
|
|
|
|
GNC_OWNER_UNDEFINED ,
|
|
|
|
GNC_OWNER_CUSTOMER ,
|
|
|
|
GNC_OWNER_JOB ,
|
|
|
|
GNC_OWNER_VENDOR ,
|
|
|
|
GNC_OWNER_EMPLOYEE ,
|
|
|
|
}GncOwnerType;
|
|
|
|
|
|
|
|
/** \name QOF handling
|
|
|
|
|
|
|
|
Whilst GncOwner is not a formal QOF object, these functions
|
|
|
|
are still expected to be useful in making GncOwner transparent
|
|
|
|
to QOF as they can be used by objects like GncInvoice.
|
|
|
|
@{
|
|
|
|
*/
|
|
|
|
/** return the type for the collection. */
|
|
|
|
QofIdType qofOwnerGetType(GncOwner *owner);
|
|
|
|
/** return the owner itself as an entity. */
|
|
|
|
QofEntity* qofOwnerGetOwner (GncOwner *owner);
|
|
|
|
/** set the owner from the entity. */
|
|
|
|
void qofOwnerSetEntity (GncOwner *owner, QofEntity *ent);
|
|
|
|
|
|
|
|
/** \brief Set the parent owner. */
|
|
|
|
void qofOwnerSetEndOwner (GncOwner *owner, GncOwner *parent);
|
|
|
|
GncOwner* qofOwnerCreate (QofBook *book);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gncOwnerRegister(void);
|
2001-12-05 23:46:42 -06:00
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/** \struct GncOwner */
|
2002-01-22 09:51:14 -06:00
|
|
|
struct gnc_owner_s {
|
2005-11-01 21:32:36 -06:00
|
|
|
GncOwnerType type; /**< Customer, Job, Vendor, Employee or Undefined. */
|
2001-12-05 23:46:42 -06:00
|
|
|
union {
|
2003-10-19 00:13:59 -05:00
|
|
|
gpointer undefined;
|
|
|
|
GncCustomer * customer;
|
|
|
|
GncJob * job;
|
|
|
|
GncVendor * vendor;
|
|
|
|
GncEmployee * employee;
|
2005-11-01 21:32:36 -06:00
|
|
|
} owner; /**< holds the pointer to the owner object. */
|
|
|
|
gpointer qof_temp; /**< Set type independently of the owner. */
|
2002-01-22 09:51:14 -06:00
|
|
|
};
|
2001-12-05 23:46:42 -06:00
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
/** \name Setup routines
|
|
|
|
@{
|
|
|
|
*/
|
2001-12-05 23:46:42 -06:00
|
|
|
void gncOwnerInitUndefined (GncOwner *owner, gpointer obj);
|
|
|
|
void gncOwnerInitCustomer (GncOwner *owner, GncCustomer *customer);
|
|
|
|
void gncOwnerInitJob (GncOwner *owner, GncJob *job);
|
|
|
|
void gncOwnerInitVendor (GncOwner *owner, GncVendor *vendor);
|
2003-03-03 00:47:54 -06:00
|
|
|
void gncOwnerInitEmployee (GncOwner *owner, GncEmployee *employee);
|
2005-11-01 21:32:36 -06:00
|
|
|
/** @} */
|
|
|
|
/** \name Get routines.
|
|
|
|
@{
|
|
|
|
*/
|
2002-01-22 09:51:14 -06:00
|
|
|
GncOwnerType gncOwnerGetType (const GncOwner *owner);
|
|
|
|
gpointer gncOwnerGetUndefined (const GncOwner *owner);
|
|
|
|
GncCustomer * gncOwnerGetCustomer (const GncOwner *owner);
|
|
|
|
GncJob * gncOwnerGetJob (const GncOwner *owner);
|
|
|
|
GncVendor * gncOwnerGetVendor (const GncOwner *owner);
|
2003-03-03 00:47:54 -06:00
|
|
|
GncEmployee * gncOwnerGetEmployee (const GncOwner *owner);
|
2005-11-01 21:32:36 -06:00
|
|
|
/** @} */
|
2001-12-05 23:46:42 -06:00
|
|
|
void gncOwnerCopy (const GncOwner *src, GncOwner *dest);
|
2002-01-22 09:51:14 -06:00
|
|
|
gboolean gncOwnerEqual (const GncOwner *a, const GncOwner *b);
|
2002-02-04 12:54:06 -06:00
|
|
|
int gncOwnerCompare (const GncOwner *a, const GncOwner *b);
|
2001-12-05 23:46:42 -06:00
|
|
|
|
|
|
|
const char * gncOwnerGetName (GncOwner *owner);
|
2003-01-12 16:07:33 -06:00
|
|
|
gnc_commodity * gncOwnerGetCurrency (GncOwner *owner);
|
2001-12-05 23:46:42 -06:00
|
|
|
|
2004-05-07 00:11:49 -05:00
|
|
|
/** Get the GUID of the immediate owner */
|
2002-02-03 20:53:13 -06:00
|
|
|
const GUID * gncOwnerGetGUID (GncOwner *owner);
|
2002-06-27 15:03:19 -05:00
|
|
|
GUID gncOwnerRetGUID (GncOwner *owner);
|
2002-02-03 20:53:13 -06:00
|
|
|
|
2002-10-17 10:17:47 -05:00
|
|
|
gboolean gncOwnerIsValid (GncOwner *owner);
|
|
|
|
|
2004-05-07 00:11:49 -05:00
|
|
|
/**
|
2002-02-03 20:53:13 -06:00
|
|
|
* Get the "parent" Owner or GUID thereof. The "parent" owner
|
|
|
|
* is the Customer or Vendor, or the Owner of a Job
|
|
|
|
*/
|
|
|
|
GncOwner * gncOwnerGetEndOwner (GncOwner *owner);
|
|
|
|
const GUID * gncOwnerGetEndGUID (GncOwner *owner);
|
|
|
|
|
2004-05-07 00:11:49 -05:00
|
|
|
/** attach an owner to a lot */
|
2002-06-25 10:08:50 -05:00
|
|
|
void gncOwnerAttachToLot (GncOwner *owner, GNCLot *lot);
|
|
|
|
|
2004-05-07 00:11:49 -05:00
|
|
|
/** Get the owner from the lot. If an owner is found in the lot,
|
2002-06-25 10:08:50 -05:00
|
|
|
* fill in "owner" and return TRUE. Otherwise return FALSE.
|
|
|
|
*/
|
|
|
|
gboolean gncOwnerGetOwnerFromLot (GNCLot *lot, GncOwner *owner);
|
|
|
|
|
2006-01-18 22:09:00 -06:00
|
|
|
gboolean gncOwnerGetOwnerFromTypeGuid (QofBook *book, GncOwner *owner, QofIdType type, GUID *guid);
|
|
|
|
|
2006-02-19 12:20:18 -06:00
|
|
|
/** Get the kvp-frame from the underlying owner object */
|
|
|
|
KvpFrame* gncOwnerGetSlots(GncOwner* owner);
|
|
|
|
|
2003-10-21 00:12:38 -05:00
|
|
|
#define OWNER_TYPE "type"
|
2005-11-01 21:32:36 -06:00
|
|
|
#define OWNER_TYPE_STRING "type-string" /**< Allows the type to be handled externally. */
|
2003-10-21 00:12:38 -05:00
|
|
|
#define OWNER_CUSTOMER "customer"
|
|
|
|
#define OWNER_JOB "job"
|
|
|
|
#define OWNER_VENDOR "vendor"
|
|
|
|
#define OWNER_EMPLOYEE "employee"
|
|
|
|
#define OWNER_PARENT "parent"
|
|
|
|
#define OWNER_PARENTG "parent-guid"
|
|
|
|
#define OWNER_NAME "name"
|
2002-02-03 20:53:13 -06:00
|
|
|
|
2003-10-21 00:12:38 -05:00
|
|
|
#define OWNER_FROM_LOT "owner-from-lot"
|
2002-06-27 23:39:18 -05:00
|
|
|
|
2004-05-07 00:11:49 -05:00
|
|
|
/**
|
2002-02-04 22:11:31 -06:00
|
|
|
* These two functions are mainly for the convenience of scheme code.
|
|
|
|
* Normal C code has no need to ever use these two functions, and rather
|
|
|
|
* can just use a GncOwner directly and just pass around a pointer to it.
|
|
|
|
*/
|
|
|
|
GncOwner * gncOwnerCreate (void);
|
|
|
|
void gncOwnerDestroy (GncOwner *owner);
|
|
|
|
|
2001-12-05 23:46:42 -06:00
|
|
|
#endif /* GNC_OWNER_H_ */
|
2004-05-07 00:11:49 -05:00
|
|
|
/** @} */
|
|
|
|
/** @} */
|