r17764 - gnucash/trunk/src/business/business-reports - implement customizable invoice title in all three invoices

Andrew Sackville-West andrewsw at cvs.gnucash.org
Tue Dec 9 18:50:04 EST 2008


Author: andrewsw
Date: 2008-12-09 18:50:04 -0500 (Tue, 09 Dec 2008)
New Revision: 17764
Trac: http://svn.gnucash.org/trac/changeset/17764

Modified:
   gnucash/trunk/src/business/business-reports/easy-invoice.scm
   gnucash/trunk/src/business/business-reports/fancy-invoice.scm
   gnucash/trunk/src/business/business-reports/invoice.scm
Log:
implement customizable invoice title in all three invoices

where previously the user had to hand edit scheme files to change
"Invoice" to "Tax Invoice" and the like, there is now an option to
enter a custom string. This string will override the word "Invoice"
(or "Bill" and "Expense Voucher") in all locations in the report.

Modified: gnucash/trunk/src/business/business-reports/easy-invoice.scm
===================================================================
--- gnucash/trunk/src/business/business-reports/easy-invoice.scm	2008-12-08 22:57:23 UTC (rev 17763)
+++ gnucash/trunk/src/business/business-reports/easy-invoice.scm	2008-12-09 23:50:04 UTC (rev 17764)
@@ -246,6 +246,12 @@
 			    (lambda () '()) #f))
 
   (gnc:register-inv-option
+   (gnc:make-string-option 
+    invoice-page (N_ "Custom Title") 
+    "z" (N_ "A custom string to replace Invoice, Bill or Expense Voucher") 
+    ""))
+
+  (gnc:register-inv-option
    (gnc:make-simple-boolean-option
     (N_ "Display Columns") (N_ "Date")
     "b" (N_ "Display the date?") #t))
@@ -669,13 +675,21 @@
     (gnc:option-value
      (gnc:lookup-option (gnc:report-options report-obj) section name)))
 
+  (define (title-string title custom-title)
+    (if (not (equal? "" custom-title))
+	(string-expand custom-title
+		       #\space " ")
+	title))
+
   (let* ((document (gnc:make-html-document))
 	 (table '())
 	 (orders '())
 	 (invoice (opt-val invoice-page invoice-name))
 	 (owner '())
 	 (references? (opt-val "Display" "References"))
-	 (title (_ "Invoice"))
+	 (default-title (_ "Invoice"))
+	 (custom-title (opt-val invoice-page "Custom Title"))
+	 (title "")
 	 (invoice? #f))
 
     (define (add-order o)
@@ -691,10 +705,10 @@
 	      ((eqv? type GNC-OWNER-CUSTOMER)
 	       (set! invoice? #t))
 	      ((eqv? type GNC-OWNER-VENDOR)
-	       (set! title (_ "Bill")))
+	       (set! default-title (_ "Bill")))
 	      ((eqv? type GNC-OWNER-EMPLOYEE)
-	       (set! title (_ "Expense Voucher")))))
-	  (set! title (sprintf #f (_"%s #%d") title
+	       (set! default-title (_ "Expense Voucher")))))
+	  (set! title (sprintf #f (_"%s #%d") (title-string default-title custom-title)
 			       (gncInvoiceGetID invoice)))))
 
 ;    (gnc:html-document-set-title! document title)
@@ -712,8 +726,9 @@
         (add-html! document "<table width='100%'><tr>")
         (add-html! document "<td align='left'>")
         (add-html! document "<b><u>")
-	(add-html! document (sprintf #f (_ "Invoice #%d")
-				     (gncInvoiceGetID invoice)))
+	(add-html! document title)
+;;	(add-html! document (sprintf #f (_ "Invoice #%d")
+;;				     (gncInvoiceGetID invoice)))
         (add-html! document "</u></b></td>")
         (add-html! document "<td align='right'>")
 

Modified: gnucash/trunk/src/business/business-reports/fancy-invoice.scm
===================================================================
--- gnucash/trunk/src/business/business-reports/fancy-invoice.scm	2008-12-08 22:57:23 UTC (rev 17763)
+++ gnucash/trunk/src/business/business-reports/fancy-invoice.scm	2008-12-09 23:50:04 UTC (rev 17764)
@@ -253,6 +253,12 @@
 			    (lambda () '()) #f))
 
   (gnc:register-inv-option
+   (gnc:make-string-option 
+    invoice-page (N_ "Custom Title") 
+    "z" (N_ "A custom string to replace Invoice, Bill or Expense Voucher") 
+    ""))
+
+  (gnc:register-inv-option
    (gnc:make-simple-boolean-option
     (N_ "Display Columns") (N_ "Date")
     "b" (N_ "Display the date?") #f))
@@ -664,7 +670,7 @@
      'attribute (list "valign" "top"))
     table))
 
-(define (make-myname-table book date-format)
+(define (make-myname-table book date-format title)
   (let* ((table (gnc:make-html-table))
 	 (slots (gnc-book-get-slots book))
 	 (name (kvp-frame-get-slot-path-gslist
@@ -704,7 +710,7 @@
      'attribute (list "cellpadding" 0)
      'attribute (list "width" "100%"))
     (gnc:html-table-cell-append-objects!
-	invoice-cell (_"INVOICE"))
+	invoice-cell title)
     (gnc:html-table-cell-set-style!
 	invoice-cell "td"
 	'font-size "+2")
@@ -754,15 +760,23 @@
     (gnc:option-value
      (gnc:lookup-option (gnc:report-options report-obj) section name)))
 
+  (define (title-string title custom-title)
+    (if (not (equal? "" custom-title))
+	(string-expand custom-title
+		       #\space "&nbsp;")
+	title))
+
   (let* ((document (gnc:make-html-document))
 	 (table '())
 	 (orders '())
 	 (invoice (opt-val invoice-page invoice-name))
 	 (owner '())
 	 (references? (opt-val "Display" "References"))
-	 (title (_ "Invoice"))
+	 (default-title (_ "Invoice"))
+	 (custom-title (opt-val invoice-page "Custom Title"))
 	 (invoice? #f))
 
+
     (define (add-order o)
       (if (and references? (not (member o orders)))
 	  (addto! orders o)))
@@ -776,20 +790,22 @@
 	      ((eqv? type GNC-OWNER-CUSTOMER)
 	       (set! invoice? #t))
 	      ((eqv? type GNC-OWNER-VENDOR)
-	       (set! title (_ "Bill")))
+	       (set! default-title (_ "Bill")))
 	      ((eqv? type GNC-OWNER-EMPLOYEE)
-	       (set! title (_ "Expense Voucher")))))
-	  (set! title (sprintf #f (_"%s #%d") title
-			       (gncInvoiceGetID invoice)))))
+	       (set! default-title (_ "Expense Voucher")))))
+	  ))
+
     ;; oli-custom - title redundant, "Invoice" moved to myname-table,
     ;; invoice number moved below
     ;;(gnc:html-document-set-title! document title)
 
+    
     (if (not (null? invoice))
 	(let* ((book (gncInvoiceGetBook invoice))
 	      (slots (gnc-book-get-slots book))
 	      (date-object #f)
-	      (helper-table (gnc:make-html-table)))
+	      (helper-table (gnc:make-html-table))
+	      (title (title-string default-title custom-title)))
 	  (set! table (make-entry-table invoice
 					(gnc:report-options report-obj)
 					add-order invoice?))
@@ -819,7 +835,7 @@
 	  (gnc:html-document-add-object!
 	   document (make-myname-table
 		     book ;;(opt-val "Display" "Today Date Format")))
-		     ""))
+		     "" title))
 
 	  (make-break! document)
 	  (make-break! document)
@@ -843,9 +859,8 @@
 		  (set! date-table (make-date-table))
 		  ;; oli-custom - moved invoice number here
 		  (gnc:html-table-append-row!
-		   date-table (list (sprintf #f (_ "Invoice&nbsp;#&nbsp;%d")
-                                             (gncInvoiceGetID invoice))))
-		  (make-date-row! date-table (_ "Invoice&nbsp;Date") post-date)
+		   date-table (list (sprintf #f (_ "%s&nbsp;#") title) (gncInvoiceGetID invoice)))
+		  (make-date-row! date-table (string-append title (_ "&nbsp;Date")) post-date)
 		  (make-date-row! date-table (_ "Due&nbsp;Date") due-date)
 		  date-table)
 		(gnc:make-html-text

Modified: gnucash/trunk/src/business/business-reports/invoice.scm
===================================================================
--- gnucash/trunk/src/business/business-reports/invoice.scm	2008-12-08 22:57:23 UTC (rev 17763)
+++ gnucash/trunk/src/business/business-reports/invoice.scm	2008-12-09 23:50:04 UTC (rev 17764)
@@ -234,9 +234,15 @@
   (define (gnc:register-inv-option new-option)
     (gnc:register-option gnc:*report-options* new-option))
 
+   (gnc:register-inv-option
+    (gnc:make-invoice-option invoice-page invoice-name "x" ""
+ 			    (lambda () '()) #f))
+
   (gnc:register-inv-option
-   (gnc:make-invoice-option invoice-page invoice-name "x" ""
-			    (lambda () '()) #f))
+   (gnc:make-string-option 
+    invoice-page (N_ "Custom Title") 
+    "z" (N_ "A custom string to replace Invoice, Bill or Expense Voucher") 
+    ""))
 
   (gnc:register-inv-option
    (gnc:make-simple-boolean-option
@@ -622,13 +628,21 @@
     (gnc:option-value
      (gnc:lookup-option (gnc:report-options report-obj) section name)))
 
+  (define (title-string title custom-title)
+    (if (not (equal? "" custom-title))
+	(string-expand custom-title
+		       #\space "&nbsp;")
+	title))
+
   (let* ((document (gnc:make-html-document))
 	 (table '())
 	 (orders '())
 	 (invoice (opt-val invoice-page invoice-name))
 	 (owner '())
 	 (references? (opt-val "Display" "References"))
-	 (title (_ "Invoice"))
+	 (default-title (N_ "Invoice"))
+	 (custom-title (opt-val invoice-page "Custom Title"))
+	 (title "")
 	 (invoice? #f))
 
     (define (add-order o)
@@ -644,14 +658,15 @@
 	      ((eqv? type GNC-OWNER-CUSTOMER)
 	       (set! invoice? #t))
 	      ((eqv? type GNC-OWNER-VENDOR)
-	       (set! title (_ "Bill")))
+	       (set! default-title (_ "Bill")))
 	      ((eqv? type GNC-OWNER-EMPLOYEE)
-	       (set! title (_ "Expense Voucher")))))
-	  (set! title (sprintf #f (_"%s #%d") title
-			       (gncInvoiceGetID invoice)))))
+	       (set! default-title (_ "Expense Voucher")))))))
 
-    (gnc:html-document-set-title! document title)
+    (set! title (title-string default-title custom-title))
 
+    (gnc:html-document-set-title! document (sprintf #f (_"%s #%d") title
+						    (gncInvoiceGetID invoice)))
+
     (if (not (null? invoice))
 	(let ((book (gncInvoiceGetBook invoice)))
 	  (set! table (make-entry-table invoice
@@ -675,7 +690,7 @@
 	    (if (not (equal? post-date (cons 0 0)))
 		(begin
 		  (set! date-table (make-date-table))
-		  (make-date-row! date-table (_ "Invoice Date") post-date)
+		  (make-date-row! date-table (string-append title (_ " Date")) post-date)
 		  (make-date-row! date-table (_ "Due Date") due-date)
 		  (gnc:html-document-add-object! document date-table))
 		(gnc:html-document-add-object!



More information about the gnucash-changes mailing list