2003-10-16 23:32:04 -05:00
|
|
|
/********************************************************************\
|
|
|
|
* gncOrder.c -- the Core Business Order *
|
|
|
|
* *
|
|
|
|
* 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
|
|
|
* *
|
|
|
|
\********************************************************************/
|
|
|
|
|
2001-11-21 19:23:07 -06:00
|
|
|
/*
|
2002-02-03 14:01:08 -06:00
|
|
|
* Copyright (C) 2001,2002 Derek Atkins
|
2001-11-21 19:23:07 -06:00
|
|
|
* Author: Derek Atkins <warlord@MIT.EDU>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include "messages.h"
|
|
|
|
#include "gncEntry.h"
|
|
|
|
#include "gncEntryP.h"
|
|
|
|
#include "gncOrder.h"
|
|
|
|
#include "gncOrderP.h"
|
2001-12-05 23:46:42 -06:00
|
|
|
#include "gncOwner.h"
|
2003-10-21 08:53:55 -05:00
|
|
|
#include "gncOwnerP.h"
|
2001-11-21 19:23:07 -06:00
|
|
|
|
2003-10-14 16:20:55 -05:00
|
|
|
struct _gncOrder
|
|
|
|
{
|
|
|
|
QofInstance inst;
|
2001-11-21 19:23:07 -06:00
|
|
|
|
|
|
|
char * id;
|
|
|
|
char * notes;
|
2003-10-14 16:20:55 -05:00
|
|
|
gboolean active;
|
|
|
|
|
2002-02-26 22:52:33 -06:00
|
|
|
char * reference;
|
2002-02-23 22:01:57 -06:00
|
|
|
char * printname;
|
2001-12-05 23:46:42 -06:00
|
|
|
GncOwner owner;
|
2001-11-21 19:23:07 -06:00
|
|
|
GList * entries;
|
|
|
|
Timespec opened;
|
|
|
|
Timespec closed;
|
|
|
|
};
|
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
static QofLogModule log_module = GNC_MOD_BUSINESS;
|
2002-11-03 14:21:42 -06:00
|
|
|
|
2003-10-19 00:13:59 -05:00
|
|
|
#define _GNC_MOD_NAME GNC_ID_ORDER
|
2001-11-24 23:34:34 -06:00
|
|
|
|
2002-11-03 18:41:01 -06:00
|
|
|
#define SET_STR(obj, member, str) { \
|
2001-11-21 19:23:07 -06:00
|
|
|
char * tmp; \
|
|
|
|
\
|
|
|
|
if (!safe_strcmp (member, str)) return; \
|
2002-11-03 18:41:01 -06:00
|
|
|
gncOrderBeginEdit (obj); \
|
2001-11-21 19:23:07 -06:00
|
|
|
tmp = CACHE_INSERT (str); \
|
|
|
|
CACHE_REMOVE (member); \
|
|
|
|
member = tmp; \
|
|
|
|
}
|
|
|
|
|
2002-03-02 12:55:01 -06:00
|
|
|
G_INLINE_FUNC void mark_order (GncOrder *order);
|
2005-11-01 21:32:36 -06:00
|
|
|
void mark_order (GncOrder *order)
|
2002-03-02 12:55:01 -06:00
|
|
|
{
|
2003-10-14 16:20:55 -05:00
|
|
|
order->inst.dirty = TRUE;
|
2003-10-19 00:13:59 -05:00
|
|
|
qof_collection_mark_dirty (order->inst.entity.collection);
|
2003-10-14 16:20:55 -05:00
|
|
|
gnc_engine_gen_event (&order->inst.entity, GNC_EVENT_MODIFY);
|
2002-03-02 12:55:01 -06:00
|
|
|
}
|
|
|
|
|
2003-10-21 08:53:55 -05:00
|
|
|
/* =============================================================== */
|
2001-11-21 19:23:07 -06:00
|
|
|
/* Create/Destroy Functions */
|
|
|
|
|
2003-06-26 22:05:25 -05:00
|
|
|
GncOrder *gncOrderCreate (QofBook *book)
|
2001-11-21 19:23:07 -06:00
|
|
|
{
|
|
|
|
GncOrder *order;
|
|
|
|
|
2001-11-24 23:34:34 -06:00
|
|
|
if (!book) return NULL;
|
2001-11-21 19:23:07 -06:00
|
|
|
|
|
|
|
order = g_new0 (GncOrder, 1);
|
2003-10-14 16:20:55 -05:00
|
|
|
qof_instance_init (&order->inst, _GNC_MOD_NAME, book);
|
2001-11-21 19:23:07 -06:00
|
|
|
|
|
|
|
order->id = CACHE_INSERT ("");
|
|
|
|
order->notes = CACHE_INSERT ("");
|
2002-02-26 22:52:33 -06:00
|
|
|
order->reference = CACHE_INSERT ("");
|
2001-11-21 19:23:07 -06:00
|
|
|
|
|
|
|
order->active = TRUE;
|
|
|
|
|
2003-10-14 16:20:55 -05:00
|
|
|
gnc_engine_gen_event (&order->inst.entity, GNC_EVENT_CREATE);
|
2002-03-02 12:55:01 -06:00
|
|
|
|
2001-11-21 19:23:07 -06:00
|
|
|
return order;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gncOrderDestroy (GncOrder *order)
|
2002-11-03 14:21:42 -06:00
|
|
|
{
|
|
|
|
if (!order) return;
|
2003-10-14 16:20:55 -05:00
|
|
|
order->inst.do_free = TRUE;
|
2002-11-03 14:21:42 -06:00
|
|
|
gncOrderCommitEdit (order);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gncOrderFree (GncOrder *order)
|
2001-11-21 19:23:07 -06:00
|
|
|
{
|
|
|
|
if (!order) return;
|
|
|
|
|
2003-10-14 16:20:55 -05:00
|
|
|
gnc_engine_gen_event (&order->inst.entity, GNC_EVENT_DESTROY);
|
2002-03-02 12:55:01 -06:00
|
|
|
|
2001-11-21 19:23:07 -06:00
|
|
|
g_list_free (order->entries);
|
|
|
|
CACHE_REMOVE (order->id);
|
|
|
|
CACHE_REMOVE (order->notes);
|
2002-02-26 22:52:33 -06:00
|
|
|
CACHE_REMOVE (order->reference);
|
2001-11-21 19:23:07 -06:00
|
|
|
|
2002-02-23 22:01:57 -06:00
|
|
|
if (order->printname) g_free (order->printname);
|
|
|
|
|
2003-10-14 16:20:55 -05:00
|
|
|
qof_instance_release (&order->inst);
|
2001-11-21 19:23:07 -06:00
|
|
|
g_free (order);
|
|
|
|
}
|
|
|
|
|
2003-10-21 08:53:55 -05:00
|
|
|
GncOrder *
|
|
|
|
gncCloneOrder (GncOrder *from, QofBook *book)
|
|
|
|
{
|
|
|
|
GList *node;
|
|
|
|
GncOrder *order;
|
|
|
|
|
|
|
|
if (!book) return NULL;
|
|
|
|
|
|
|
|
order = g_new0 (GncOrder, 1);
|
|
|
|
qof_instance_init (&order->inst, _GNC_MOD_NAME, book);
|
|
|
|
qof_instance_gemini (&order->inst, &from->inst);
|
|
|
|
|
|
|
|
order->id = CACHE_INSERT (from->id);
|
|
|
|
order->notes = CACHE_INSERT (from->notes);
|
|
|
|
order->reference = CACHE_INSERT (from->reference);
|
|
|
|
|
|
|
|
order->active = from->active;
|
|
|
|
order->printname = NULL; /* yes, null, that's right */
|
|
|
|
order->opened = from->opened;
|
|
|
|
order->closed = from->closed;
|
|
|
|
|
|
|
|
order->owner = gncCloneOwner (&from->owner, book);
|
|
|
|
|
|
|
|
order->entries = NULL;
|
|
|
|
for (node = g_list_last(from->entries); node; node=node->prev)
|
|
|
|
{
|
|
|
|
GncEntry *entry = node->data;
|
|
|
|
entry = gncEntryObtainTwin (entry, book);
|
|
|
|
order->entries = g_list_prepend (order->entries, entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
gnc_engine_gen_event (&order->inst.entity, GNC_EVENT_CREATE);
|
|
|
|
|
|
|
|
return order;
|
|
|
|
}
|
|
|
|
|
|
|
|
GncOrder *
|
|
|
|
gncOrderObtainTwin (GncOrder *from, QofBook *book)
|
|
|
|
{
|
|
|
|
GncOrder *order;
|
|
|
|
if (!book) return NULL;
|
|
|
|
|
|
|
|
order = (GncOrder *) qof_instance_lookup_twin (QOF_INSTANCE(from), book);
|
|
|
|
if (!order)
|
|
|
|
{
|
|
|
|
order = gncCloneOrder (from, book);
|
|
|
|
}
|
|
|
|
|
|
|
|
return order;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* =============================================================== */
|
2001-11-21 19:23:07 -06:00
|
|
|
/* Set Functions */
|
|
|
|
|
|
|
|
void gncOrderSetID (GncOrder *order, const char *id)
|
|
|
|
{
|
|
|
|
if (!order || !id) return;
|
2002-11-03 18:41:01 -06:00
|
|
|
SET_STR (order, order->id, id);
|
2002-03-02 12:55:01 -06:00
|
|
|
mark_order (order);
|
2002-11-03 18:41:01 -06:00
|
|
|
gncOrderCommitEdit (order);
|
2001-11-21 19:23:07 -06:00
|
|
|
}
|
|
|
|
|
2001-12-05 23:46:42 -06:00
|
|
|
void gncOrderSetOwner (GncOrder *order, GncOwner *owner)
|
2001-11-21 19:23:07 -06:00
|
|
|
{
|
2001-12-05 23:46:42 -06:00
|
|
|
if (!order || !owner) return;
|
2002-06-21 14:00:34 -05:00
|
|
|
if (gncOwnerEqual (&order->owner, owner)) return;
|
2001-11-21 19:23:07 -06:00
|
|
|
|
2002-11-03 18:41:01 -06:00
|
|
|
gncOrderBeginEdit (order);
|
2001-12-05 23:46:42 -06:00
|
|
|
gncOwnerCopy (owner, &order->owner);
|
2002-03-02 12:55:01 -06:00
|
|
|
mark_order (order);
|
2002-11-03 18:41:01 -06:00
|
|
|
gncOrderCommitEdit (order);
|
2001-11-21 19:23:07 -06:00
|
|
|
}
|
|
|
|
|
2002-02-27 18:55:34 -06:00
|
|
|
void gncOrderSetDateOpened (GncOrder *order, Timespec date)
|
2001-11-21 19:23:07 -06:00
|
|
|
{
|
2002-02-27 18:55:34 -06:00
|
|
|
if (!order) return;
|
2002-06-21 14:00:34 -05:00
|
|
|
if (timespec_equal (&order->opened, &date)) return;
|
2002-11-03 18:41:01 -06:00
|
|
|
gncOrderBeginEdit (order);
|
2002-02-27 18:55:34 -06:00
|
|
|
order->opened = date;
|
2002-03-02 12:55:01 -06:00
|
|
|
mark_order (order);
|
2002-11-03 18:41:01 -06:00
|
|
|
gncOrderCommitEdit (order);
|
2001-11-21 19:23:07 -06:00
|
|
|
}
|
|
|
|
|
2002-02-27 18:55:34 -06:00
|
|
|
void gncOrderSetDateClosed (GncOrder *order, Timespec date)
|
2001-11-21 19:23:07 -06:00
|
|
|
{
|
2002-02-27 18:55:34 -06:00
|
|
|
if (!order) return;
|
2002-06-21 14:00:34 -05:00
|
|
|
if (timespec_equal (&order->closed, &date)) return;
|
2002-11-03 18:41:01 -06:00
|
|
|
gncOrderBeginEdit (order);
|
2002-02-27 18:55:34 -06:00
|
|
|
order->closed = date;
|
2002-03-02 12:55:01 -06:00
|
|
|
mark_order (order);
|
2002-11-03 18:41:01 -06:00
|
|
|
gncOrderCommitEdit (order);
|
2001-11-21 19:23:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void gncOrderSetNotes (GncOrder *order, const char *notes)
|
|
|
|
{
|
|
|
|
if (!order || !notes) return;
|
2002-11-03 18:41:01 -06:00
|
|
|
SET_STR (order, order->notes, notes);
|
2002-03-02 12:55:01 -06:00
|
|
|
mark_order (order);
|
2002-11-03 18:41:01 -06:00
|
|
|
gncOrderCommitEdit (order);
|
2001-11-21 19:23:07 -06:00
|
|
|
}
|
|
|
|
|
2002-02-26 22:52:33 -06:00
|
|
|
void gncOrderSetReference (GncOrder *order, const char *reference)
|
|
|
|
{
|
|
|
|
if (!order || !reference) return;
|
2002-11-03 18:41:01 -06:00
|
|
|
SET_STR (order, order->reference, reference);
|
2002-03-02 12:55:01 -06:00
|
|
|
mark_order (order);
|
2002-11-03 18:41:01 -06:00
|
|
|
gncOrderCommitEdit (order);
|
2002-02-26 22:52:33 -06:00
|
|
|
}
|
|
|
|
|
2001-11-21 19:23:07 -06:00
|
|
|
void gncOrderSetActive (GncOrder *order, gboolean active)
|
|
|
|
{
|
|
|
|
if (!order) return;
|
2002-06-21 14:00:34 -05:00
|
|
|
if (order->active == active) return;
|
2002-11-03 18:41:01 -06:00
|
|
|
gncOrderBeginEdit (order);
|
2001-11-21 19:23:07 -06:00
|
|
|
order->active = active;
|
2002-03-02 12:55:01 -06:00
|
|
|
mark_order (order);
|
2002-11-03 18:41:01 -06:00
|
|
|
gncOrderCommitEdit (order);
|
2001-11-21 19:23:07 -06:00
|
|
|
}
|
|
|
|
|
2003-10-21 08:53:55 -05:00
|
|
|
/* =============================================================== */
|
2001-11-21 19:23:07 -06:00
|
|
|
/* Add an Entry to the Order */
|
|
|
|
void gncOrderAddEntry (GncOrder *order, GncEntry *entry)
|
|
|
|
{
|
|
|
|
GncOrder *old;
|
|
|
|
|
|
|
|
if (!order || !entry) return;
|
|
|
|
|
|
|
|
old = gncEntryGetOrder (entry);
|
|
|
|
if (old == order) return; /* I already own it */
|
|
|
|
if (old) gncOrderRemoveEntry (old, entry);
|
|
|
|
|
2002-02-27 23:10:07 -06:00
|
|
|
order->entries = g_list_insert_sorted (order->entries, entry,
|
|
|
|
(GCompareFunc)gncEntryCompare);
|
2002-02-28 22:15:01 -06:00
|
|
|
|
|
|
|
/* This will send out an event -- make sure we're attached */
|
|
|
|
gncEntrySetOrder (entry, order);
|
2002-03-02 12:55:01 -06:00
|
|
|
mark_order (order);
|
2001-11-21 19:23:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void gncOrderRemoveEntry (GncOrder *order, GncEntry *entry)
|
|
|
|
{
|
|
|
|
if (!order || !entry) return;
|
|
|
|
|
|
|
|
gncEntrySetOrder (entry, NULL);
|
|
|
|
order->entries = g_list_remove (order->entries, entry);
|
2002-03-02 12:55:01 -06:00
|
|
|
mark_order (order);
|
2001-11-21 19:23:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get Functions */
|
|
|
|
|
|
|
|
const char * gncOrderGetID (GncOrder *order)
|
|
|
|
{
|
|
|
|
if (!order) return NULL;
|
|
|
|
return order->id;
|
|
|
|
}
|
|
|
|
|
2001-12-05 23:46:42 -06:00
|
|
|
GncOwner * gncOrderGetOwner (GncOrder *order)
|
2001-11-21 19:23:07 -06:00
|
|
|
{
|
|
|
|
if (!order) return NULL;
|
2001-12-05 23:46:42 -06:00
|
|
|
return &order->owner;
|
2001-11-21 19:23:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
Timespec gncOrderGetDateOpened (GncOrder *order)
|
|
|
|
{
|
|
|
|
Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
|
|
|
|
if (!order) return ts;
|
|
|
|
return order->opened;
|
|
|
|
}
|
|
|
|
|
|
|
|
Timespec gncOrderGetDateClosed (GncOrder *order)
|
|
|
|
{
|
|
|
|
Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
|
|
|
|
if (!order) return ts;
|
|
|
|
return order->closed;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char * gncOrderGetNotes (GncOrder *order)
|
|
|
|
{
|
|
|
|
if (!order) return NULL;
|
|
|
|
return order->notes;
|
|
|
|
}
|
|
|
|
|
2002-02-26 22:52:33 -06:00
|
|
|
const char * gncOrderGetReference (GncOrder *order)
|
|
|
|
{
|
|
|
|
if (!order) return NULL;
|
|
|
|
return order->reference;
|
|
|
|
}
|
|
|
|
|
2001-11-21 19:23:07 -06:00
|
|
|
gboolean gncOrderGetActive (GncOrder *order)
|
|
|
|
{
|
|
|
|
if (!order) return FALSE;
|
|
|
|
return order->active;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the list Entries */
|
|
|
|
GList * gncOrderGetEntries (GncOrder *order)
|
|
|
|
{
|
|
|
|
if (!order) return NULL;
|
|
|
|
return order->entries;
|
|
|
|
}
|
|
|
|
|
2002-02-19 12:23:53 -06:00
|
|
|
gboolean gncOrderIsClosed (GncOrder *order)
|
|
|
|
{
|
|
|
|
if (!order) return FALSE;
|
|
|
|
if (order->closed.tv_sec || order->closed.tv_nsec) return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-10-21 08:53:55 -05:00
|
|
|
/* =============================================================== */
|
|
|
|
|
2001-11-21 19:23:07 -06:00
|
|
|
void gncOrderBeginEdit (GncOrder *order)
|
|
|
|
{
|
2005-11-01 21:32:36 -06:00
|
|
|
qof_begin_edit(&order->inst);
|
2001-11-21 19:23:07 -06:00
|
|
|
}
|
|
|
|
|
2003-10-14 16:20:55 -05:00
|
|
|
static inline void gncOrderOnError (QofInstance *order, QofBackendError errcode)
|
2001-11-21 19:23:07 -06:00
|
|
|
{
|
2003-06-26 22:36:02 -05:00
|
|
|
PERR("Order QofBackend Failure: %d", errcode);
|
2002-11-03 14:21:42 -06:00
|
|
|
}
|
2002-03-04 13:34:52 -06:00
|
|
|
|
2003-10-16 23:32:04 -05:00
|
|
|
static inline void gncOrderOnDone (QofInstance *order) {}
|
2003-10-14 16:20:55 -05:00
|
|
|
|
|
|
|
static inline void order_free (QofInstance *inst)
|
|
|
|
{
|
|
|
|
GncOrder *order = (GncOrder *) inst;
|
|
|
|
gncOrderFree (order);
|
2001-11-21 19:23:07 -06:00
|
|
|
}
|
|
|
|
|
2002-11-03 14:21:42 -06:00
|
|
|
void gncOrderCommitEdit (GncOrder *order)
|
|
|
|
{
|
2004-06-13 11:48:32 -05:00
|
|
|
QOF_COMMIT_EDIT_PART1 (&order->inst);
|
|
|
|
QOF_COMMIT_EDIT_PART2 (&order->inst, gncOrderOnError,
|
2003-10-14 16:20:55 -05:00
|
|
|
gncOrderOnDone, order_free);
|
2002-11-03 14:21:42 -06:00
|
|
|
}
|
|
|
|
|
2002-02-03 14:01:08 -06:00
|
|
|
int gncOrderCompare (GncOrder *a, GncOrder *b)
|
|
|
|
{
|
|
|
|
int compare;
|
|
|
|
|
|
|
|
if (a == b) return 0;
|
|
|
|
if (!a && b) return -1;
|
|
|
|
if (a && !b) return 1;
|
|
|
|
|
|
|
|
compare = safe_strcmp (a->id, b->id);
|
2002-02-27 23:10:07 -06:00
|
|
|
if (compare) return compare;
|
2002-02-03 14:01:08 -06:00
|
|
|
|
|
|
|
compare = timespec_cmp (&(a->opened), &(b->opened));
|
2002-02-27 23:10:07 -06:00
|
|
|
if (compare) return compare;
|
2002-02-03 14:01:08 -06:00
|
|
|
|
|
|
|
compare = timespec_cmp (&(a->closed), &(b->closed));
|
2002-02-27 23:10:07 -06:00
|
|
|
if (compare) return compare;
|
2002-02-03 14:01:08 -06:00
|
|
|
|
2003-10-14 16:20:55 -05:00
|
|
|
return guid_compare (&(a->inst.entity.guid), &(b->inst.entity.guid));
|
2002-02-03 14:01:08 -06:00
|
|
|
}
|
|
|
|
|
2003-10-19 00:13:59 -05:00
|
|
|
/* =========================================================== */
|
2001-11-24 23:34:34 -06:00
|
|
|
/* Package-Private functions */
|
|
|
|
|
2003-10-19 00:13:59 -05:00
|
|
|
static const char *
|
|
|
|
_gncOrderPrintable (gpointer obj)
|
2002-02-23 22:01:57 -06:00
|
|
|
{
|
2002-02-24 16:12:24 -06:00
|
|
|
GncOrder *order = obj;
|
|
|
|
|
2002-02-23 22:01:57 -06:00
|
|
|
g_return_val_if_fail (order, NULL);
|
|
|
|
|
2003-10-14 16:20:55 -05:00
|
|
|
if (order->inst.dirty || order->printname == NULL) {
|
2002-02-23 22:01:57 -06:00
|
|
|
if (order->printname) g_free (order->printname);
|
|
|
|
|
|
|
|
order->printname =
|
|
|
|
g_strdup_printf ("%s%s", order->id,
|
|
|
|
gncOrderIsClosed (order) ? _(" (closed)") : "");
|
|
|
|
}
|
|
|
|
|
|
|
|
return order->printname;
|
|
|
|
}
|
|
|
|
|
2003-10-19 00:13:59 -05:00
|
|
|
static QofObject gncOrderDesc =
|
|
|
|
{
|
|
|
|
interface_version: QOF_OBJECT_VERSION,
|
|
|
|
e_type: _GNC_MOD_NAME,
|
|
|
|
type_label: "Order",
|
2004-10-16 10:51:26 -05:00
|
|
|
create: (gpointer)gncOrderCreate,
|
2003-10-19 00:13:59 -05:00
|
|
|
book_begin: NULL,
|
|
|
|
book_end: NULL,
|
|
|
|
is_dirty: qof_collection_is_dirty,
|
|
|
|
mark_clean: qof_collection_mark_clean,
|
|
|
|
foreach: qof_collection_foreach,
|
|
|
|
printable: _gncOrderPrintable,
|
2004-06-12 15:27:08 -05:00
|
|
|
version_cmp: (int (*)(gpointer, gpointer)) qof_instance_version_cmp,
|
2001-11-21 19:23:07 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
gboolean gncOrderRegister (void)
|
|
|
|
{
|
2003-09-27 05:21:27 -05:00
|
|
|
static QofParam params[] = {
|
2004-07-26 07:41:43 -05:00
|
|
|
{ ORDER_ID, QOF_TYPE_STRING, (QofAccessFunc)gncOrderGetID, (QofSetterFunc)gncOrderSetID },
|
|
|
|
{ ORDER_REFERENCE, QOF_TYPE_STRING, (QofAccessFunc)gncOrderGetReference, (QofSetterFunc)gncOrderSetReference },
|
|
|
|
{ ORDER_OWNER, GNC_ID_OWNER, (QofAccessFunc)gncOrderGetOwner, (QofSetterFunc)gncOrderSetOwner },
|
|
|
|
{ ORDER_OPENED, QOF_TYPE_DATE, (QofAccessFunc)gncOrderGetDateOpened, (QofSetterFunc)gncOrderSetDateOpened },
|
2003-09-27 11:33:06 -05:00
|
|
|
{ ORDER_IS_CLOSED, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncOrderIsClosed, NULL },
|
2004-07-26 07:41:43 -05:00
|
|
|
{ ORDER_CLOSED, QOF_TYPE_DATE, (QofAccessFunc)gncOrderGetDateClosed, (QofSetterFunc)gncOrderSetDateClosed },
|
|
|
|
{ ORDER_NOTES, QOF_TYPE_STRING, (QofAccessFunc)gncOrderGetNotes, (QofSetterFunc)gncOrderSetNotes },
|
|
|
|
{ QOF_PARAM_ACTIVE, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncOrderGetActive, (QofSetterFunc)gncOrderSetActive },
|
2004-05-23 12:31:40 -05:00
|
|
|
{ QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
|
|
|
|
{ QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
|
2002-02-03 14:01:08 -06:00
|
|
|
{ NULL },
|
|
|
|
};
|
|
|
|
|
2003-09-27 11:33:06 -05:00
|
|
|
qof_class_register (_GNC_MOD_NAME, (QofSortFunc)gncOrderCompare, params);
|
2002-02-03 14:01:08 -06:00
|
|
|
|
2003-06-26 22:09:39 -05:00
|
|
|
return qof_object_register (&gncOrderDesc);
|
2001-11-21 19:23:07 -06:00
|
|
|
}
|
|
|
|
|
2003-06-26 22:05:25 -05:00
|
|
|
gint64 gncOrderNextID (QofBook *book)
|
2001-11-21 19:23:07 -06:00
|
|
|
{
|
2003-10-17 00:15:56 -05:00
|
|
|
return qof_book_get_counter (book, _GNC_MOD_NAME);
|
2001-11-21 19:23:07 -06:00
|
|
|
}
|