Skip to content

Commit 5591660

Browse files
[invoice.scm] centralize layout components into layout-key-list
instead of maintaining 2 assoc lists.
1 parent f0bc675 commit 5591660

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

gnucash/report/reports/standard/invoice.scm

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,30 @@
108108
(gnc:make-gnc-monetary currency numeric)))
109109

110110
(define layout-key-list
111-
(list (cons 'client (list (cons 'text (G_ "Client or vendor name, address and ID"))))
112-
(cons 'company (list (cons 'text (G_ "Company name, address and tax-ID"))))
113-
(cons 'invoice (list (cons 'text (G_ "Invoice date, due date, billing ID, terms, job details"))))
114-
(cons 'today (list (cons 'text (G_ "Today's date"))))
115-
(cons 'picture (list (cons 'text (G_ "Picture"))))
111+
(list (list 'client
112+
(cons 'renderer make-client-table)
113+
(cons 'text (G_ "Client or vendor name, address and ID")))
114+
115+
(list 'company
116+
(cons 'renderer make-company-table)
117+
(cons 'text (G_ "Company name, address and tax-ID")))
118+
119+
(list 'invoice
120+
(cons 'renderer make-invoice-details-table)
121+
(cons 'text (G_ "Invoice date, due date, billing ID, terms, job details")))
122+
123+
(list 'today
124+
(cons 'renderer make-today)
125+
(cons 'text (G_ "Today's date")))
126+
127+
(list 'picture
128+
(cons 'renderer make-picture)
129+
(cons 'text (G_ "Picture")))
116130

117131
;; Translators: "Empty space" refers to invoice header section being left blank
118-
(cons 'none (list (cons 'text (G_ "Empty space"))))))
132+
(list 'none
133+
(cons 'renderer (const #f))
134+
(cons 'text (G_ "Empty space")))))
119135

120136
(define variant-list
121137
(list
@@ -768,13 +784,10 @@ for styling the invoice. Please see the exported report for the CSS class names.
768784
;; " #" by whatever is common as number abbreviation,
769785
;; i.e. "~a Nr. ~a"
770786
(invoice-title (format #f (G_"~a #~a") title (gncInvoiceGetID invoice)))
771-
(layout-lookup-table (list (cons 'none #f)
772-
(cons 'picture (make-picture options))
773-
(cons 'invoice (make-invoice-details-table options))
774-
(cons 'client (make-client-table options))
775-
(cons 'company (make-company-table options))
776-
(cons 'today (make-today options))))
777-
(layout-lookup (lambda (loc) (cdr (assq (opt-val "Layout" loc) layout-lookup-table)))))
787+
(layout-lookup (lambda (loc)
788+
(let* ((key (opt-val "Layout" loc))
789+
(renderer (keylist-get-info layout-key-list key 'renderer)))
790+
(renderer options)))))
778791

779792
(gnc:html-document-set-style-text! document (opt-val "Layout" "CSS"))
780793

0 commit comments

Comments
 (0)