[invoice.scm] add qrcode section

This commit is contained in:
Christopher Lam 2021-01-05 20:13:40 +08:00
parent b881e85d4e
commit 80baf53bf1
2 changed files with 26 additions and 0 deletions

View File

@ -188,5 +188,7 @@
"td.centered-label-cell { text-align: center; " centered-label-cell-info " }\n" "td.centered-label-cell { text-align: center; " centered-label-cell-info " }\n"
"sub { top: 0.4em; }\n" "sub { top: 0.4em; }\n"
"sub, sup { vertical-align: baseline; position: relative; top: -0.4em; }\n" "sub, sup { vertical-align: baseline; position: relative; top: -0.4em; }\n"
".qr-code-error { color: white; background-color: red }\n"
"@media print { .qr-code-error { display:none; }}\n"
"@media print { html, body { height: unset; }}\n" "@media print { html, body { height: unset; }}\n"
(or (gnc:html-document-style-text doc) ""))))) (or (gnc:html-document-style-text doc) "")))))

View File

@ -295,6 +295,18 @@ for styling the invoice. Please see the exported report for the CSS class names.
"u" (N_ "Extra notes to put on the invoice.") "u" (N_ "Extra notes to put on the invoice.")
(G_ "Thank you for your patronage!")) (G_ "Thank you for your patronage!"))
(gnc-register-multichoice-callback-option
options
(N_ "Display") (N_ "QR Code")
"te" "QR Code"
"none"
(list
(vector 'none (N_ "None") (N_ "None"))
(vector 'epc (N_ "EPC QR Code") (N_ "EPC QR Code")))
(lambda _
(gnc-optiondb-set-option-selectable-by-name
options "Display" "QR Code" (gnc-qrcode-available))))
(gnc-register-multichoice-option options (gnc-register-multichoice-option options
(N_ "Layout") (N_ "Row 1 Left") (N_ "Layout") (N_ "Row 1 Left")
"1a" "1st row, left" "1a" "1st row, left"
@ -738,6 +750,7 @@ for styling the invoice. Please see the exported report for the CSS class names.
(else (else
(G_ "Invoice")))) (G_ "Invoice"))))
(title (if (string-null? custom-title) default-title custom-title)) (title (if (string-null? custom-title) default-title custom-title))
(opt-qrcode (opt-val "Display" "QR Code"))
;; Translators: This is the format of the invoice ;; Translators: This is the format of the invoice
;; title. The first ~a is one of "Invoice", "Credit ;; title. The first ~a is one of "Invoice", "Credit
;; Note", and so on and the second the number. Replace ;; Note", and so on and the second the number. Replace
@ -828,6 +841,17 @@ for styling the invoice. Please see the exported report for the CSS class names.
(multiline-to-html-text (multiline-to-html-text
(string-append contact-str ": " contact))))))) (string-append contact-str ": " contact)))))))
(cond
((eq? opt-qrcode 'none) #f)
((not (gnc-qrcode-available))
(gnc:warn "invoice QR: libqrencode not available"))
((eq? opt-qrcode 'epc)
(gnc:html-table-append-row!
main-table
(gnc:make-html-table-cell/size
1 2 (apply gnc:make-html-div/markup (gnc:make-epc-qrcode invoice)))))
(else (gnc:warn "QR option invalid")))
(gnc:html-table-append-row! main-table (gnc:html-table-append-row! main-table
(gnc:make-html-table-cell/size (gnc:make-html-table-cell/size
1 2 (gnc:make-html-div/markup 1 2 (gnc:make-html-div/markup