r19442 - gnucash/trunk/src - Bug #625193: Move newly introduced search-by-id functions into src/engine.
Christian Stimming
cstim at code.gnucash.org
Tue Aug 17 15:52:24 EDT 2010
Author: cstim
Date: 2010-08-17 15:52:24 -0400 (Tue, 17 Aug 2010)
New Revision: 19442
Trac: http://svn.gnucash.org/trac/changeset/19442
Added:
gnucash/trunk/src/engine/gncIDSearch.c
gnucash/trunk/src/engine/gncIDSearch.h
Removed:
gnucash/trunk/src/optional/python-bindings/utils.c
gnucash/trunk/src/optional/python-bindings/utils.h
Modified:
gnucash/trunk/src/engine/Makefile.am
gnucash/trunk/src/optional/python-bindings/Makefile.am
gnucash/trunk/src/optional/python-bindings/gnucash_core.i
Log:
Bug #625193: Move newly introduced search-by-id functions into src/engine.
Patch by Mike Evans.
Modified: gnucash/trunk/src/engine/Makefile.am
===================================================================
--- gnucash/trunk/src/engine/Makefile.am 2010-08-17 19:50:13 UTC (rev 19441)
+++ gnucash/trunk/src/engine/Makefile.am 2010-08-17 19:52:24 UTC (rev 19442)
@@ -55,6 +55,7 @@
gncOrder.c \
gncOwner.c \
gncTaxTable.c \
+ gncIDSearch.c \
gncVendor.c
EXTRA_libgncmod_engine_la_SOURCES = iso-4217-currencies.c
Copied: gnucash/trunk/src/engine/gncIDSearch.c (from rev 19441, gnucash/trunk/src/optional/python-bindings/utils.c)
===================================================================
--- gnucash/trunk/src/engine/gncIDSearch.c (rev 0)
+++ gnucash/trunk/src/engine/gncIDSearch.c 2010-08-17 19:52:24 UTC (rev 19442)
@@ -0,0 +1,179 @@
+/** utils.c
+*
+* 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, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+* MA 02110-1301, USA.
+*
+* Developed (aka copied?) from code written by Sebastian Held <sebastian.held at gmx.de>
+* as part of his GnuCash invoice importer module
+* Mike Evans <mikee at saxicola.co.uk>
+*
+**********************************************************************/
+
+#include "gncIDSearch.h"
+
+
+/***********************************************************************
+ * Search the book for a Customer with the same ID. If it exists return a
+ * Customer object, if nit then return NULL.
+ @param QofBook The book
+ @param gchar ID of the Customer
+ @return GncCustomer * Pointer to the customer or NULL of there is no customer
+ *
+ **********************************************************************/
+GncCustomer *
+search_customer_on_id (QofBook * book, const gchar *id)
+{
+ QueryNew *q;
+ GNCIdType type = GNC_CUSTOMER_MODULE_NAME;
+ GList *result; // do not free this!
+ QueryPredData_t string_pred_data;
+ GncCustomer *customer = NULL;
+ gint len;
+
+ g_return_val_if_fail (id, NULL);
+ g_return_val_if_fail (book, NULL);
+
+ // Build the query
+ q = gncQueryCreateFor (type);
+ gncQuerySetBook (q, book);
+
+ // Search only the customer id field
+ string_pred_data = gncQueryStringPredicate (COMPARE_EQUAL, id, STRING_MATCH_NORMAL, FALSE);
+ gncQueryAddTerm (q, gncQueryBuildParamList(CUSTOMER_ID), string_pred_data, QUERY_AND);
+
+ // Run the query
+ result = gncQueryRun (q);
+
+ // now compare _exactly_
+ len = g_list_length (result);
+ if (result && (len>0)) {
+ result = g_list_first (result);
+ while (result) {
+ GncCustomer *c = result->data;
+ if (strcmp(id,gncCustomerGetID(c)) == 0) {
+ // correct id found
+ customer = c;
+ break;
+ }
+ result = g_list_next (result);
+ }
+ }
+
+ gncQueryDestroy (q);
+ return customer;
+}
+
+/***********************************************************************
+ * Search the book for an Invoice with the same ID. If it exists return an
+ * Invoice object, if not then return NULL.
+ @param QofBook The book
+ @param gchar ID of the invoice
+ @return GncCustomer * Pointer to the Invoice or NULL of there is no customer
+ *
+ **********************************************************************/
+GncInvoice *
+search_invoice_on_id(QofBook *book, const gchar *id)
+{
+ QueryNew *q;
+ GNCIdType type = GNC_INVOICE_MODULE_NAME;
+ GList *result; // do not free this!
+ QueryPredData_t string_pred_data;
+ GncInvoice *invoice = NULL;
+ gint len;
+
+ g_return_val_if_fail (id, NULL);
+ g_return_val_if_fail (book, NULL);
+
+ // Build the query
+ q = gncQueryCreateFor (type);
+ gncQuerySetBook (q, book);
+
+ // Search only the invoice id field
+ string_pred_data = gncQueryStringPredicate (COMPARE_EQUAL, id, STRING_MATCH_NORMAL, FALSE);
+ gncQueryAddTerm (q, gncQueryBuildParamList(INVOICE_ID), string_pred_data, QUERY_AND);
+
+ // Run the query
+ result = gncQueryRun (q);
+
+ // now compare _exactly_
+ len = g_list_length (result);
+ if (result && (len>0)) {
+ result = g_list_first (result);
+ while (result) {
+ GncInvoice *c = result->data;
+ if (strcmp(id,gncInvoiceGetID(c)) == 0) {
+ // correct id found
+ invoice = c;
+ break;
+ }
+ result = g_list_next (result);
+ }
+ }
+
+ gncQueryDestroy (q);
+ return invoice;
+}
+
+
+/***********************************************************************
+ * Search the book for a Bill with the same ID. If it exists return an
+ * Invoice object, if not then return NULL.
+ @param QofBook The book
+ @param gchar ID of the invoice
+ @return GncCustomer * Pointer to the Invoice or NULL of there is no customer
+ *
+ **********************************************************************/
+GncInvoice *
+search_bill_on_id(QofBook *book, const gchar *id)
+{
+ QueryNew *q;
+ GNCIdType type = GNC_INVOICE_MODULE_NAME;
+ GList *result; // do not free this!
+ QueryPredData_t string_pred_data;
+ GncInvoice *bill = NULL;
+ gint len;
+
+ g_return_val_if_fail (id, NULL);
+ g_return_val_if_fail (book, NULL);
+
+ // Build the query
+ q = gncQueryCreateFor (type);
+ gncQuerySetBook (q, book);
+
+ // Search only the invoice id field
+ string_pred_data = gncQueryStringPredicate (COMPARE_EQUAL, id, STRING_MATCH_NORMAL, FALSE);
+ gncQueryAddTerm (q, gncQueryBuildParamList(INVOICE_ID), string_pred_data, QUERY_AND);
+
+ // Run the query
+ result = gncQueryRun (q);
+
+ // now compare _exactly_
+ len = g_list_length (result);
+ if (result && (len>0)) {
+ result = g_list_first (result);
+ while (result) {
+ GncInvoice *c = result->data;
+ if (strcmp(id,gncInvoiceGetID(c)) == 0) {
+ // correct id found
+ bill = c;
+ break;
+ }
+ result = g_list_next (result);
+ }
+ }
+
+ gncQueryDestroy (q);
+ return bill;
+}
Property changes on: gnucash/trunk/src/engine/gncIDSearch.c
___________________________________________________________________
Added: svn:eol-style
+ LF
Copied: gnucash/trunk/src/engine/gncIDSearch.h (from rev 19441, gnucash/trunk/src/optional/python-bindings/utils.h)
===================================================================
--- gnucash/trunk/src/engine/gncIDSearch.h (rev 0)
+++ gnucash/trunk/src/engine/gncIDSearch.h 2010-08-17 19:52:24 UTC (rev 19442)
@@ -0,0 +1,47 @@
+/** utils.h
+*
+* 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, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+* MA 02110-1301, USA.
+*
+* Developed from code written by Sebastian Held <sebastian.held at gmx.de>
+* as part of his invoice importer module
+* Mike Evans <mikee at saxicola.co.uk>
+*
+**********************************************************************/
+#include "config.h"
+#include <glib/gi18n.h>
+#include <regex.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+#include "qof.h"
+//#include "gncAddressP.h"
+#include "gncCustomerP.h"
+//#include "gncCustomer.h"
+#include "gncInvoice.h"
+#include "gncBusiness.h"
+// query
+#include "QueryCore.h"
+#include "QueryNew.h"
+#include "GNCId.h"
+
+#ifndef GNC_PLUGIN_invoice_import_invoice_import_H
+#define GNC_PLUGIN_invoice_import_invoice_import_H
+
+
+GncCustomer * search_customer_on_id (QofBook *book, const gchar *id);
+GncInvoice * search_invoice_on_id (QofBook *book, const gchar *id);
+GncInvoice * search_bill_on_id (QofBook *book, const gchar *id);
+
+#endif
Property changes on: gnucash/trunk/src/engine/gncIDSearch.h
___________________________________________________________________
Added: svn:eol-style
+ LF
Modified: gnucash/trunk/src/optional/python-bindings/Makefile.am
===================================================================
--- gnucash/trunk/src/optional/python-bindings/Makefile.am 2010-08-17 19:50:13 UTC (rev 19441)
+++ gnucash/trunk/src/optional/python-bindings/Makefile.am 2010-08-17 19:52:24 UTC (rev 19442)
@@ -12,7 +12,7 @@
pkgpyexec_LTLIBRARIES = _gnucash_core_c.la
_gnucash_core_c_la_SOURCES = \
- gnucash_core.c utils.c
+ gnucash_core.c
_gnucash_core_c_la_CPPFLAGS = \
$(PYTHON_CPPFLAGS) \
Modified: gnucash/trunk/src/optional/python-bindings/gnucash_core.i
===================================================================
--- gnucash/trunk/src/optional/python-bindings/gnucash_core.i 2010-08-17 19:50:13 UTC (rev 19441)
+++ gnucash/trunk/src/optional/python-bindings/gnucash_core.i 2010-08-17 19:52:24 UTC (rev 19442)
@@ -57,7 +57,7 @@
#include "gncJob.h"
#include "gncEntry.h"
#include "gncTaxTable.h"
-#include "utils.h"
+#include "gncIDSearch.h"
%}
@@ -177,7 +177,7 @@
%include <gncJob.h>
%include <gncEntry.h>
%include <gncTaxTable.h>
-%include "utils.h"
+%include <gncIDSearch.h>
%init %{
Deleted: gnucash/trunk/src/optional/python-bindings/utils.c
===================================================================
--- gnucash/trunk/src/optional/python-bindings/utils.c 2010-08-17 19:50:13 UTC (rev 19441)
+++ gnucash/trunk/src/optional/python-bindings/utils.c 2010-08-17 19:52:24 UTC (rev 19442)
@@ -1,179 +0,0 @@
-/** utils.c
-*
-* 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, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-* MA 02110-1301, USA.
-*
-* Developed (aka copied?) from code written by Sebastian Held <sebastian.held at gmx.de>
-* as part of his GnuCash invoice importer module
-* Mike Evans <mikee at saxicola.co.uk>
-*
-**********************************************************************/
-
-#include "utils.h"
-
-
-/***********************************************************************
- * Search the book for a Customer with the same ID. If it exists return a
- * Customer object, if nit then return NULL.
- @param QofBook The book
- @param gchar ID of the Customer
- @return GncCustomer * Pointer to the customer or NULL of there is no customer
- *
- **********************************************************************/
-GncCustomer *
-search_customer_on_id (QofBook * book, const gchar *id)
-{
- QueryNew *q;
- GNCIdType type = GNC_CUSTOMER_MODULE_NAME;
- GList *result; // do not free this!
- QueryPredData_t string_pred_data;
- GncCustomer *customer = NULL;
- gint len;
-
- g_return_val_if_fail (id, NULL);
- g_return_val_if_fail (book, NULL);
-
- // Build the query
- q = gncQueryCreateFor (type);
- gncQuerySetBook (q, book);
-
- // Search only the customer id field
- string_pred_data = gncQueryStringPredicate (COMPARE_EQUAL, id, STRING_MATCH_NORMAL, FALSE);
- gncQueryAddTerm (q, gncQueryBuildParamList(CUSTOMER_ID), string_pred_data, QUERY_AND);
-
- // Run the query
- result = gncQueryRun (q);
-
- // now compare _exactly_
- len = g_list_length (result);
- if (result && (len>0)) {
- result = g_list_first (result);
- while (result) {
- GncCustomer *c = result->data;
- if (strcmp(id,gncCustomerGetID(c)) == 0) {
- // correct id found
- customer = c;
- break;
- }
- result = g_list_next (result);
- }
- }
-
- gncQueryDestroy (q);
- return customer;
-}
-
-/***********************************************************************
- * Search the book for an Invoice with the same ID. If it exists return an
- * Invoice object, if not then return NULL.
- @param QofBook The book
- @param gchar ID of the invoice
- @return GncCustomer * Pointer to the Invoice or NULL of there is no customer
- *
- **********************************************************************/
-GncInvoice *
-search_invoice_on_id(QofBook *book, const gchar *id)
-{
- QueryNew *q;
- GNCIdType type = GNC_INVOICE_MODULE_NAME;
- GList *result; // do not free this!
- QueryPredData_t string_pred_data;
- GncInvoice *invoice = NULL;
- gint len;
-
- g_return_val_if_fail (id, NULL);
- g_return_val_if_fail (book, NULL);
-
- // Build the query
- q = gncQueryCreateFor (type);
- gncQuerySetBook (q, book);
-
- // Search only the invoice id field
- string_pred_data = gncQueryStringPredicate (COMPARE_EQUAL, id, STRING_MATCH_NORMAL, FALSE);
- gncQueryAddTerm (q, gncQueryBuildParamList(INVOICE_ID), string_pred_data, QUERY_AND);
-
- // Run the query
- result = gncQueryRun (q);
-
- // now compare _exactly_
- len = g_list_length (result);
- if (result && (len>0)) {
- result = g_list_first (result);
- while (result) {
- GncInvoice *c = result->data;
- if (strcmp(id,gncInvoiceGetID(c)) == 0) {
- // correct id found
- invoice = c;
- break;
- }
- result = g_list_next (result);
- }
- }
-
- gncQueryDestroy (q);
- return invoice;
-}
-
-
-/***********************************************************************
- * Search the book for a Bill with the same ID. If it exists return an
- * Invoice object, if not then return NULL.
- @param QofBook The book
- @param gchar ID of the invoice
- @return GncCustomer * Pointer to the Invoice or NULL of there is no customer
- *
- **********************************************************************/
-GncInvoice *
-search_bill_on_id(QofBook *book, const gchar *id)
-{
- QueryNew *q;
- GNCIdType type = GNC_INVOICE_MODULE_NAME;
- GList *result; // do not free this!
- QueryPredData_t string_pred_data;
- GncInvoice *bill = NULL;
- gint len;
-
- g_return_val_if_fail (id, NULL);
- g_return_val_if_fail (book, NULL);
-
- // Build the query
- q = gncQueryCreateFor (type);
- gncQuerySetBook (q, book);
-
- // Search only the invoice id field
- string_pred_data = gncQueryStringPredicate (COMPARE_EQUAL, id, STRING_MATCH_NORMAL, FALSE);
- gncQueryAddTerm (q, gncQueryBuildParamList(INVOICE_ID), string_pred_data, QUERY_AND);
-
- // Run the query
- result = gncQueryRun (q);
-
- // now compare _exactly_
- len = g_list_length (result);
- if (result && (len>0)) {
- result = g_list_first (result);
- while (result) {
- GncInvoice *c = result->data;
- if (strcmp(id,gncInvoiceGetID(c)) == 0) {
- // correct id found
- bill = c;
- break;
- }
- result = g_list_next (result);
- }
- }
-
- gncQueryDestroy (q);
- return bill;
-}
Deleted: gnucash/trunk/src/optional/python-bindings/utils.h
===================================================================
--- gnucash/trunk/src/optional/python-bindings/utils.h 2010-08-17 19:50:13 UTC (rev 19441)
+++ gnucash/trunk/src/optional/python-bindings/utils.h 2010-08-17 19:52:24 UTC (rev 19442)
@@ -1,57 +0,0 @@
-/** utils.h
-*
-* 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, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-* MA 02110-1301, USA.
-*
-* Developed from code written by Sebastian Held <sebastian.held at gmx.de>
-* as part of his invoice importer module
-* Mike Evans <mikee at saxicola.co.uk>
-*
-**********************************************************************/
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <glib/gi18n.h>
-#include <regex.h>
-#include <glib.h>
-#include <glib/gstdio.h>
-
-#include "gnc-ui.h"
-#include "gnc-ui-util.h"
-#include "gnome-utils/gnc-gui-query.h"
-#include "gncAddress.h"
-#include "gncCustomerP.h"
-#include "gncCustomer.h"
-#include "gncInvoice.h"
-#include "gnc-exp-parser.h"
-
-// query
-#include "QueryCore.h"
-#include "QueryNew.h"
-#include "GNCId.h"
-
-
-
-#ifndef GNC_PLUGIN_invoice_import_invoice_import_H
-#define GNC_PLUGIN_invoice_import_invoice_import_H
-
-GncCustomer * search_customer_on_id (QofBook *book, const gchar *id);
-GncInvoice * search_invoice_on_id (QofBook *book, const gchar *id);
-GncInvoice * search_bill_on_id (QofBook *book, const gchar *id);
-
-#endif
More information about the gnucash-changes
mailing list