r23066 - gnucash/trunk/src - Lookup business reports by id instead of by name

Geert Janssens gjanssens at code.gnucash.org
Thu Jun 27 05:08:26 EDT 2013


Author: gjanssens
Date: 2013-06-27 05:08:25 -0400 (Thu, 27 Jun 2013)
New Revision: 23066
Trac: http://svn.gnucash.org/trac/changeset/23066

Modified:
   gnucash/trunk/src/business/business-gnome/dialog-invoice.c
   gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c
   gnucash/trunk/src/report/business-reports/business-reports.scm
Log:
Lookup business reports by id instead of by name

Modified: gnucash/trunk/src/business/business-gnome/dialog-invoice.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-invoice.c	2013-06-25 18:44:52 UTC (rev 23065)
+++ gnucash/trunk/src/business/business-gnome/dialog-invoice.c	2013-06-27 09:08:25 UTC (rev 23066)
@@ -638,9 +638,9 @@
 
     g_return_if_fail (invoice);
     if (!reportname)
-        reportname = "Printable Invoice"; // fallback if the option lookup failed
+        reportname = "5123a759ceb9483abf2182d01c140e8d"; // fallback if the option lookup failed
 
-    func = scm_c_eval_string ("gnc:invoice-report-create-withname");
+    func = scm_c_eval_string ("gnc:invoice-report-create");
     g_return_if_fail (scm_is_procedure (func));
 
     arg = SWIG_NewPointerObj(invoice, SWIG_TypeQuery("_p__gncInvoice"), 0);

Modified: gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c	2013-06-25 18:44:52 UTC (rev 23065)
+++ gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c	2013-06-27 09:08:25 UTC (rev 23066)
@@ -1101,12 +1101,15 @@
 
 static const char* invoice_printreport_values[] =
 {
-    // FIXME: You must manually keep this list in sync with the one at the end
-    // of business-prefs.glade
-    "Printable Invoice",
-    "Tax Invoice",
-    "Easy Invoice",
-    "Fancy Invoice",
+    /* The list below are the guids of reports that can
+     * be used to print an invoice.
+     * Important: this list must be kept in sync with the one at the end
+     * of business-prefs.glade
+     */
+    "5123a759ceb9483abf2182d01c140e8d", // "Printable Invoice"
+    "0769e242be474010b4acf264a5512e6e", // "Tax Invoice"
+    "67112f318bef4fc496bdc27d106bbda4", // "Easy Invoice"
+    "3ce293441e894423a2425d7a22dd1ac6", // "Fancy Invoice"
     NULL
 };
 

Modified: gnucash/trunk/src/report/business-reports/business-reports.scm
===================================================================
--- gnucash/trunk/src/report/business-reports/business-reports.scm	2013-06-25 18:44:52 UTC (rev 23065)
+++ gnucash/trunk/src/report/business-reports/business-reports.scm	2013-06-27 09:08:25 UTC (rev 23066)
@@ -105,15 +105,10 @@
 	ref)))
 
 ;; Creates a new report instance for the given invoice. The given
-;; report name must be the name of one existing report template, which
+;; report-template-id must refer to an existing report template, which
 ;; is then used to instantiate the new report instance.
-(define (gnc:invoice-report-create-withname invoice report-name)
-  ;; Look up the internal template-id that belongs to the given report
-  ;; name
-  (let ((report-template-id
-         (gnc:report-template-name-to-id report-name)))
-
-    (if report-template-id
+(define (gnc:invoice-report-create invoice report-template-id)
+    (if (gnc:find-report-template report-template-id)
         ;; We found the report template id, so instantiate a report
         ;; and set the invoice option accordingly.
         (let* ((options (gnc:make-report-options report-template-id))
@@ -121,12 +116,10 @@
 
           (gnc:option-set-value invoice-op invoice)
           (gnc:make-report report-template-id options))
-        ;; No report template id was found (probably the name has a
-        ;; typo), so let's return zero as an invalid report id.
+        ;; Invalid report-template-id, so let's return zero as an invalid report id.
         0
-        )))
+        ))
 
-(export gnc:invoice-report-create-withname)
 (export gnc:menuname-business-reports gnc:optname-invoice-number)
 
 (use-modules (gnucash report fancy-invoice))
@@ -140,17 +133,6 @@
 (use-modules (gnucash report customer-summary))
 (use-modules (gnucash report balsheet-eg))
 
-(define (gnc:invoice-report-create invoice)
-  (gnc:invoice-report-create-withname
-   invoice
-   ;; Feel free to insert a different invoice report name below, such
-   ;; as "Tax Invoice"
-   "Printable Invoice"))
-
-;; Alternatively, if your preferred report has a "create-internal"
-;; function, uncomment the line below and delete the ones above
-;;(define gnc:invoice-report-create gnc:invoice-report-create-internal)
-
 (define (gnc:payables-report-create account title show-zeros?)
   (payables-report-create-internal account title show-zeros?))
 



More information about the gnucash-changes mailing list