diff --git a/gnucash/report/trep-engine.scm b/gnucash/report/trep-engine.scm index 1504cfb2a7..14f7429958 100644 --- a/gnucash/report/trep-engine.scm +++ b/gnucash/report/trep-engine.scm @@ -1653,14 +1653,22 @@ be excluded from periodic reporting.") (gnc-commodity-equal commodity (gnc:gnc-monetary-commodity mon))) list-of-monetary)) + (define anchor + (gensym "subtotals")) + + (define (cell-add-id cell) + (gnc:html-table-cell-set-style! cell "total-label-cell" 'attribute (list "id" anchor)) + cell) + (define (first-column string) (if (report-uses? 'export-table) (cons - (gnc:make-html-table-cell/markup "total-label-cell" string) + (cell-add-id (gnc:make-html-table-cell/markup "total-label-cell" string)) (gnc:html-make-empty-cells (+ right-indent width-left-columns -1))) (list - (gnc:make-html-table-cell/size/markup - 1 (+ right-indent width-left-columns) "total-label-cell" string)))) + (cell-add-id + (gnc:make-html-table-cell/size/markup + 1 (+ right-indent width-left-columns) "total-label-cell" string))))) (define (data-columns commodity) (let loop ((merging? #f) @@ -1719,7 +1727,7 @@ be excluded from periodic reporting.") zero)))) (set! grid - (grid-add grid row col (map get-commodity-grid-amount list-of-commodities))) + (grid-add grid row col (map get-commodity-grid-amount list-of-commodities) anchor)) ;; each commodity subtotal gets a separate line in the html-table ;; each line comprises: indenting, first-column, data-columns @@ -2008,12 +2016,20 @@ be excluded from periodic reporting.") calculated-cells total-collectors))))) (values table grid csvlist)))) +(define-record-type :subtotal-table-cell + (make-subtotal-table-cell row col data anchor) + subtotal-table-cell? + (row get-subtotal-table-cell-row) + (col get-subtotal-table-cell-col) + (data get-subtotal-table-cell-data) + (anchor get-subtotal-table-cell-anchor)) + ;; grid data structure (define (make-grid) '()) (define (cell-match? cell row col) - (and (or (not row) (equal? row (vector-ref cell 0))) - (or (not col) (equal? col (vector-ref cell 1))))) + (and (or (not row) (equal? row (get-subtotal-table-cell-row cell))) + (or (not col) (equal? col (get-subtotal-table-cell-col cell))))) (define (grid-get grid row col) ;; grid filter - get all row/col - if #f then retrieve whole row/col (filter @@ -2021,13 +2037,13 @@ be excluded from periodic reporting.") (cell-match? cell row col)) grid)) (define (grid-rows grid) - (delete-duplicates (map (lambda (cell) (vector-ref cell 0)) grid))) + (delete-duplicates (map get-subtotal-table-cell-row grid))) (define (grid-cols grid) - (delete-duplicates (map (lambda (cell) (vector-ref cell 1)) grid))) -(define (grid-add grid row col data) + (delete-duplicates (map get-subtotal-table-cell-col grid))) +(define (grid-add grid row col data anchor) ;; we don't need to check for duplicate cells in a row/col because ;; in the trep it should never happen. - (cons (vector row col data) grid)) + (cons (make-subtotal-table-cell row col data anchor) grid)) (define (grid->html-table grid) (define (