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.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17764 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Andrew Sackville-West
2008-12-09 23:50:04 +00:00
parent c32d9b75ef
commit 03f528d3c6
3 changed files with 72 additions and 27 deletions

View File

@@ -245,6 +245,12 @@
(gnc:make-invoice-option invoice-page invoice-name "x" ""
(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")
@@ -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'>")

View File

@@ -252,6 +252,12 @@
(gnc:make-invoice-option invoice-page invoice-name "x" ""
(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")
@@ -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

View File

@@ -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,13 +658,14 @@
((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)))
@@ -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!