mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[trep-engine] upgrade to include 'balance brought forward'
This fairly complex-looking change is actually simple. default-calculated-cells is redefined so that the running-balance column has a custom subheading renderer. The subheading renderer was formerly used solely for the account->friendly-debit/credit-string renderer, and is now upgraded to handle hard-coded symbols. If the friendly-heading-fn is a symbol 'bal-bf, it'll print the split->account->balance at begindate. Other columns may also be upgraded for novel subheading renderers. No forward/backward compatibility issues are expected at all. This change looks complex because the begindate is not available to make-split-table and has to be passed on as an argument to be available for use, and the subheading-renderer will test whether to display the friendly-fn-renderer at a later stage than previously.
This commit is contained in:
parent
0f4265d910
commit
741eb48016
@ -42,6 +42,7 @@
|
|||||||
(use-modules (gnucash gettext))
|
(use-modules (gnucash gettext))
|
||||||
(use-modules (srfi srfi-11))
|
(use-modules (srfi srfi-11))
|
||||||
(use-modules (srfi srfi-1))
|
(use-modules (srfi srfi-1))
|
||||||
|
(use-modules (ice-9 match))
|
||||||
|
|
||||||
;; Define the strings here to avoid typos and make changes easier.
|
;; Define the strings here to avoid typos and make changes easier.
|
||||||
|
|
||||||
@ -1033,7 +1034,8 @@ be excluded from periodic reporting.")
|
|||||||
;; ;;;;;;;;;;;;;;;;;;;;
|
;; ;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Here comes the big function that builds the whole table.
|
;; Here comes the big function that builds the whole table.
|
||||||
|
|
||||||
(define (make-split-table splits options custom-calculated-cells)
|
(define (make-split-table splits options custom-calculated-cells
|
||||||
|
begindate)
|
||||||
|
|
||||||
(define (opt-val section name)
|
(define (opt-val section name)
|
||||||
(let ((option (gnc:lookup-option options section name)))
|
(let ((option (gnc:lookup-option options section name)))
|
||||||
@ -1120,6 +1122,11 @@ be excluded from periodic reporting.")
|
|||||||
'multi-line))
|
'multi-line))
|
||||||
(export? (opt-val gnc:pagename-general optname-table-export)))
|
(export? (opt-val gnc:pagename-general optname-table-export)))
|
||||||
|
|
||||||
|
(define (acc-reverse? acc)
|
||||||
|
(if account-types-to-reverse
|
||||||
|
(memv (xaccAccountGetType acc) account-types-to-reverse)
|
||||||
|
(gnc-reverse-balance acc)))
|
||||||
|
|
||||||
(define (column-uses? param)
|
(define (column-uses? param)
|
||||||
(cdr (assq param used-columns)))
|
(cdr (assq param used-columns)))
|
||||||
|
|
||||||
@ -1315,6 +1322,7 @@ be excluded from periodic reporting.")
|
|||||||
;; column must be the credit side
|
;; column must be the credit side
|
||||||
;; friendly-heading-fn (friendly-heading-fn account) to retrieve
|
;; friendly-heading-fn (friendly-heading-fn account) to retrieve
|
||||||
;; friendly name for account debit/credit
|
;; friendly name for account debit/credit
|
||||||
|
;; or 'bal-bf for balance-brought-forward
|
||||||
|
|
||||||
(if (column-uses? 'amount-single)
|
(if (column-uses? 'amount-single)
|
||||||
(list (vector (header-commodity (_ "Amount"))
|
(list (vector (header-commodity (_ "Amount"))
|
||||||
@ -1351,7 +1359,7 @@ be excluded from periodic reporting.")
|
|||||||
(if (column-uses? 'running-balance)
|
(if (column-uses? 'running-balance)
|
||||||
(list (vector (_ "Running Balance")
|
(list (vector (_ "Running Balance")
|
||||||
running-balance #t #f #f
|
running-balance #t #f #f
|
||||||
(lambda (a) "")))
|
'bal-bf))
|
||||||
'()))))
|
'()))))
|
||||||
|
|
||||||
(define calculated-cells
|
(define calculated-cells
|
||||||
@ -1406,29 +1414,35 @@ be excluded from periodic reporting.")
|
|||||||
table subheading-style
|
table subheading-style
|
||||||
(append
|
(append
|
||||||
(gnc:html-make-empty-cells left-indent)
|
(gnc:html-make-empty-cells left-indent)
|
||||||
(if (and (opt-val pagename-sorting optname-show-informal-headers)
|
(if export?
|
||||||
(column-uses? 'amount-double)
|
(cons
|
||||||
(memq sortkey SORTKEY-INFORMAL-HEADERS))
|
(gnc:make-html-table-cell data)
|
||||||
(append
|
(gnc:html-make-empty-cells
|
||||||
(if export?
|
(+ right-indent width-left-columns -1)))
|
||||||
(cons
|
|
||||||
(gnc:make-html-table-cell data)
|
|
||||||
(gnc:html-make-empty-cells
|
|
||||||
(+ right-indent width-left-columns -1)))
|
|
||||||
(list
|
|
||||||
(gnc:make-html-table-cell/size
|
|
||||||
1 (+ right-indent width-left-columns) data)))
|
|
||||||
(map (lambda (cell)
|
|
||||||
(let ((friendly-fn (vector-ref cell 5)))
|
|
||||||
(and friendly-fn
|
|
||||||
(gnc:make-html-text
|
|
||||||
(gnc:html-markup-b
|
|
||||||
(friendly-fn (renderer-fn split)))))))
|
|
||||||
calculated-cells))
|
|
||||||
(list
|
(list
|
||||||
(gnc:make-html-table-cell/size
|
(gnc:make-html-table-cell/size
|
||||||
1 (+ right-indent width-left-columns width-right-columns)
|
1 (+ right-indent width-left-columns) data)))
|
||||||
data))))))))
|
(map
|
||||||
|
(lambda (cell)
|
||||||
|
(match (vector-ref cell 5)
|
||||||
|
(#f #f)
|
||||||
|
('bal-bf
|
||||||
|
(let* ((acc (xaccSplitGetAccount split))
|
||||||
|
(bal (xaccAccountGetBalanceAsOfDate acc begindate)))
|
||||||
|
(and (memq sortkey ACCOUNT-SORTING-TYPES)
|
||||||
|
(gnc:make-html-table-cell/markup
|
||||||
|
"number-cell"
|
||||||
|
(gnc:make-gnc-monetary
|
||||||
|
(xaccAccountGetCommodity acc)
|
||||||
|
(if (acc-reverse? acc) (- bal) bal))))))
|
||||||
|
(fn
|
||||||
|
(and (opt-val pagename-sorting optname-show-informal-headers)
|
||||||
|
(column-uses? 'amount-double)
|
||||||
|
(memq sortkey SORTKEY-INFORMAL-HEADERS)
|
||||||
|
(gnc:make-html-text
|
||||||
|
(gnc:html-markup-b
|
||||||
|
(fn (xaccSplitGetAccount split))))))))
|
||||||
|
calculated-cells))))))
|
||||||
|
|
||||||
(define (add-subtotal-row subtotal-string subtotal-collectors
|
(define (add-subtotal-row subtotal-string subtotal-collectors
|
||||||
subtotal-style level row col)
|
subtotal-style level row col)
|
||||||
@ -1605,10 +1619,7 @@ be excluded from periodic reporting.")
|
|||||||
|
|
||||||
(define (add-split-row split cell-calculators row-style transaction-row?)
|
(define (add-split-row split cell-calculators row-style transaction-row?)
|
||||||
(let* ((account (xaccSplitGetAccount split))
|
(let* ((account (xaccSplitGetAccount split))
|
||||||
(reversible-account? (if account-types-to-reverse
|
(reversible-account? (acc-reverse? account))
|
||||||
(memv (xaccAccountGetType account)
|
|
||||||
account-types-to-reverse)
|
|
||||||
(gnc-reverse-balance account)))
|
|
||||||
(cells (map (lambda (cell)
|
(cells (map (lambda (cell)
|
||||||
(let ((split->monetary (vector-ref cell 1)))
|
(let ((split->monetary (vector-ref cell 1)))
|
||||||
(vector (split->monetary split)
|
(vector (split->monetary split)
|
||||||
@ -2173,7 +2184,8 @@ be excluded from periodic reporting.")
|
|||||||
|
|
||||||
(else
|
(else
|
||||||
(let-values (((table grid csvlist)
|
(let-values (((table grid csvlist)
|
||||||
(make-split-table splits options custom-calculated-cells)))
|
(make-split-table splits options custom-calculated-cells
|
||||||
|
begindate)))
|
||||||
|
|
||||||
(gnc:html-document-set-title! document report-title)
|
(gnc:html-document-set-title! document report-title)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user