ENH: Add option to choose infobox display summary

Options are: always/never display, or display if no splits are matched or found
This commit is contained in:
Christopher Lam 2017-11-27 21:43:07 +08:00
parent f2df1bd49c
commit 139e2aa7f2

View File

@ -83,6 +83,7 @@
(define optname-common-currency (N_ "Common Currency"))
(define optname-orig-currency (N_ "Show original currency amount"))
(define optname-currency (N_ "Report's currency"))
(define optname-infobox-display (N_ "Add options summary"))
;;Filtering
(define pagename-filter (N_ "Filter"))
@ -399,6 +400,24 @@ Credit Card, and Income accounts."))
gnc:pagename-general optname-table-export
"g" (_ "Formats the table suitable for cut & paste exporting with extra cells.") #f))
(gnc:register-trep-option
(gnc:make-multichoice-option
gnc:pagename-general optname-infobox-display
"h" (_ "Add summary of options.")
'(no-match)
;; This is an alist of conditions for displaying the infobox
;; 'no-match for empty-report
;; 'match for generated report
(list (vector '(no-match)
(_ "If no transactions matched")
(_ "Display summary if no transactions were matched."))
(vector '(no-match match)
(_ "Always")
(_ "Always display summary."))
(vector '()
(_ "Never")
(_ "Disable report summary.")))))
;; Filtering Options
(gnc:register-trep-option
@ -1473,6 +1492,7 @@ tags within description, notes or memo. ")
(not (eq? primary-date-subtotal 'none))) ; until qof-query
(and (member secondary-key DATE-SORTING-TYPES) ; is upgraded
(not (eq? secondary-date-subtotal 'none)))))
(infobox-display (opt-val gnc:pagename-general optname-infobox-display))
(query (qof-query-create-for-splits)))
(define (generic-less? X Y key date-subtotal ascend?)
@ -1617,10 +1637,11 @@ tags within description, notes or memo. ")
(gnc:html-markup-h2 NO-MATCHING-ACCT-HEADER)
(gnc:html-markup-p NO-MATCHING-ACCT-TEXT)))
(gnc:html-document-add-object!
document
(infobox))))
(if (member 'nomatch infobox-display)
(gnc:html-document-add-object!
document
(infobox)))))
(begin
(qof-query-set-book query (gnc-get-current-book))
@ -1683,9 +1704,10 @@ tags within description, notes or memo. ")
(gnc:html-markup-h2 NO-MATCHING-TRANS-HEADER)
(gnc:html-markup-p NO-MATCHING-TRANS-TEXT)))
(gnc:html-document-add-object!
document
(infobox)))
(if (member 'no-match infobox-display)
(gnc:html-document-add-object!
document
(infobox))))
(let ((table (make-split-table splits options)))
@ -1700,9 +1722,10 @@ tags within description, notes or memo. ")
(gnc-print-date begindate)
(gnc-print-date enddate)))))
(gnc:html-document-add-object!
document
(infobox))
(if (member 'match infobox-display)
(gnc:html-document-add-object!
document
(infobox)))
(gnc:html-document-add-object! document table)))))