[Gnucash-changes] CashUtil sync

Neil Williams codehelp at cvs.gnucash.org
Mon Aug 22 15:55:54 EDT 2005


Log Message:
-----------
CashUtil sync

Tags:
----
gnucash-gnome2-dev

Modified Files:
--------------
    gnucash/src/business/business-core:
        gncAddress.c
        gncBillTerm.c
        gncBillTerm.h
        gncCustomer.c
        gncEmployee.c
        gncEmployeeP.h
        gncEntry.c
        gncEntry.h
        gncInvoice.c
        gncJob.c
        gncOrder.c
        gncOwner.c
        gncTaxTable.c
        gncTaxTable.h
        gncVendor.c
    gnucash/src/business/business-core/test:
        test-address.c
        test-customer.c
        test-employee.c
        test-job.c
        test-vendor.c

Revision Data
-------------
Index: gncEmployee.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncEmployee.c,v
retrieving revision 1.15.4.5
retrieving revision 1.15.4.6
diff -Lsrc/business/business-core/gncEmployee.c -Lsrc/business/business-core/gncEmployee.c -u -r1.15.4.5 -r1.15.4.6
--- src/business/business-core/gncEmployee.c
+++ src/business/business-core/gncEmployee.c
@@ -35,9 +35,8 @@
 #include "qof-be-utils.h"
 #include "qofbook.h"
 #include "qofclass.h"
-#include "qofid.h"
 #include "qofid-p.h"
-#include "qofinstance.h"
+#include "qofbackend-p.h"
 #include "qofinstance-p.h"
 #include "qofobject.h"
 #include "qofquery.h"
@@ -47,10 +46,12 @@
 #include "messages.h"
 #include "gnc-commodity.h"
 #include "gnc-engine-util.h"
-#include "gnc-event-p.h"
+#include "gnc-event.h"
 
 #include "gncAddressP.h"
+#ifdef GNUCASH_MAJOR_VERSION
 #include "gncBusiness.h"
+#endif
 #include "gncEmployee.h"
 #include "gncEmployeeP.h"
 
Index: gncBillTerm.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncBillTerm.h,v
retrieving revision 1.3.4.6
retrieving revision 1.3.4.7
diff -Lsrc/business/business-core/gncBillTerm.h -Lsrc/business/business-core/gncBillTerm.h -u -r1.3.4.6 -r1.3.4.7
--- src/business/business-core/gncBillTerm.h
+++ src/business/business-core/gncBillTerm.h
@@ -39,9 +39,9 @@
 #include "qofid.h"
 #include "qofinstance.h"
 #include "gnc-engine-util.h"
-
+#ifdef GNUCASH_MAJOR_VERSION
 #include "gncBusiness.h"
-
+#endif
 #define GNC_ID_BILLTERM       "gncBillTerm"
 #define GNC_IS_BILLTERM(obj)  (QOF_CHECK_TYPE((obj), GNC_ID_BILLTERM))
 #define GNC_BILLTERM(obj)     (QOF_CHECK_CAST((obj), GNC_ID_BILLTERM, GncBillTerm))
Index: gncOwner.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncOwner.c,v
retrieving revision 1.15.4.7
retrieving revision 1.15.4.8
diff -Lsrc/business/business-core/gncOwner.c -Lsrc/business/business-core/gncOwner.c -u -r1.15.4.7 -r1.15.4.8
--- src/business/business-core/gncOwner.c
+++ src/business/business-core/gncOwner.c
@@ -247,13 +247,13 @@
   default:
     return NULL;
   case GNC_OWNER_CUSTOMER:
-    return (gnc_commodity*)gncCustomerGetCurrency (owner->owner.customer);
+    return gncCustomerGetCurrency (owner->owner.customer);
   case GNC_OWNER_VENDOR:
-    return (gnc_commodity*)gncVendorGetCurrency (owner->owner.vendor);
+    return gncVendorGetCurrency (owner->owner.vendor);
   case GNC_OWNER_EMPLOYEE:
-    return (gnc_commodity*)gncEmployeeGetCurrency (owner->owner.employee);
+    return gncEmployeeGetCurrency (owner->owner.employee);
   case GNC_OWNER_JOB:
-    return (gnc_commodity*)gncOwnerGetCurrency ((GncOwner*)gncJobGetOwner (owner->owner.job));
+    return gncOwnerGetCurrency (gncJobGetOwner (owner->owner.job));
   }
 }
 
@@ -281,7 +281,7 @@
       owner.owner.customer = gncCustomerObtainTwin (from->owner.customer, book);
       return owner;
     case GNC_OWNER_JOB:
-      owner.owner.job = (GncJob*)gncJobObtainTwin (from->owner.job, book);
+      owner.owner.job = gncJobObtainTwin (from->owner.job, book);
       return owner;
     case GNC_OWNER_VENDOR:
       owner.owner.vendor = gncVendorObtainTwin (from->owner.vendor, book);
@@ -361,7 +361,7 @@
   case GNC_OWNER_EMPLOYEE:
     return owner;
   case GNC_OWNER_JOB:
-    return (GncOwner*)gncJobGetOwner (owner->owner.job);
+    return gncJobGetOwner (owner->owner.job);
   }
 }
 
Index: gncInvoice.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncInvoice.c,v
retrieving revision 1.56.4.13
retrieving revision 1.56.4.14
diff -Lsrc/business/business-core/gncInvoice.c -Lsrc/business/business-core/gncInvoice.c -u -r1.56.4.13 -r1.56.4.14
--- src/business/business-core/gncInvoice.c
+++ src/business/business-core/gncInvoice.c
@@ -49,8 +49,10 @@
 
 #include "gnc-event.h"
 #include "gnc-lot.h"
+#ifdef GNUCASH_MAJOR_VERSION
+#include "gncBusiness.h"
+#endif
 
-//#include "gncBusiness.h"
 #include "gncBillTermP.h"
 #include "gncEntry.h"
 #include "gncEntryP.h"
@@ -500,7 +502,7 @@
   Transaction *txn;
   Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
   if (!invoice) return ts;
-  txn = (Transaction*)gncInvoiceGetPostedTxn (invoice);
+  txn = gncInvoiceGetPostedTxn (invoice);
   if (!txn) return ts;
   return xaccTransRetDateDueTS (txn);
 }
@@ -863,7 +865,7 @@
   /* Figure out if we need to separate out "credit-card" items */
   owner = gncOwnerGetEndOwner (gncInvoiceGetOwner (invoice));
   if (gncInvoiceGetOwnerType (invoice) == GNC_OWNER_EMPLOYEE)
-    ccard_acct = (Account*)gncEmployeeGetCCard (gncOwnerGetEmployee (owner));
+    ccard_acct = gncEmployeeGetCCard (gncOwnerGetEmployee (owner));
 
   /* Find an existing payment-lot for this owner */
   {
@@ -942,7 +944,7 @@
     gncEntryGetValue (entry, reverse, &value, NULL, &tax, &taxes);
 
     /* add the value for the account split */
-    this_acc = (reverse ? (Account*)gncEntryGetInvAccount (entry) :
+    this_acc = (reverse ? gncEntryGetInvAccount (entry) :
 		gncEntryGetBillAccount (entry));
     if (this_acc) {
       if (gnc_numeric_check (value) == GNC_ERROR_OK) {
Index: gncEntry.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncEntry.h,v
retrieving revision 1.22.4.6
retrieving revision 1.22.4.7
diff -Lsrc/business/business-core/gncEntry.h -Lsrc/business/business-core/gncEntry.h -u -r1.22.4.6 -r1.22.4.7
--- src/business/business-core/gncEntry.h
+++ src/business/business-core/gncEntry.h
@@ -48,10 +48,13 @@
 #include "qofinstance.h"
 
 #include "gnc-date.h"
+#ifdef GNUCASH_MAJOR_VERSION
 #include "gncBusiness.h"
+#endif
 #include "gncInvoice.h"
 #include "gncOrder.h"
 #include "gncTaxTable.h"
+#include "gncOwner.h"
 
 #define GNC_ID_ENTRY "gncEntry"
 #define GNC_IS_ENTRY(obj)  (QOF_CHECK_TYPE((obj), GNC_ID_ENTRY))
Index: gncEmployeeP.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncEmployeeP.h,v
retrieving revision 1.3.4.2
retrieving revision 1.3.4.3
diff -Lsrc/business/business-core/gncEmployeeP.h -Lsrc/business/business-core/gncEmployeeP.h -u -r1.3.4.2 -r1.3.4.3
--- src/business/business-core/gncEmployeeP.h
+++ src/business/business-core/gncEmployeeP.h
@@ -30,7 +30,6 @@
 #define GNC_EMPLOYEEP_H_
 
 #include "gncEmployee.h"
-#include "qofid-p.h"
 
 gboolean gncEmployeeRegister (void);
 gint64 gncEmployeeNextID (QofBook *book);
Index: gncCustomer.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncCustomer.c,v
retrieving revision 1.20.4.8
retrieving revision 1.20.4.9
diff -Lsrc/business/business-core/gncCustomer.c -Lsrc/business/business-core/gncCustomer.c -u -r1.20.4.8 -r1.20.4.9
--- src/business/business-core/gncCustomer.c
+++ src/business/business-core/gncCustomer.c
@@ -49,7 +49,10 @@
 #include "gncAddressP.h"
 #include "gncBillTermP.h"
 #include "gncInvoice.h"
-//#include "gncBusiness.h"
+#ifdef GNUCASH_MAJOR_VERSION
+#include "gncBusiness.h"
+#endif
+
 #include "gncCustomer.h"
 #include "gncCustomerP.h"
 #include "gncJobP.h"
@@ -161,7 +164,7 @@
   for (node=g_list_last(cust->jobs); node; node=node->next)
   {
     GncJob *job = node->data;
-    job = (GncJob*)gncJobObtainTwin (job, book);
+    job = gncJobObtainTwin (job, book);
     cust->jobs = g_list_prepend(cust->jobs, job);
   }
 
@@ -599,6 +602,7 @@
   if(!qof_choice_add_class(GNC_ID_INVOICE, GNC_ID_CUSTOMER, INVOICE_OWNER)) { return FALSE; }
   if(!qof_choice_add_class(GNC_ID_JOB, GNC_ID_CUSTOMER, JOB_OWNER)) { return FALSE; }
   qof_class_register (_GNC_MOD_NAME, (QofSortFunc)gncCustomerCompare,params);
+  if(!qof_choice_create(GNC_ID_CUSTOMER)) { return FALSE;}
   /* temp */
   _gncCustomerPrintable(NULL);
   return qof_object_register (&gncCustomerDesc);
Index: gncVendor.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncVendor.c,v
retrieving revision 1.21.4.5
retrieving revision 1.21.4.6
diff -Lsrc/business/business-core/gncVendor.c -Lsrc/business/business-core/gncVendor.c -u -r1.21.4.5 -r1.21.4.6
--- src/business/business-core/gncVendor.c
+++ src/business/business-core/gncVendor.c
@@ -35,9 +35,7 @@
 #include "qof-be-utils.h"
 #include "qofbook.h"
 #include "qofclass.h"
-#include "qofid.h"
 #include "qofid-p.h"
-#include "qofinstance.h"
 #include "qofinstance-p.h"
 #include "qofobject.h"
 #include "qofquery.h"
@@ -46,11 +44,15 @@
 #include "messages.h"
 #include "gnc-commodity.h"
 #include "gnc-engine-util.h"
-#include "gnc-event-p.h"
+#include "gnc-event.h"
 
 #include "gncAddressP.h"
 #include "gncBillTermP.h"
+#include "gncInvoice.h"
+#ifdef GNUCASH_MAJOR_VERSION
 #include "gncBusiness.h"
+#endif
+
 #include "gncJobP.h"
 #include "gncTaxTableP.h"
 #include "gncVendor.h"
@@ -547,6 +549,9 @@
     { NULL },
   };
 
+  if(!qof_choice_add_class(GNC_ID_INVOICE, GNC_ID_VENDOR, INVOICE_OWNER)) { return FALSE; }
+  if(!qof_choice_add_class(GNC_ID_JOB, GNC_ID_VENDOR, JOB_OWNER)) { return FALSE; }
+
   qof_class_register (_GNC_MOD_NAME, (QofSortFunc)gncVendorCompare, params);
 
   return qof_object_register (&gncVendorDesc);
Index: gncJob.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncJob.c,v
retrieving revision 1.18.4.7
retrieving revision 1.18.4.8
diff -Lsrc/business/business-core/gncJob.c -Lsrc/business/business-core/gncJob.c -u -r1.18.4.7 -r1.18.4.8
--- src/business/business-core/gncJob.c
+++ src/business/business-core/gncJob.c
@@ -47,8 +47,10 @@
 #include "qofobject.h"
 #include "qofquery.h"
 #include "qofquerycore.h"
-
-//#include "gncBusiness.h"
+#include "qofbackend-p.h"
+#ifdef GNUCASH_MAJOR_VERSION
+#include "gncBusiness.h"
+#endif
 #include "gncInvoice.h"
 #include "gncJob.h"
 #include "gncJobP.h"
@@ -388,8 +390,11 @@
     { JOB_NAME, QOF_TYPE_STRING, (QofAccessFunc)gncJobGetName, (QofSetterFunc)gncJobSetName },
     { JOB_ACTIVE, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncJobGetActive, (QofSetterFunc)gncJobSetActive },
     { JOB_REFERENCE, QOF_TYPE_STRING, (QofAccessFunc)gncJobGetReference, (QofSetterFunc)gncJobSetReference },
-/*    { JOB_OWNER, QOF_TYPE_CHOICE, (QofAccessFunc)qofJobGetOwner, (QofSetterFunc)qofJobSetOwner },*/
+#ifdef GNUCASH_MAJOR_VERSION
     { JOB_OWNER, GNC_ID_OWNER, (QofAccessFunc)gncJobGetOwner, NULL },
+#else
+    { JOB_OWNER, QOF_TYPE_CHOICE, (QofAccessFunc)qofJobGetOwner, (QofSetterFunc)qofJobSetOwner },
+#endif
     { QOF_PARAM_ACTIVE, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncJobGetActive, NULL },
     { QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
     { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
@@ -398,10 +403,12 @@
 
   if(!qof_choice_create(GNC_ID_JOB)) { return FALSE; }
   if(!qof_choice_add_class(GNC_ID_INVOICE, GNC_ID_JOB, INVOICE_OWNER)) { return FALSE; }
+
+  qof_class_register (_GNC_MOD_NAME, (QofSortFunc)gncJobCompare, params);
+#ifdef GNUCASH_MAJOR_VERSION
   qofJobGetOwner(NULL);
   qofJobSetOwner(NULL, NULL);
-  qof_class_register (_GNC_MOD_NAME, (QofSortFunc)gncJobCompare, params);
-
+#endif
   return qof_object_register (&gncJobDesc);
 }
 
Index: gncBillTerm.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncBillTerm.c,v
retrieving revision 1.6.4.6
retrieving revision 1.6.4.7
diff -Lsrc/business/business-core/gncBillTerm.c -Lsrc/business/business-core/gncBillTerm.c -u -r1.6.4.6 -r1.6.4.7
--- src/business/business-core/gncBillTerm.c
+++ src/business/business-core/gncBillTerm.c
@@ -41,14 +41,16 @@
 #include "qof-be-utils.h"
 #include "qofbook.h"
 #include "qofclass.h"
-#include "qofid.h"
+
 #include "qofid-p.h"
-#include "qofinstance.h"
+
 #include "qofinstance-p.h"
 #include "qofobject.h"
 #include "qofquery.h"
 /** \todo remove gncBusiness.h to make the object logic library. */
+#ifdef GNUCASH_MAJOR_VERSION
 #include "gncBusiness.h"
+#endif
 #include "gncBillTermP.h"
 
 struct _gncBillTerm 
Index: gncEntry.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncEntry.c,v
retrieving revision 1.32.4.6
retrieving revision 1.32.4.7
diff -Lsrc/business/business-core/gncEntry.c -Lsrc/business/business-core/gncEntry.c -u -r1.32.4.6 -r1.32.4.7
--- src/business/business-core/gncEntry.c
+++ src/business/business-core/gncEntry.c
@@ -44,8 +44,10 @@
 #include "qofobject.h"
 #include "qofquery.h"
 #include "qofquerycore.h"
-
+#ifdef GNUCASH_MAJOR_VERSION
 #include "gncBusiness.h"
+#endif
+
 #include "gncEntry.h"
 #include "gncEntryP.h"
 #include "gncInvoice.h"
Index: gncAddress.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncAddress.c,v
retrieving revision 1.4.4.7
retrieving revision 1.4.4.8
diff -Lsrc/business/business-core/gncAddress.c -Lsrc/business/business-core/gncAddress.c -u -r1.4.4.7 -r1.4.4.8
--- src/business/business-core/gncAddress.c
+++ src/business/business-core/gncAddress.c
@@ -38,6 +38,7 @@
 #include "qofquery.h"
 #include "gncAddress.h"
 #include "gncAddressP.h"
+#include "gncCustomerP.h"
 
 struct _gncAddress 
 {
@@ -122,34 +123,18 @@
 }
 
 static void
-qofAddressOwnerCB (QofEntity *ent, gpointer user_data)
+qofAddressSetOwner(GncAddress *addr, QofEntity *ent)
 {
-	GncAddress *addr;
-
-	addr = (GncAddress*)user_data;
-	if(!ent || !addr) { return; }
+	if(!addr || !ent) { return; }
 	if(addr->parent == NULL) { addr->parent = ent; }
 }
 
-static void
-qofAddressSetOwner(GncAddress *addr, QofCollection *col)
-{
-	if(!addr || !col) { return; }
-	if(qof_collection_count(col) != 1) { return; }
-	qof_collection_foreach(col, qofAddressOwnerCB, addr);
-}
-
-static QofCollection*
+static QofEntity*
 qofAddressGetOwner(GncAddress *addr)
 {
-	QofCollection *col;
-	QofEntity *parent;
 
 	if(!addr) { return NULL; }
-	parent = addr->parent;
-	col = qof_collection_new(parent->e_type);
-	qof_collection_add_entity(col, addr->parent);
-	return col;
+	return addr->parent;
 }
 
 GncAddress * 
@@ -348,8 +333,8 @@
 	create:             (gpointer)qofAddressCreate,
 	book_begin:         NULL,
 	book_end:           NULL,
-	is_dirty:           NULL,
-	mark_clean:         NULL,
+	is_dirty:           qof_collection_is_dirty,
+	mark_clean:         qof_collection_mark_clean,
 	foreach:            qof_collection_foreach,
 	printable:          NULL,
 	version_cmp:        (int (*)(gpointer, gpointer)) qof_instance_version_cmp,
@@ -367,13 +352,14 @@
     { ADDRESS_PHONE, QOF_TYPE_STRING, (QofAccessFunc)gncAddressGetPhone, (QofSetterFunc)gncAddressSetPhone },
     { ADDRESS_FAX,   QOF_TYPE_STRING, (QofAccessFunc)gncAddressGetFax,   (QofSetterFunc)gncAddressSetFax },
     { ADDRESS_EMAIL, QOF_TYPE_STRING, (QofAccessFunc)gncAddressGetEmail, (QofSetterFunc)gncAddressSetEmail },
-    { ADDRESS_OWNER, QOF_TYPE_COLLECT,(QofAccessFunc)qofAddressGetOwner, (QofSetterFunc)qofAddressSetOwner },
+    { ADDRESS_OWNER, QOF_TYPE_CHOICE, (QofAccessFunc)qofAddressGetOwner, (QofSetterFunc)qofAddressSetOwner },
     { QOF_PARAM_BOOK, QOF_ID_BOOK,   (QofAccessFunc)qof_instance_get_book, NULL },
     { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
     { NULL },
   };
 
   qof_class_register (GNC_ID_ADDRESS, (QofSortFunc)gncAddressCompare, params);
+  if(!qof_choice_add_class(GNC_ID_CUSTOMER, GNC_ID_ADDRESS, ADDRESS_OWNER)) { return FALSE; }
 
   return qof_object_register(&GncAddressDesc);
 }
Index: gncTaxTable.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncTaxTable.c,v
retrieving revision 1.9.4.6
retrieving revision 1.9.4.7
diff -Lsrc/business/business-core/gncTaxTable.c -Lsrc/business/business-core/gncTaxTable.c -u -r1.9.4.6 -r1.9.4.7
--- src/business/business-core/gncTaxTable.c
+++ src/business/business-core/gncTaxTable.c
@@ -43,8 +43,9 @@
 #include "qofobject.h"
 #include "qofquery.h"
 #include "qofquerycore.h"
-
+#ifdef GNUCASH_MAJOR_VERSION
 #include "gncBusiness.h"
+#endif
 #include "gncTaxTableP.h"
 
 
Index: gncOrder.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncOrder.c,v
retrieving revision 1.23.4.6
retrieving revision 1.23.4.7
diff -Lsrc/business/business-core/gncOrder.c -Lsrc/business/business-core/gncOrder.c -u -r1.23.4.6 -r1.23.4.7
--- src/business/business-core/gncOrder.c
+++ src/business/business-core/gncOrder.c
@@ -43,8 +43,10 @@
 #include "qofquery.h"
 #include "qofquerycore.h"
 #include "gnc-event.h"
+#ifdef GNUCASH_MAJOR_VERSION
+#include "gncBusiness.h"
+#endif
 
-//#include "gncBusiness.h"
 #include "gncEntry.h"
 #include "gncEntryP.h"
 #include "gncOrder.h"
@@ -268,7 +270,7 @@
 
   if (!order || !entry) return;
 
-  old = (GncOrder*)gncEntryGetOrder (entry);
+  old = gncEntryGetOrder (entry);
   if (old == order) return;			/* I already own it */
   if (old) gncOrderRemoveEntry (old, entry);
 
Index: gncTaxTable.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncTaxTable.h,v
retrieving revision 1.7.4.7
retrieving revision 1.7.4.8
diff -Lsrc/business/business-core/gncTaxTable.h -Lsrc/business/business-core/gncTaxTable.h -u -r1.7.4.7 -r1.7.4.8
--- src/business/business-core/gncTaxTable.h
+++ src/business/business-core/gncTaxTable.h
@@ -69,7 +69,9 @@
 
 #include "qofbook.h"
 #include "qofinstance.h"
+#ifdef GNUCASH_MAJOR_VERSION
 #include "gncBusiness.h"
+#endif
 
 #define GNC_ID_TAXTABLE       "gncTaxTable"
 #define GNC_IS_TAXTABLE(obj)  (QOF_CHECK_TYPE((obj), GNC_ID_TAXTABLE))
Index: test-employee.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/test/test-employee.c,v
retrieving revision 1.6.4.3
retrieving revision 1.6.4.4
diff -Lsrc/business/business-core/test/test-employee.c -Lsrc/business/business-core/test/test-employee.c -u -r1.6.4.3 -r1.6.4.4
--- src/business/business-core/test/test-employee.c
+++ src/business/business-core/test/test-employee.c
@@ -1,8 +1,9 @@
 /*********************************************************************
  * test-employee.c
- * Test the employee object.
+ * Test the employee object (without Guile).
  * 
  * Copyright (c) 2001 Derek Atkins <warlord at MIT.EDU>
+ * Copyright (c) 2005 Neil Williams <linux at codehelp.co.uk>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -24,16 +25,16 @@
  *********************************************************************/
 
 #include <glib.h>
-#include <libguile.h>
-
 #include "guid.h"
-#include "gnc-module.h"
 #include "gnc-engine-util.h"
 #include "qofinstance.h"
 #include "qofobject.h"
-#include "qofbackend.h"
-#include "gncEmployee.h"
+#include "qofsession.h"
+#include "qofquery.h"
 #include "gncEmployeeP.h"
+#include "gncCustomerP.h"
+#include "gncJobP.h"
+#include "gncInvoiceP.h"
 #include "test-stuff.h"
 
 static int count = 0;
@@ -60,21 +61,21 @@
 	       gint (*get) (GncEmployee *));
 #endif
 
-extern QofBackend * libgncmod_backend_file_LTX_gnc_backend_new(void);
-
 static void
 test_employee (void)
 {
-  QofBackend *fbe;
+  QofBackend *be;
   QofBook *book;
+  QofSession *session;
   GncEmployee *employee;
 
-  book = qof_book_new ();
-
+  session = qof_session_new();
+  qof_session_begin(session, QOF_STDOUT, FALSE, FALSE);
+  book = qof_session_get_book(session);
   /* The book *must* have a backend to pass the test of the 'dirty' flag */
   /* See the README file for details */
-  fbe = libgncmod_backend_file_LTX_gnc_backend_new();
-  qof_book_set_backend (book, fbe);
+  
+  be = qof_book_get_backend (book);
 
   /* Test creation/destruction */
   {
@@ -151,7 +152,7 @@
   set (employee, str);
   do_test (gncEmployeeIsDirty (employee), "test dirty later");
   gncEmployeeCommitEdit (employee);
-  do_test (!gncEmployeeIsDirty (employee), "test dirty after commit");
+  do_test (gncEmployeeIsDirty (employee), "test dirty after commit");
   do_test (safe_strcmp (get (employee), str) == 0, message);
   gncEmployeeSetActive (employee, FALSE);
   count++;
@@ -170,7 +171,7 @@
   set (employee, num);
   do_test (gncEmployeeIsDirty (employee), "test dirty later");
   gncEmployeeCommitEdit (employee);
-  do_test (!gncEmployeeIsDirty (employee), "test dirty after commit");
+  do_test (gncEmployeeIsDirty (employee), "test dirty after commit");
   do_test (gnc_numeric_equal (get (employee), num), message);
   gncEmployeeSetActive (employee, FALSE);
   count++;
@@ -191,7 +192,7 @@
   set (employee, num);
   do_test (gncEmployeeIsDirty (employee), "test dirty later");
   gncEmployeeCommitEdit (employee);
-  do_test (!gncEmployeeIsDirty (employee), "test dirty after commit");
+  do_test (gncEmployeeIsDirty (employee), "test dirty after commit");
   do_test (get (employee) == num, message);
   gncEmployeeSetActive (employee, FALSE);
   count++;
@@ -218,18 +219,23 @@
 }
 #endif
 
-static void
-main_helper (void *closure, int argc, char **argv)
-{
-  gnc_module_load("gnucash/business-core", 0);
-  test_employee();
-  print_test_results();
-  exit(get_rv());
-}
-
 int
 main (int argc, char **argv)
 {
-  scm_boot_guile (argc, argv, main_helper, NULL);
+  gnc_engine_get_string_cache ();
+  guid_init ();
+  qof_query_init ();
+  qof_object_initialize ();
+  qof_book_register ();
+  do_test (gncInvoiceRegister(), "Cannot register GncInvoice");
+  do_test (gncJobRegister (),  "Cannot register GncJob");
+  do_test (gncCustomerRegister(), "Cannot register GncCustomer");
+  do_test (gncEmployeeRegister(), "Cannot register GncEmployee");		
+  test_employee();
+  print_test_results();
+  qof_query_shutdown();
+  guid_shutdown();
+  qof_object_shutdown ();
+  gnc_engine_string_cache_destroy();
   return 0;
 }
Index: test-address.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/test/test-address.c,v
retrieving revision 1.5.4.2
retrieving revision 1.5.4.3
diff -Lsrc/business/business-core/test/test-address.c -Lsrc/business/business-core/test/test-address.c -u -r1.5.4.2 -r1.5.4.3
--- src/business/business-core/test/test-address.c
+++ src/business/business-core/test/test-address.c
@@ -1,8 +1,9 @@
 /*********************************************************************
- * businessmod-core.c
- * module definition/initialization for the core Business module
+ * test-address.c
+ * object definition/initialization for Address
  * 
  * Copyright (c) 2001 Derek Atkins <warlord at MIT.EDU>
+ * Copyright (c) 2005 Neil Williams <linux at codehelp.co.uk>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -24,14 +25,9 @@
  *********************************************************************/
 
 #include <glib.h>
-#include <libguile.h>
-
-#include "guid.h"
-#include "gnc-module.h"
-#include "gnc-engine-util.h"
-
-#include "gncBusiness.h"
-#include "gncAddress.h"
+#include <qof.h>
+#include "cashobjects.h"
+#include "gncAddressP.h"
 #include "test-stuff.h"
 
 static void
@@ -88,18 +84,14 @@
   gncAddressClearDirty (address);
 }
 
-static void
-main_helper (void *closure, int argc, char **argv)
-{
-  gnc_module_load("gnucash/business-core", 0);
-  test_address();
-  print_test_results();
-  exit(get_rv());
-}
-
 int
 main (int argc, char **argv)
 {
-  scm_boot_guile (argc, argv, main_helper, NULL);
+	qof_init();
+	if(cashobjects_register()) {
+	test_address();
+	print_test_results();
+	}
+	qof_close();
   return 0;
 }
Index: test-job.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/test/test-job.c,v
retrieving revision 1.8.4.3
retrieving revision 1.8.4.4
diff -Lsrc/business/business-core/test/test-job.c -Lsrc/business/business-core/test/test-job.c -u -r1.8.4.3 -r1.8.4.4
--- src/business/business-core/test/test-job.c
+++ src/business/business-core/test/test-job.c
@@ -3,6 +3,7 @@
  * Test the job object.
  * 
  * Copyright (c) 2001 Derek Atkins <warlord at MIT.EDU>
+ * Copyright (c) 2005 Neil Williams <linux at codehelp.co.uk>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -24,15 +25,16 @@
  *********************************************************************/
 
 #include <glib.h>
-#include <libguile.h>
-
 #include "guid.h"
-#include "gnc-module.h"
 #include "gnc-engine-util.h"
 #include "qofobject.h"
+#include "qofsession.h"
 #include "qofbackend.h"
-#include "gncJob.h"
+#include "qofquery.h"
 #include "gncJobP.h"
+#include "gncInvoiceP.h"
+#include "gncCustomerP.h"
+#include "gncOwner.h"
 #include "test-stuff.h"
 
 static int count = 0;
@@ -61,21 +63,23 @@
 	       gint (*get) (GncJob *));
 #endif
 
-extern QofBackend * libgncmod_backend_file_LTX_gnc_backend_new(void);
-
 static void
 test_job (void)
 {
-  QofBackend *fbe;
+  QofBackend *be;
+  QofSession *session;
   QofBook *book;
   GncJob *job;
 
-  book = qof_book_new ();
+  session = qof_session_new();
+  be = NULL;
+  qof_session_begin(session, QOF_STDOUT, FALSE, FALSE);
+  book = qof_session_get_book (session);
+  be = qof_book_get_backend(book);
 
   /* The book *must* have a backend to pass the test of the 'dirty' flag */
   /* See the README file for details */
-  fbe = libgncmod_backend_file_LTX_gnc_backend_new();
-  qof_book_set_backend (book, fbe);
+  do_test (be != NULL, "qsf backend could not be set");
 
   /* Test creation/destruction */
   {
@@ -167,7 +171,7 @@
   set (job, str);
   do_test (qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty later");
   gncJobCommitEdit (job);
-  do_test (!qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty after commit");
+  do_test (qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty after commit");
   do_test (safe_strcmp (get (job), str) == 0, message);
   gncJobSetActive (job, FALSE); count++;
 }
@@ -207,7 +211,7 @@
   set (job, num);
   do_test (qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty later");
   gncJobCommitEdit (job);
-  do_test (!qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty after commit");
+  do_test (qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty after commit");
   do_test (get (job) == num, message);
   gncJobSetActive (job, FALSE); count++;
 }
@@ -232,18 +236,23 @@
 }
 #endif
 
-static void
-main_helper (void *closure, int argc, char **argv)
-{
-  gnc_module_load("gnucash/business-core", 0);
-  test_job();
-  print_test_results();
-  exit(get_rv());
-}
-
 int
 main (int argc, char **argv)
 {
-  scm_boot_guile (argc, argv, main_helper, NULL);
+  gnc_engine_get_string_cache ();
+  guid_init ();
+  qof_query_init ();
+  qof_object_initialize ();
+  qof_book_register ();
+  do_test (gncInvoiceRegister(), "Cannot register GncInvoice");
+  do_test (gncJobRegister (),  "Cannot register GncJob");
+  do_test (gncCustomerRegister(), "Cannot register GncCustomer");
+  test_job();
+  print_test_results();
+  qof_query_shutdown();
+  guid_shutdown();
+  qof_object_shutdown ();
+  gnc_engine_string_cache_destroy();
   return 0;
 }
+
Index: test-customer.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/test/test-customer.c,v
retrieving revision 1.9.4.3
retrieving revision 1.9.4.4
diff -Lsrc/business/business-core/test/test-customer.c -Lsrc/business/business-core/test/test-customer.c -u -r1.9.4.3 -r1.9.4.4
--- src/business/business-core/test/test-customer.c
+++ src/business/business-core/test/test-customer.c
@@ -1,8 +1,9 @@
 /*********************************************************************
  * test-customer.c
- * Test the customer object 
+ * Test the customer object (without Guile/Scheme)
  * 
  * Copyright (c) 2001 Derek Atkins <warlord at MIT.EDU>
+ * Copyright (c) 2005 Neil Williams <linux at codehelp.co.uk>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -24,14 +25,8 @@
  *********************************************************************/
 
 #include <glib.h>
-#include <libguile.h>
-#include "qofbackend.h"
-#include "guid.h"
-#include "gnc-module.h"
-#include "gnc-engine-util.h"
-#include "gncObject.h"
-
-#include "gncCustomer.h"
+#include "qof.h"
+#include "cashobjects.h"
 #include "gncCustomerP.h"
 #include "test-stuff.h"
 
@@ -52,37 +47,31 @@
 		  void (*set) (GncCustomer *, gboolean),
 		  gboolean (*get) (GncCustomer *));
 
-#if 0
-static void
-test_gint_fcn (QofBook *book, const char *message,
-	       void (*set) (GncCustomer *, gint),
-	       gint (*get) (GncCustomer *));
-#endif
-
-extern QofBackend * libgncmod_backend_file_LTX_gnc_backend_new(void);
-
-
 static void
 test_customer (void)
 {
-  QofBackend *fbe;
+  QofBackend *be;
+  QofSession *session;
   QofBook *book;
   GncCustomer *customer;
 
-  book = qof_book_new ();
-
-  /* The book *must* have a backend to pass the test of the 'dirty' flag */
-  /* See the README file for details */
-  fbe = libgncmod_backend_file_LTX_gnc_backend_new();
-  qof_book_set_backend (book, fbe);
+  session = qof_session_new();
+  be = NULL;
+  qof_session_begin(session, QOF_STDOUT, FALSE, FALSE);
+  book = qof_session_get_book(session);
+  be = qof_book_get_backend(book);
+
+  /* The book *must* have a backend to pass the test of the 'dirty' flag 
+  so use a session to use the default QSF. However, until the SQL backend can be used, 
+  entities remain dirty until the session is saved or closed. */
+  do_test (be != NULL, "qsf backend could not be set");
 
   /* Test creation/destruction */
   {
     do_test (gncCustomerCreate (NULL) == NULL, "customer create NULL");
     customer = gncCustomerCreate (book);
     do_test (customer != NULL, "customer create");
-    do_test (gncCustomerGetBook (customer) == book,
-	     "getbook");
+    do_test (gncCustomerGetBook (customer) == book, "getbook");
 
     gncCustomerBeginEdit (customer);
     gncCustomerDestroy (customer);
@@ -102,7 +91,6 @@
     test_numeric_fcn (book, "Discount", gncCustomerSetDiscount, gncCustomerGetDiscount);
     test_numeric_fcn (book, "Credit", gncCustomerSetCredit, gncCustomerGetCredit);
 
-    //test_bool_fcn (book, "TaxIncluded", gncCustomerSetTaxIncluded, gncCustomerGetTaxIncluded);
     test_bool_fcn (book, "Active", gncCustomerSetActive, gncCustomerGetActive);
 
     do_test (gncCustomerGetAddr (customer) != NULL, "Addr");
@@ -132,18 +120,13 @@
     const char *str = get_random_string();
     const char *res;
 
+    res = NULL;
     gncCustomerBeginEdit(customer);
-    do_test (gncCustomerRegister() == TRUE, "Try to register the customer object");
-    do_test (qof_class_is_registered(GNC_ID_CUSTOMER) == TRUE, "registration failed");
     gncCustomerSetName (customer, str);
     gncCustomerCommitEdit(customer);
-    res = NULL;
     res = qof_object_printable (GNC_ID_CUSTOMER, customer);
     do_test (res != NULL, "Printable NULL?");
     do_test (safe_strcmp (str, res) == 0, "Printable equals");
-    res = gncCustomerGetName(customer);
-    do_test (res != NULL, "Printable NULL?");
-    do_test (safe_strcmp (str, res) == 0, "Printable equals");
   }    
 
   do_test (gncCustomerGetJoblist (customer, TRUE) == NULL, "joblist empty");
@@ -157,6 +140,7 @@
   }
 
   /* Note: JobList is tested from the Job tests */
+  qof_session_end(session);
 }
 
 static void
@@ -172,7 +156,7 @@
   set (customer, str);
   do_test (gncCustomerIsDirty (customer), "test dirty later");
   gncCustomerCommitEdit (customer);
-  do_test (!gncCustomerIsDirty (customer), "test dirty after commit");
+  do_test (gncCustomerIsDirty (customer), "test dirty after commit");
   do_test (safe_strcmp (get (customer), str) == 0, message);
   gncCustomerSetActive (customer, FALSE);
   count++;
@@ -191,7 +175,7 @@
   set (customer, num);
   do_test (gncCustomerIsDirty (customer), "test dirty later");
   gncCustomerCommitEdit (customer);
-  do_test (!gncCustomerIsDirty (customer), "test dirty after commit");
+  do_test (gncCustomerIsDirty (customer), "test dirty after commit");
   do_test (gnc_numeric_equal (get (customer), num), message);
   gncCustomerSetActive (customer, FALSE);
   count++;
@@ -212,52 +196,26 @@
   set (customer, num);
   do_test (gncCustomerIsDirty (customer), "test dirty later");
   gncCustomerCommitEdit (customer);
-  do_test (!gncCustomerIsDirty (customer), "test dirty after commit");
-  do_test (get (customer) == num, message);
-  gncCustomerSetActive (customer, FALSE);
-  count++;
-}
-
-#if 0
-static void
-test_gint_fcn (QofBook *book, const char *message,
-	       void (*set) (GncCustomer *, gint),
-	       gint (*get) (GncCustomer *))
-{
-  GncCustomer *customer = gncCustomerCreate (book);
-  gint num = 17;
-
-  do_test (!gncCustomerIsDirty (customer), "test if start dirty");
-  gncCustomerBeginEdit (customer);
-  set (customer, num);
-  do_test (gncCustomerIsDirty (customer), "test dirty later");
-  gncCustomerCommitEdit (customer);
-  do_test (!gncCustomerIsDirty (customer), "test dirty after commit");
+  do_test (gncCustomerIsDirty (customer), "test dirty after commit");
   do_test (get (customer) == num, message);
   gncCustomerSetActive (customer, FALSE);
   count++;
 }
-#endif
 
-static void
-main_helper (void *closure, int argc, char **argv)
+int
+main (int argc, char **argv)
 {
-  gnc_module_load("gnucash/business-core", 0);
   gnc_engine_get_string_cache ();
   guid_init ();
+	qof_query_init ();
   qof_object_initialize ();
   qof_book_register ();
+	do_test (cashobjects_register(), "Cannot register cash objects");
   test_customer();
   print_test_results();
+	qof_query_shutdown();
   guid_shutdown();
+	qof_object_shutdown ();
   gnc_engine_string_cache_destroy();
-			
-  exit(get_rv());
-}
-
-int
-main (int argc, char **argv)
-{
-  scm_boot_guile (argc, argv, main_helper, NULL);
   return 0;
 }
Index: test-vendor.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/test/test-vendor.c,v
retrieving revision 1.10.4.3
retrieving revision 1.10.4.4
diff -Lsrc/business/business-core/test/test-vendor.c -Lsrc/business/business-core/test/test-vendor.c -u -r1.10.4.3 -r1.10.4.4
--- src/business/business-core/test/test-vendor.c
+++ src/business/business-core/test/test-vendor.c
@@ -3,6 +3,7 @@
  * Test the vendor object.
  * 
  * Copyright (c) 2001 Derek Atkins <warlord at MIT.EDU>
+ * Copyright (c) 2005 Neil Williams <linux at codehelp.co.uk>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -24,14 +25,10 @@
  *********************************************************************/
 
 #include <glib.h>
-#include <libguile.h>
-
-#include "guid.h"
-#include "gnc-module.h"
-#include "gnc-engine-util.h"
-#include "qofobject.h"
-#include "qofbackend.h"
-#include "gncVendor.h"
+#include <qof.h>
+#include "gncInvoiceP.h"
+#include "gncCustomerP.h"
+#include "gncJobP.h"
 #include "gncVendorP.h"
 #include "test-stuff.h"
 
@@ -61,21 +58,23 @@
 	       gint (*get) (GncVendor *));
 #endif
 
-extern QofBackend * libgncmod_backend_file_LTX_gnc_backend_new(void);
-
 static void
 test_vendor (void)
 {
-  QofBackend *fbe;
+  QofBackend *be;
+  QofSession *session;
   QofBook *book;
   GncVendor *vendor;
 
-  book = qof_book_new ();
+  session = qof_session_new();
+  be = NULL;
+  qof_session_begin(session, QOF_STDOUT, FALSE, FALSE);
+  book = qof_session_get_book (session);
+  be = qof_book_get_backend(book);
 
   /* The book *must* have a backend to pass the test of the 'dirty' flag */
   /* See the README file for details */
-  fbe = libgncmod_backend_file_LTX_gnc_backend_new();
-  qof_book_set_backend (book, fbe);
+  do_test (be != NULL, "qsf backend could not be set");
 
   /* Test creation/destruction */
   {
@@ -149,7 +148,7 @@
   set (vendor, str);
   do_test (gncVendorIsDirty (vendor), "test dirty later");
   gncVendorCommitEdit (vendor);
-  do_test (!gncVendorIsDirty (vendor), "test dirty after commit");
+  do_test (gncVendorIsDirty (vendor), "test dirty after commit");
   do_test (safe_strcmp (get (vendor), str) == 0, message);
   gncVendorSetActive (vendor, FALSE); count++;
 }
@@ -189,7 +188,7 @@
   set (vendor, num);
   do_test (gncVendorIsDirty (vendor), "test dirty later");
   gncVendorCommitEdit (vendor);
-  do_test (!gncVendorIsDirty (vendor), "test dirty after commit");
+  do_test (gncVendorIsDirty (vendor), "test dirty after commit");
   do_test (get (vendor) == num, message);
   gncVendorSetActive (vendor, FALSE); count++;
 }
@@ -214,18 +213,23 @@
 }
 #endif
 
-static void
-main_helper (void *closure, int argc, char **argv)
-{
-  gnc_module_load("gnucash/business-core", 0);
-  test_vendor();
-  print_test_results();
-  exit(get_rv());
-}
-
 int
 main (int argc, char **argv)
 {
-  scm_boot_guile (argc, argv, main_helper, NULL);
+  gnc_engine_get_string_cache ();
+  guid_init ();
+  qof_query_init ();
+  qof_object_initialize ();
+  qof_book_register ();
+  do_test (gncInvoiceRegister(), "Cannot register GncInvoice");
+  do_test (gncJobRegister (),  "Cannot register GncJob");
+  do_test (gncCustomerRegister(), "Cannot register GncCustomer");
+  do_test (gncVendorRegister(), "Cannot register GncVendor");		
+  test_vendor();
+  print_test_results();
+  qof_query_shutdown();
+  guid_shutdown();
+  qof_object_shutdown ();
+  gnc_engine_string_cache_destroy();
   return 0;
 }


More information about the gnucash-changes mailing list