mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[transaction] convert add-split-row to functional style
This commit removes need for row-contents, building a list of table-cells directly.
This commit is contained in:
parent
f3100ddc0a
commit
83ad9e4b89
@ -1509,65 +1509,46 @@ 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* ((row-contents '())
|
(let* ((account (xaccSplitGetAccount split))
|
||||||
(trans (xaccSplitGetParent split))
|
(reversible-account? (if account-types-to-reverse
|
||||||
(account (xaccSplitGetAccount split)))
|
(member (xaccAccountGetType account)
|
||||||
|
account-types-to-reverse)
|
||||||
|
(gnc-reverse-balance account)))
|
||||||
|
(cells (map (lambda (cell)
|
||||||
|
(let* ((split->monetary (vector-ref cell 1)))
|
||||||
|
(vector (split->monetary split)
|
||||||
|
(vector-ref cell 2) ;reverse?
|
||||||
|
(vector-ref cell 3) ;subtotal?
|
||||||
|
)))
|
||||||
|
cell-calculators)))
|
||||||
|
|
||||||
(define left-cols
|
(unless (column-uses? 'subtotals-only)
|
||||||
(map (lambda (left-col)
|
(gnc:html-table-append-row/markup!
|
||||||
(let* ((col-fn (vector-ref left-col 1))
|
table row-style
|
||||||
(col-data (col-fn split transaction-row?)))
|
(append
|
||||||
col-data))
|
(gnc:html-make-empty-cells indent-level)
|
||||||
left-columns))
|
(map (lambda (left-col)
|
||||||
|
((vector-ref left-col 1)
|
||||||
(define cells
|
split transaction-row?))
|
||||||
(map (lambda (cell)
|
left-columns)
|
||||||
(let* ((calculator (vector-ref cell 1))
|
(map (lambda (cell)
|
||||||
(reverse? (vector-ref cell 2))
|
(let ((cell-monetary (vector-ref cell 0))
|
||||||
(subtotal? (vector-ref cell 3))
|
(reverse? (and (vector-ref cell 1)
|
||||||
(calculated (calculator split)))
|
reversible-account?)))
|
||||||
(vector calculated
|
(and cell-monetary
|
||||||
reverse?
|
(gnc:make-html-table-cell/markup
|
||||||
subtotal?)))
|
"number-cell"
|
||||||
cell-calculators))
|
(gnc:html-transaction-anchor
|
||||||
|
(xaccSplitGetParent split)
|
||||||
(for-each (lambda (cell) (addto! row-contents cell))
|
(if reverse?
|
||||||
(gnc:html-make-empty-cells indent-level))
|
(gnc:monetary-neg cell-monetary)
|
||||||
|
cell-monetary))))))
|
||||||
(for-each (lambda (col)
|
cells))))
|
||||||
(addto! row-contents col))
|
|
||||||
left-cols)
|
|
||||||
|
|
||||||
(for-each (lambda (cell)
|
|
||||||
(let ((cell-content (vector-ref cell 0))
|
|
||||||
;; reverse? returns a bool - will check if the cell type has reversible sign,
|
|
||||||
;; whether the account is also reversible according to Report Option, or
|
|
||||||
;; if Report Option follows Global Settings, will retrieve bool from it.
|
|
||||||
(reverse? (and (vector-ref cell 1)
|
|
||||||
(if account-types-to-reverse
|
|
||||||
(member (xaccAccountGetType account) account-types-to-reverse)
|
|
||||||
(gnc-reverse-balance account)))))
|
|
||||||
(if cell-content
|
|
||||||
(addto! row-contents
|
|
||||||
(gnc:make-html-table-cell/markup
|
|
||||||
"number-cell"
|
|
||||||
(gnc:html-transaction-anchor
|
|
||||||
trans
|
|
||||||
;; if conditions for reverse are satisfied, apply sign reverse to
|
|
||||||
;; monetary amount
|
|
||||||
(if reverse?
|
|
||||||
(gnc:monetary-neg cell-content)
|
|
||||||
cell-content))))
|
|
||||||
(addto! row-contents (gnc:html-make-empty-cell)))))
|
|
||||||
cells)
|
|
||||||
|
|
||||||
(if (not (column-uses? 'subtotals-only))
|
|
||||||
(gnc:html-table-append-row/markup! table row-style (reverse row-contents)))
|
|
||||||
|
|
||||||
(map (lambda (cell)
|
(map (lambda (cell)
|
||||||
(let ((cell-content (vector-ref cell 0))
|
(let ((cell-monetary (vector-ref cell 0))
|
||||||
(subtotal? (vector-ref cell 2)))
|
(subtotal? (vector-ref cell 2)))
|
||||||
(and subtotal? cell-content)))
|
(and subtotal? cell-monetary)))
|
||||||
cells)))
|
cells)))
|
||||||
|
|
||||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
Loading…
Reference in New Issue
Block a user