r19983 - gnucash/trunk/src/gnome-utils - Improve GncEntry quickfill to create separate quickfills for invoices and bills

Christian Stimming cstim at code.gnucash.org
Mon Dec 27 16:07:58 EST 2010


Author: cstim
Date: 2010-12-27 16:07:58 -0500 (Mon, 27 Dec 2010)
New Revision: 19983
Trac: http://svn.gnucash.org/trac/changeset/19983

Modified:
   gnucash/trunk/src/gnome-utils/gnc-entry-quickfill.c
   gnucash/trunk/src/gnome-utils/gnc-entry-quickfill.h
Log:
Improve GncEntry quickfill to create separate quickfills for invoices and bills

Modified: gnucash/trunk/src/gnome-utils/gnc-entry-quickfill.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-entry-quickfill.c	2010-12-27 20:19:19 UTC (rev 19982)
+++ gnucash/trunk/src/gnome-utils/gnc-entry-quickfill.c	2010-12-27 21:07:58 UTC (rev 19983)
@@ -34,6 +34,7 @@
     QuickFillSort qf_sort;
     QofBook *book;
     gint  listener;
+    gboolean using_invoices;
 } EntryQF;
 
 static void
@@ -91,7 +92,12 @@
 {
     const GncEntry* entry = data;
     EntryQF *s = (EntryQF *) user_data;
-    gnc_quickfill_insert (s->qf, gncEntryGetDescription(entry), s->qf_sort);
+    if (s->using_invoices == (gncEntryGetInvAccount(entry) != NULL))
+    {
+        gnc_quickfill_insert (s->qf,
+                              gncEntryGetDescription(entry),
+                              s->qf_sort);
+    }
 }
 
 /** Creates a new query that searches for all GncEntry items in the
@@ -104,7 +110,7 @@
     return query;
 }
 
-static EntryQF* build_shared_quickfill (QofBook *book, const char * key)
+static EntryQF* build_shared_quickfill (QofBook *book, const char * key, gboolean use_invoices)
 {
     EntryQF *result;
     QofQuery *query = new_query_for_entrys(book);
@@ -114,6 +120,7 @@
 
     result = g_new0(EntryQF, 1);
 
+    result->using_invoices = use_invoices;
     result->qf = gnc_quickfill_new();
     result->qf_sort = QUICKFILL_LIFO;
     result->book = book;
@@ -132,7 +139,7 @@
 }
 
 QuickFill * gnc_get_shared_entry_desc_quickfill (QofBook *book,
-        const char * key)
+        const char * key, gboolean use_invoices)
 {
     EntryQF *qfb;
 
@@ -142,8 +149,11 @@
     qfb = qof_book_get_data (book, key);
 
     if (qfb)
+    {
+        g_assert(use_invoices == qfb->using_invoices);
         return qfb->qf;
+    }
 
-    qfb = build_shared_quickfill(book, key);
+    qfb = build_shared_quickfill(book, key, use_invoices);
     return qfb->qf;
 }

Modified: gnucash/trunk/src/gnome-utils/gnc-entry-quickfill.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-entry-quickfill.h	2010-12-27 20:19:19 UTC (rev 19982)
+++ gnucash/trunk/src/gnome-utils/gnc-entry-quickfill.h	2010-12-27 21:07:58 UTC (rev 19983)
@@ -45,9 +45,22 @@
  *  listens to the entry's deletion events and removes those
  *  descriptions from the quickfill; however, this does not yet seem
  *  to fully remove them from the GUI.
+ *
+ * \param book The book
+ * \param key The identifier to look up the shared object in the book
+ *
+ * \param use_invoices If TRUE, this quickfill considers only the
+ * entries from GncInvoice objects. If FALSE, this quickfill considers
+ * only the entries from bills/expense vouchers. Watch out: This
+ * parameter must be identical each time the same key is used for
+ * lookup, or otherwise an assertion will fail.
+ *
+ * \return The shared QuickFill object which is created on first
+ * calling of this function and subsequently looked up in the book by
+ * using the key.
  */
 QuickFill * gnc_get_shared_entry_desc_quickfill (QofBook *book,
-        const char * key);
+        const char * key, gboolean use_invoices);
 
 #endif
 



More information about the gnucash-changes mailing list