mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
ENH: Add indenting for main data and subheadings/subtotals
Adds between 0-2 empty columns to the left, depending on subtotal strategy. Option toggle added to Sorting tab
This commit is contained in:
parent
408f609a58
commit
7a5f2ed49b
@ -16,6 +16,7 @@
|
|||||||
;; and enable multiple data columns
|
;; and enable multiple data columns
|
||||||
;; - add informational box, summarising options used, useful
|
;; - add informational box, summarising options used, useful
|
||||||
;; to troubleshoot reports
|
;; to troubleshoot reports
|
||||||
|
;; - add support for indenting for better grouping
|
||||||
;;
|
;;
|
||||||
;; This program is free software; you can redistribute it and/or
|
;; This program is free software; you can redistribute it and/or
|
||||||
;; modify it under the terms of the GNU General Public License as
|
;; modify it under the terms of the GNU General Public License as
|
||||||
@ -72,6 +73,7 @@
|
|||||||
(define optname-show-account-code (N_ "Show Account Code"))
|
(define optname-show-account-code (N_ "Show Account Code"))
|
||||||
(define optname-show-account-description (N_ "Show Account Description"))
|
(define optname-show-account-description (N_ "Show Account Description"))
|
||||||
(define optname-show-informal-headers (N_ "Show Informal Debit/Credit Headers"))
|
(define optname-show-informal-headers (N_ "Show Informal Debit/Credit Headers"))
|
||||||
|
(define optname-indenting (N_ "Add indenting columns"))
|
||||||
(define optname-sec-sortkey (N_ "Secondary Key"))
|
(define optname-sec-sortkey (N_ "Secondary Key"))
|
||||||
(define optname-sec-subtotal (N_ "Secondary Subtotal"))
|
(define optname-sec-subtotal (N_ "Secondary Subtotal"))
|
||||||
(define optname-sec-sortorder (N_ "Secondary Sort Order"))
|
(define optname-sec-sortorder (N_ "Secondary Sort Order"))
|
||||||
@ -577,6 +579,11 @@ tags within description, notes or memo. ")
|
|||||||
(or (and prime-sortkey-subtotal-enabled prime-sortkey-subtotal-true)
|
(or (and prime-sortkey-subtotal-enabled prime-sortkey-subtotal-true)
|
||||||
(and sec-sortkey-subtotal-enabled sec-sortkey-subtotal-true)))
|
(and sec-sortkey-subtotal-enabled sec-sortkey-subtotal-true)))
|
||||||
|
|
||||||
|
(gnc-option-db-set-option-selectable-by-name
|
||||||
|
options pagename-sorting optname-indenting
|
||||||
|
(or (and prime-sortkey-subtotal-enabled prime-sortkey-subtotal-true)
|
||||||
|
(and sec-sortkey-subtotal-enabled sec-sortkey-subtotal-true)))
|
||||||
|
|
||||||
(gnc-option-db-set-option-selectable-by-name
|
(gnc-option-db-set-option-selectable-by-name
|
||||||
options pagename-sorting optname-show-informal-headers
|
options pagename-sorting optname-show-informal-headers
|
||||||
(or (member prime-sortkey (list 'account-name 'account-code))
|
(or (member prime-sortkey (list 'account-name 'account-code))
|
||||||
@ -622,7 +629,6 @@ tags within description, notes or memo. ")
|
|||||||
(_ "Show the account description for subheadings?")
|
(_ "Show the account description for subheadings?")
|
||||||
#f))
|
#f))
|
||||||
|
|
||||||
|
|
||||||
(gnc:register-trep-option
|
(gnc:register-trep-option
|
||||||
(gnc:make-simple-boolean-option
|
(gnc:make-simple-boolean-option
|
||||||
pagename-sorting optname-show-informal-headers
|
pagename-sorting optname-show-informal-headers
|
||||||
@ -630,6 +636,13 @@ tags within description, notes or memo. ")
|
|||||||
(_ "Show the informal headers for debit/credit accounts?")
|
(_ "Show the informal headers for debit/credit accounts?")
|
||||||
#f))
|
#f))
|
||||||
|
|
||||||
|
(gnc:register-trep-option
|
||||||
|
(gnc:make-simple-boolean-option
|
||||||
|
pagename-sorting optname-indenting
|
||||||
|
"j5"
|
||||||
|
(_ "Add indenting columns with grouping and subtotals?")
|
||||||
|
#t))
|
||||||
|
|
||||||
(gnc:register-trep-option
|
(gnc:register-trep-option
|
||||||
(gnc:make-complex-boolean-option
|
(gnc:make-complex-boolean-option
|
||||||
pagename-sorting optname-prime-subtotal
|
pagename-sorting optname-prime-subtotal
|
||||||
@ -855,6 +868,7 @@ tags within description, notes or memo. ")
|
|||||||
(cons 'amount-original-currency
|
(cons 'amount-original-currency
|
||||||
(and (opt-val gnc:pagename-general optname-common-currency)
|
(and (opt-val gnc:pagename-general optname-common-currency)
|
||||||
(opt-val gnc:pagename-general optname-orig-currency)))
|
(opt-val gnc:pagename-general optname-orig-currency)))
|
||||||
|
(cons 'indenting (opt-val pagename-sorting optname-indenting))
|
||||||
(cons 'running-balance (opt-val gnc:pagename-display (N_ "Running Balance")))
|
(cons 'running-balance (opt-val gnc:pagename-display (N_ "Running Balance")))
|
||||||
(cons 'account-full-name (opt-val gnc:pagename-display (N_ "Use Full Account Name")))
|
(cons 'account-full-name (opt-val gnc:pagename-display (N_ "Use Full Account Name")))
|
||||||
(cons 'memo (opt-val gnc:pagename-display (N_ "Memo")))
|
(cons 'memo (opt-val gnc:pagename-display (N_ "Memo")))
|
||||||
@ -1119,36 +1133,61 @@ tags within description, notes or memo. ")
|
|||||||
(define width-left-columns (length left-columns))
|
(define width-left-columns (length left-columns))
|
||||||
(define width-right-columns (length calculated-cells))
|
(define width-right-columns (length calculated-cells))
|
||||||
|
|
||||||
|
(define primary-indent
|
||||||
|
(if (and (column-uses? 'indenting)
|
||||||
|
(primary-get-info 'renderer-fn))
|
||||||
|
1 0))
|
||||||
|
|
||||||
|
(define secondary-indent
|
||||||
|
(if (and (column-uses? 'indenting)
|
||||||
|
(secondary-get-info 'renderer-fn))
|
||||||
|
1 0))
|
||||||
|
|
||||||
|
(define indent-level
|
||||||
|
(+ primary-indent secondary-indent))
|
||||||
|
|
||||||
|
|
||||||
(define (add-subheading data subheading-style split level)
|
(define (add-subheading data subheading-style split level)
|
||||||
(let ((sortkey (opt-val pagename-sorting
|
(let* ((row-contents '())
|
||||||
|
(sortkey (opt-val pagename-sorting
|
||||||
(case level
|
(case level
|
||||||
((primary) optname-prime-sortkey)
|
((primary) optname-prime-sortkey)
|
||||||
((secondary) optname-sec-sortkey)))))
|
((secondary) optname-sec-sortkey))))
|
||||||
|
(left-indent (case level
|
||||||
|
((primary total) 0)
|
||||||
|
((secondary) primary-indent)))
|
||||||
|
(right-indent (- indent-level left-indent)))
|
||||||
|
(for-each (lambda (cell) (addto! row-contents cell))
|
||||||
|
(gnc:html-make-empty-cells left-indent))
|
||||||
(if (and (opt-val pagename-sorting optname-show-informal-headers)
|
(if (and (opt-val pagename-sorting optname-show-informal-headers)
|
||||||
(member sortkey SORTKEY-INFORMAL-HEADERS))
|
(member sortkey SORTKEY-INFORMAL-HEADERS))
|
||||||
(let ((row-contents '()))
|
|
||||||
(begin
|
(begin
|
||||||
(if export?
|
(if export?
|
||||||
(begin (addto! row-contents (gnc:make-html-table-cell subheading-style data))
|
(begin
|
||||||
|
(addto! row-contents (gnc:make-html-table-cell data))
|
||||||
(for-each (lambda (cell) (addto! row-contents cell))
|
(for-each (lambda (cell) (addto! row-contents cell))
|
||||||
(gnc:html-make-empty-cells (- width-left-columns 1))))
|
(gnc:html-make-empty-cells (+ right-indent width-left-columns -1))))
|
||||||
(addto! row-contents (gnc:make-html-table-cell/size 1 width-left-columns data)))
|
(addto! row-contents (gnc:make-html-table-cell/size
|
||||||
(map (lambda (col)
|
1 (+ right-indent width-left-columns) data)))
|
||||||
|
(for-each (lambda (cell)
|
||||||
(addto! row-contents
|
(addto! row-contents
|
||||||
(gnc:make-html-table-cell
|
(gnc:make-html-table-cell
|
||||||
"<b>"
|
"<b>"
|
||||||
((vector-ref col 5)
|
((vector-ref cell 5)
|
||||||
((keylist-get-info sortkey-list sortkey 'renderer-fn) split))
|
((keylist-get-info sortkey-list sortkey 'renderer-fn) split))
|
||||||
"</b>")))
|
"</b>")))
|
||||||
calculated-cells)
|
calculated-cells))
|
||||||
|
(addto! row-contents (gnc:make-html-table-cell/size
|
||||||
|
1 (+ right-indent width-left-columns width-right-columns) data)))
|
||||||
(gnc:html-table-append-row/markup! table subheading-style (reverse row-contents))))
|
(gnc:html-table-append-row/markup! table subheading-style (reverse row-contents))))
|
||||||
(let ((heading-cell (gnc:make-html-table-cell data)))
|
|
||||||
(gnc:html-table-cell-set-colspan! heading-cell (+ width-left-columns width-right-columns))
|
|
||||||
(gnc:html-table-append-row/markup!
|
|
||||||
table subheading-style (list heading-cell))))))
|
|
||||||
|
|
||||||
(define (add-subtotal-row subtotal-string subtotal-collectors subtotal-style)
|
(define (add-subtotal-row subtotal-string subtotal-collectors subtotal-style level)
|
||||||
(let* ((row-contents '())
|
(let* ((row-contents '())
|
||||||
|
(left-indent (case level
|
||||||
|
((total) 0)
|
||||||
|
((primary) primary-indent)
|
||||||
|
((secondary) (+ primary-indent secondary-indent))))
|
||||||
|
(right-indent (- indent-level left-indent))
|
||||||
(merge-list (map (lambda (cell) (vector-ref cell 4)) calculated-cells))
|
(merge-list (map (lambda (cell) (vector-ref cell 4)) calculated-cells))
|
||||||
(columns (map (lambda (coll) (coll 'format gnc:make-gnc-monetary #f)) subtotal-collectors))
|
(columns (map (lambda (coll) (coll 'format gnc:make-gnc-monetary #f)) subtotal-collectors))
|
||||||
(list-of-commodities (delete-duplicates (map gnc:gnc-monetary-commodity (concatenate columns))
|
(list-of-commodities (delete-duplicates (map gnc:gnc-monetary-commodity (concatenate columns))
|
||||||
@ -1166,8 +1205,8 @@ tags within description, notes or memo. ")
|
|||||||
(begin
|
(begin
|
||||||
(addto! row-contents (gnc:make-html-table-cell/markup "total-label-cell" string))
|
(addto! row-contents (gnc:make-html-table-cell/markup "total-label-cell" string))
|
||||||
(for-each (lambda (cell) (addto! row-contents cell))
|
(for-each (lambda (cell) (addto! row-contents cell))
|
||||||
(gnc:html-make-empty-cells (- width-left-columns 1))))
|
(gnc:html-make-empty-cells (+ right-indent width-left-columns -1))))
|
||||||
(addto! row-contents (gnc:make-html-table-cell/size/markup 1 width-left-columns "total-label-cell" string))))
|
(addto! row-contents (gnc:make-html-table-cell/size/markup 1 (+ right-indent width-left-columns) "total-label-cell" string))))
|
||||||
|
|
||||||
(define (add-columns commodity)
|
(define (add-columns commodity)
|
||||||
(let ((start-dual-column? #f)
|
(let ((start-dual-column? #f)
|
||||||
@ -1219,6 +1258,8 @@ tags within description, notes or memo. ")
|
|||||||
merge-list)))
|
merge-list)))
|
||||||
|
|
||||||
;;first row
|
;;first row
|
||||||
|
(for-each (lambda (cell) (addto! row-contents cell))
|
||||||
|
(gnc:html-make-empty-cells left-indent))
|
||||||
(add-first-column subtotal-string)
|
(add-first-column subtotal-string)
|
||||||
(add-columns (if (pair? list-of-commodities)
|
(add-columns (if (pair? list-of-commodities)
|
||||||
(car list-of-commodities)
|
(car list-of-commodities)
|
||||||
@ -1229,6 +1270,8 @@ tags within description, notes or memo. ")
|
|||||||
(if (pair? list-of-commodities)
|
(if (pair? list-of-commodities)
|
||||||
(for-each (lambda (commodity)
|
(for-each (lambda (commodity)
|
||||||
(set! row-contents '())
|
(set! row-contents '())
|
||||||
|
(for-each (lambda (cell) (addto! row-contents cell))
|
||||||
|
(gnc:html-make-empty-cells left-indent))
|
||||||
(add-first-column "")
|
(add-first-column "")
|
||||||
(add-columns commodity)
|
(add-columns commodity)
|
||||||
(gnc:html-table-append-row/markup! table subtotal-style (reverse row-contents)))
|
(gnc:html-table-append-row/markup! table subtotal-style (reverse row-contents)))
|
||||||
@ -1334,6 +1377,9 @@ tags within description, notes or memo. ")
|
|||||||
subtotal?)))
|
subtotal?)))
|
||||||
cell-calculators))
|
cell-calculators))
|
||||||
|
|
||||||
|
(for-each (lambda (cell) (addto! row-contents cell))
|
||||||
|
(gnc:html-make-empty-cells indent-level))
|
||||||
|
|
||||||
(for-each (lambda (col)
|
(for-each (lambda (col)
|
||||||
(addto! row-contents col))
|
(addto! row-contents col))
|
||||||
left-cols)
|
left-cols)
|
||||||
@ -1400,10 +1446,10 @@ tags within description, notes or memo. ")
|
|||||||
table def:grand-total-style
|
table def:grand-total-style
|
||||||
(list
|
(list
|
||||||
(gnc:make-html-table-cell/size
|
(gnc:make-html-table-cell/size
|
||||||
1 (+ width-left-columns width-right-columns)
|
1 (+ indent-level width-left-columns width-right-columns)
|
||||||
(gnc:make-html-text (gnc:html-markup-hr)))))
|
(gnc:make-html-text (gnc:html-markup-hr)))))
|
||||||
|
|
||||||
(add-subtotal-row (render-grand-total) total-collectors def:grand-total-style)))
|
(add-subtotal-row (render-grand-total) total-collectors def:grand-total-style 'total)))
|
||||||
|
|
||||||
(let* ((current (car splits))
|
(let* ((current (car splits))
|
||||||
(rest (cdr splits))
|
(rest (cdr splits))
|
||||||
@ -1453,13 +1499,15 @@ tags within description, notes or memo. ")
|
|||||||
(add-subtotal-row (total-string
|
(add-subtotal-row (total-string
|
||||||
(render-summary current 'secondary #f))
|
(render-summary current 'secondary #f))
|
||||||
secondary-subtotal-collectors
|
secondary-subtotal-collectors
|
||||||
def:secondary-subtotal-style)
|
def:secondary-subtotal-style
|
||||||
|
'secondary)
|
||||||
(for-each (lambda (coll) (coll 'reset #f #f))
|
(for-each (lambda (coll) (coll 'reset #f #f))
|
||||||
secondary-subtotal-collectors)))
|
secondary-subtotal-collectors)))
|
||||||
(add-subtotal-row (total-string
|
(add-subtotal-row (total-string
|
||||||
(render-summary current 'primary #f))
|
(render-summary current 'primary #f))
|
||||||
primary-subtotal-collectors
|
primary-subtotal-collectors
|
||||||
def:primary-subtotal-style)
|
def:primary-subtotal-style
|
||||||
|
'primary)
|
||||||
(for-each (lambda (coll) (coll 'reset #f #f))
|
(for-each (lambda (coll) (coll 'reset #f #f))
|
||||||
primary-subtotal-collectors)
|
primary-subtotal-collectors)
|
||||||
(if next
|
(if next
|
||||||
@ -1478,7 +1526,8 @@ tags within description, notes or memo. ")
|
|||||||
(begin (add-subtotal-row (total-string
|
(begin (add-subtotal-row (total-string
|
||||||
(render-summary current 'secondary #f))
|
(render-summary current 'secondary #f))
|
||||||
secondary-subtotal-collectors
|
secondary-subtotal-collectors
|
||||||
def:secondary-subtotal-style)
|
def:secondary-subtotal-style
|
||||||
|
'secondary)
|
||||||
(for-each (lambda (coll) (coll 'reset #f #f))
|
(for-each (lambda (coll) (coll 'reset #f #f))
|
||||||
secondary-subtotal-collectors)
|
secondary-subtotal-collectors)
|
||||||
(if next
|
(if next
|
||||||
@ -1487,7 +1536,10 @@ tags within description, notes or memo. ")
|
|||||||
|
|
||||||
(do-rows-with-subtotals rest (not odd-row?)))))
|
(do-rows-with-subtotals rest (not odd-row?)))))
|
||||||
|
|
||||||
(gnc:html-table-set-col-headers! table (concatenate (list headings-left-columns headings-right-columns)))
|
(gnc:html-table-set-col-headers! table (concatenate (list
|
||||||
|
(gnc:html-make-empty-cells indent-level)
|
||||||
|
headings-left-columns
|
||||||
|
headings-right-columns)))
|
||||||
|
|
||||||
(if (primary-get-info 'renderer-fn)
|
(if (primary-get-info 'renderer-fn)
|
||||||
(add-subheading (render-summary (car splits) 'primary #t)
|
(add-subheading (render-summary (car splits) 'primary #t)
|
||||||
|
Loading…
Reference in New Issue
Block a user