r19129 - gnucash/trunk/src/business - Return only bills when searching for bills, return only invoices when searching for invoices and return only vouchers when searching for vouchers

Geert Janssens gjanssens at code.gnucash.org
Thu May 6 11:15:36 EDT 2010


Author: gjanssens
Date: 2010-05-06 11:15:36 -0400 (Thu, 06 May 2010)
New Revision: 19129
Trac: http://svn.gnucash.org/trac/changeset/19129

Modified:
   gnucash/trunk/src/business/business-core/gncInvoice.c
   gnucash/trunk/src/business/business-core/gncInvoice.h
   gnucash/trunk/src/business/business-gnome/dialog-invoice.c
Log:
Return only bills when searching for bills, return only invoices when searching for invoices and  return only vouchers when searching for vouchers

Modified: gnucash/trunk/src/business/business-core/gncInvoice.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncInvoice.c	2010-05-06 12:00:03 UTC (rev 19128)
+++ gnucash/trunk/src/business/business-core/gncInvoice.c	2010-05-06 15:15:36 UTC (rev 19129)
@@ -845,11 +845,9 @@
     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,8 +858,15 @@
     default:
         return NULL;
     }
+
 }
 
+const char * gncInvoiceGetType (GncInvoice *invoice)
+{
+    if (!invoice) return NULL;
+    return gncInvoiceGetTypeFromOwnerType (gncInvoiceGetOwnerType (invoice));
+}
+
 gnc_commodity * gncInvoiceGetCurrency (const GncInvoice *invoice)
 {
     if (!invoice) return NULL;

Modified: gnucash/trunk/src/business/business-core/gncInvoice.h
===================================================================
--- gnucash/trunk/src/business/business-core/gncInvoice.h	2010-05-06 12:00:03 UTC (rev 19128)
+++ gnucash/trunk/src/business/business-core/gncInvoice.h	2010-05-06 15:15:36 UTC (rev 19129)
@@ -112,6 +112,7 @@
 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);

Modified: gnucash/trunk/src/business/business-gnome/dialog-invoice.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-invoice.c	2010-05-06 12:00:03 UTC (rev 19128)
+++ gnucash/trunk/src/business/business-gnome/dialog-invoice.c	2010-05-06 15:15:36 UTC (rev 19129)
@@ -2552,8 +2552,9 @@
             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 @@
             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



More information about the gnucash-changes mailing list