From 1c2f75c160f1471852efae39eb4ec3324e6e75ef Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Thu, 6 May 2010 15:15:36 +0000 Subject: [PATCH] Return only bills when searching for bills, return only invoices when searching for invoices and return only vouchers when searching for vouchers git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19129 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/business/business-core/gncInvoice.c | 13 +++++++++---- src/business/business-core/gncInvoice.h | 1 + src/business/business-gnome/dialog-invoice.c | 15 +++++++++++++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/business/business-core/gncInvoice.c b/src/business/business-core/gncInvoice.c index b071a7b56f..a6dda6d780 100644 --- a/src/business/business-core/gncInvoice.c +++ b/src/business/business-core/gncInvoice.c @@ -845,11 +845,9 @@ gnc_numeric gncInvoiceGetTotalOf (GncInvoice *invoice, GncEntryPaymentType type) return gncInvoiceGetTotalInternal(invoice, TRUE, TRUE, TRUE, type); } -const char * gncInvoiceGetType (GncInvoice *invoice) +const char * gncInvoiceGetTypeFromOwnerType (GncOwnerType type) { - if (!invoice) return NULL; - - switch (gncInvoiceGetOwnerType (invoice)) + switch (type) { case GNC_OWNER_CUSTOMER: return _("Invoice"); @@ -860,6 +858,13 @@ const char * gncInvoiceGetType (GncInvoice *invoice) default: return NULL; } + +} + +const char * gncInvoiceGetType (GncInvoice *invoice) +{ + if (!invoice) return NULL; + return gncInvoiceGetTypeFromOwnerType (gncInvoiceGetOwnerType (invoice)); } gnc_commodity * gncInvoiceGetCurrency (const GncInvoice *invoice) diff --git a/src/business/business-core/gncInvoice.h b/src/business/business-core/gncInvoice.h index db4c311d7b..f6fddccdb7 100644 --- a/src/business/business-core/gncInvoice.h +++ b/src/business/business-core/gncInvoice.h @@ -112,6 +112,7 @@ GncBillTerm * gncInvoiceGetTerms (const GncInvoice *invoice); const char * gncInvoiceGetBillingID (const GncInvoice *invoice); const char * gncInvoiceGetNotes (const GncInvoice *invoice); GncOwnerType gncInvoiceGetOwnerType (GncInvoice *invoice); +const char * gncInvoiceGetTypeFromOwnerType (GncOwnerType type); const char * gncInvoiceGetType (GncInvoice *invoice); gnc_commodity * gncInvoiceGetCurrency (const GncInvoice *invoice); GncOwner * gncInvoiceGetBillTo (GncInvoice *invoice); diff --git a/src/business/business-gnome/dialog-invoice.c b/src/business/business-gnome/dialog-invoice.c index e8ccdf788f..128f735bc1 100644 --- a/src/business/business-gnome/dialog-invoice.c +++ b/src/business/business-gnome/dialog-invoice.c @@ -2552,8 +2552,9 @@ gnc_invoice_search (GncInvoice *start, GncOwner *owner, QofBook *book) owner_type = gncOwnerGetType(tmp); } - /* Then if there's an actual owner (and not just a type) - * then add it to the query and limit the search to this owner + /* Then if there's an actual owner add it to the query + * and limit the search to this owner + * If there's only a type, limit the search to this type. */ if (gncOwnerGetGUID (owner)) { @@ -2572,6 +2573,16 @@ gnc_invoice_search (GncInvoice *start, GncOwner *owner, QofBook *book) gncQueryDestroy (q2); q2 = gncQueryCopy (q); } + else + { + QofQueryPredData *inv_type_pred; + GSList *param_list=NULL; + inv_type_pred = qof_query_string_predicate(QOF_COMPARE_EQUAL, + gncInvoiceGetTypeFromOwnerType(owner_type), + QOF_STRING_MATCH_NORMAL, FALSE); + param_list = g_slist_prepend (param_list, INVOICE_TYPE); + gncQueryAddTerm (q, param_list, inv_type_pred, QOF_QUERY_AND); + } } #if 0