mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Prepare invoice search to handle both invoices and credit notes
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21404 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
1afcc0969d
commit
fa2338deb1
@ -2703,33 +2703,36 @@ gnc_invoice_search (GncInvoice *start, GncOwner *owner, QofBook *book)
|
||||
(g_slist_prepend (NULL, OWNER_PARENTG),
|
||||
INVOICE_OWNER),
|
||||
gncOwnerGetGUID (owner), QOF_QUERY_OR);
|
||||
|
||||
qof_query_merge_in_place (q, q2, QOF_QUERY_AND);
|
||||
qof_query_destroy (q2);
|
||||
|
||||
/* Use this base query as pre-fill query.
|
||||
* This will pre-fill the search dialog with the query results
|
||||
*/
|
||||
q2 = qof_query_copy (q);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
QofQueryPredData *inv_type_pred;
|
||||
GSList *param_list = NULL;
|
||||
inv_type_pred = qof_query_int32_predicate(QOF_COMPARE_EQUAL,
|
||||
gncInvoiceGetTypeListForOwnerType(owner_type));
|
||||
param_list = g_slist_prepend (param_list, INVOICE_TYPE);
|
||||
qof_query_add_term (q, param_list, inv_type_pred, QOF_QUERY_AND);
|
||||
QofQuery *q3 = qof_query_create ();
|
||||
QofQueryPredData *inv_type_pred = NULL;
|
||||
GList *type_list = NULL, *node = NULL;
|
||||
|
||||
type_list = gncInvoiceGetTypeListForOwnerType(owner_type);
|
||||
for (node = type_list; node; node=node->next)
|
||||
{
|
||||
inv_type_pred = qof_query_int32_predicate(QOF_COMPARE_EQUAL,
|
||||
GPOINTER_TO_INT(node->data));
|
||||
qof_query_add_term (q3, g_slist_prepend (NULL, INVOICE_TYPE), inv_type_pred, QOF_QUERY_OR);
|
||||
}
|
||||
qof_query_merge_in_place (q, q3, QOF_QUERY_AND);
|
||||
qof_query_destroy (q3);
|
||||
|
||||
/* Don't set a pre-fill query in this case, the result set would be too long */
|
||||
q2 = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (start)
|
||||
{
|
||||
if (q2 == NULL)
|
||||
q2 = qof_query_copy (q);
|
||||
|
||||
qof_query_add_guid_match (q2, g_slist_prepend (NULL, QOF_PARAM_GUID),
|
||||
gncInvoiceGetGUID (start), QOF_QUERY_AND);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Launch select dialog and return the result */
|
||||
sw = g_new0 (struct _invoice_select_window, 1);
|
||||
|
||||
|
@ -851,19 +851,25 @@ gnc_numeric gncInvoiceGetTotalOf (GncInvoice *invoice, GncEntryPaymentType type)
|
||||
return gncInvoiceGetTotalInternal(invoice, TRUE, TRUE, TRUE, type);
|
||||
}
|
||||
|
||||
// FIXME this should return a list of valid invoice types for a given owner type
|
||||
GncInvoiceType gncInvoiceGetTypeListForOwnerType (GncOwnerType type)
|
||||
GList * gncInvoiceGetTypeListForOwnerType (GncOwnerType type)
|
||||
{
|
||||
GList *type_list = NULL;
|
||||
switch (type)
|
||||
{
|
||||
case GNC_OWNER_CUSTOMER:
|
||||
return GNC_INVOICE_CUST_INVOICE;
|
||||
type_list = g_list_append (type_list, GINT_TO_POINTER(GNC_INVOICE_CUST_INVOICE));
|
||||
type_list = g_list_append (type_list, GINT_TO_POINTER(GNC_INVOICE_CUST_CREDIT_NOTE));
|
||||
return type_list;
|
||||
case GNC_OWNER_VENDOR:
|
||||
return GNC_INVOICE_VEND_INVOICE;
|
||||
type_list = g_list_append (type_list, GINT_TO_POINTER(GNC_INVOICE_VEND_INVOICE));
|
||||
type_list = g_list_append (type_list, GINT_TO_POINTER(GNC_INVOICE_VEND_CREDIT_NOTE));
|
||||
return type_list;
|
||||
case GNC_OWNER_EMPLOYEE:
|
||||
return GNC_INVOICE_EMPL_INVOICE;
|
||||
type_list = g_list_append (type_list, GINT_TO_POINTER(GNC_INVOICE_EMPL_INVOICE));
|
||||
type_list = g_list_append (type_list, GINT_TO_POINTER(GNC_INVOICE_EMPL_CREDIT_NOTE));
|
||||
return type_list;
|
||||
default:
|
||||
return GNC_INVOICE_UNDEFINED;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ GncBillTerm * gncInvoiceGetTerms (const GncInvoice *invoice);
|
||||
const char * gncInvoiceGetBillingID (const GncInvoice *invoice);
|
||||
const char * gncInvoiceGetNotes (const GncInvoice *invoice);
|
||||
GncOwnerType gncInvoiceGetOwnerType (GncInvoice *invoice);
|
||||
GncInvoiceType gncInvoiceGetTypeListForOwnerType (GncOwnerType type);
|
||||
GList * gncInvoiceGetTypeListForOwnerType (GncOwnerType type);
|
||||
GncInvoiceType gncInvoiceGetType (GncInvoice *invoice);
|
||||
const char * gncInvoiceGetTypeString (GncInvoice *invoice);
|
||||
gnc_commodity * gncInvoiceGetCurrency (const GncInvoice *invoice);
|
||||
|
Loading…
Reference in New Issue
Block a user