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
This commit is contained in:
Geert Janssens 2010-05-06 15:15:36 +00:00
parent 6afded02b0
commit 1c2f75c160
3 changed files with 23 additions and 6 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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