2001-12-05 23:46:42 -06:00
|
|
|
/*
|
|
|
|
* gncOwner.h -- Business Interface: Object OWNERs
|
2002-01-22 09:51:14 -06:00
|
|
|
* Copyright (C) 2001, 2002 Derek Atkins
|
2001-12-05 23:46:42 -06:00
|
|
|
* Author: Derek Atkins <warlord@MIT.EDU>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GNC_OWNER_H_
|
|
|
|
#define GNC_OWNER_H_
|
|
|
|
|
2002-01-22 09:51:14 -06:00
|
|
|
typedef struct gnc_owner_s GncOwner;
|
|
|
|
|
2002-02-03 20:53:13 -06:00
|
|
|
#define GNC_OWNER_MODULE_NAME "gncOwner"
|
|
|
|
|
2001-12-05 23:46:42 -06:00
|
|
|
#include "gncCustomer.h"
|
|
|
|
#include "gncJob.h"
|
|
|
|
#include "gncVendor.h"
|
2002-06-25 10:08:50 -05:00
|
|
|
#include "gnc-lot.h"
|
2001-12-05 23:46:42 -06:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
GNC_OWNER_NONE,
|
|
|
|
GNC_OWNER_UNDEFINED,
|
|
|
|
GNC_OWNER_CUSTOMER,
|
|
|
|
GNC_OWNER_JOB,
|
|
|
|
GNC_OWNER_VENDOR
|
|
|
|
} GncOwnerType;
|
|
|
|
|
2002-01-22 09:51:14 -06:00
|
|
|
struct gnc_owner_s {
|
2001-12-05 23:46:42 -06:00
|
|
|
GncOwnerType type;
|
|
|
|
union {
|
|
|
|
gpointer undefined;
|
|
|
|
GncCustomer * customer;
|
|
|
|
GncJob * job;
|
|
|
|
GncVendor * vendor;
|
|
|
|
} owner;
|
2002-01-22 09:51:14 -06:00
|
|
|
};
|
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);
|
|
|
|
|
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);
|
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
|
|
|
|
2002-02-03 20:53:13 -06:00
|
|
|
/* Get the GUID of the immediate owner */
|
|
|
|
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);
|
|
|
|
|
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);
|
|
|
|
|
2002-06-25 10:08:50 -05:00
|
|
|
/* attach an owner to a lot */
|
|
|
|
void gncOwnerAttachToLot (GncOwner *owner, GNCLot *lot);
|
|
|
|
|
|
|
|
/* Get the owner from the lot. If an owner is found in the lot,
|
|
|
|
* fill in "owner" and return TRUE. Otherwise return FALSE.
|
|
|
|
*/
|
|
|
|
gboolean gncOwnerGetOwnerFromLot (GNCLot *lot, GncOwner *owner);
|
|
|
|
|
2002-02-03 20:53:13 -06:00
|
|
|
#define OWNER_TYPE "type"
|
|
|
|
#define OWNER_CUSTOMER "customer"
|
|
|
|
#define OWNER_JOB "job"
|
|
|
|
#define OWNER_VENDOR "vendor"
|
|
|
|
#define OWNER_PARENT "parent"
|
|
|
|
#define OWNER_PARENTG "parent-guid"
|
|
|
|
#define OWNER_NAME "name"
|
|
|
|
|
2002-06-27 23:39:18 -05:00
|
|
|
#define OWNER_FROM_LOT "owner-from-lot"
|
|
|
|
|
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_ */
|