24 #include "gncIDSearch.h" 35 static void * search(QofBook * book,
const gchar *
id,
void *
object, GncSearchType type);
47 gnc_search_customer_on_id (QofBook * book,
const gchar *
id)
50 GncSearchType type = CUSTOMER;
51 customer = (
GncCustomer*)search(book,
id, customer, type);
56 gnc_search_invoice_on_id (QofBook * book,
const gchar *
id)
58 GncInvoice *invoice = NULL;
59 GncSearchType type = INVOICE;
60 invoice = (GncInvoice*)search(book,
id, invoice, type);
66 gnc_search_bill_on_id (QofBook * book,
const gchar *
id)
68 GncInvoice *bill = NULL;
69 GncSearchType type = BILL;
70 bill = (GncInvoice*)search(book,
id, bill, type);
75 gnc_search_vendor_on_id (QofBook * book,
const gchar *
id)
77 GncVendor *vendor = NULL;
78 GncSearchType type = VENDOR;
79 vendor = (GncVendor*)search(book,
id, vendor, type);
88 static void * search(QofBook * book,
const gchar *
id,
void *
object, GncSearchType type)
93 QofQueryPredData* string_pred_data;
95 PINFO(
"Type = %d", type);
96 g_return_val_if_fail (type, NULL);
97 g_return_val_if_fail (
id, NULL);
98 g_return_val_if_fail (book, NULL);
104 string_pred_data = qof_query_string_predicate (QOF_COMPARE_EQUAL,
id, QOF_STRING_MATCH_NORMAL, FALSE);
105 if (type == CUSTOMER)
108 qof_query_add_term (q, qof_query_build_param_list(
"CUSTOMER_ID"), string_pred_data, QOF_QUERY_AND);
110 else if (type == INVOICE || type == BILL)
113 qof_query_add_term (q, qof_query_build_param_list(
"INVOICE_ID"), string_pred_data, QOF_QUERY_AND);
115 else if (type == VENDOR)
118 qof_query_add_term (q, qof_query_build_param_list(
"VENDOR_ID"), string_pred_data, QOF_QUERY_AND);
128 result = g_list_first (result);
134 if (type == CUSTOMER && strcmp(
id, gncCustomerGetID(c)) == 0)
140 else if (type == INVOICE && strcmp(
id, gncInvoiceGetID(c)) == 0
141 && gncInvoiceGetType(c) == GNC_INVOICE_CUST_INVOICE)
146 else if (type == BILL && strcmp(
id, gncInvoiceGetID(c)) == 0
147 && gncInvoiceGetType(c) == GNC_INVOICE_VEND_INVOICE)
152 else if (type == VENDOR && strcmp(
id, gncVendorGetID(c)) == 0)
157 result = g_list_next (result);
void qof_query_add_term(QofQuery *q, QofQueryParamList *param_list, QofQueryPredData *pred_data, QofQueryOp op)
This is the general function that adds a new Query Term to a query.
#define G_LOG_DOMAIN
Functions providing the SX List as a plugin page.
#define PINFO(format, args...)
Print an informational note.
void qof_query_destroy(QofQuery *query)
Frees the resources associate with a Query object.
void qof_query_set_book(QofQuery *query, QofBook *book)
Set the book to be searched.
credit, discount and shipaddr are unique to GncCustomer id, name, notes, terms, addr, currency, taxtable, taxtable_override taxincluded, active and jobs are identical to ::GncVendor.
GList * qof_query_run(QofQuery *query)
Perform the query, return the results.
gint gnc_list_length_cmp(const GList *list, size_t len)
Scans the GList elements the minimum number of iterations required to test it against a specified siz...
QofQuery * qof_query_create(void)
Create a new query.
void qof_query_search_for(QofQuery *q, QofIdTypeConst obj_type)
Set the object type to be searched for.