mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[register] simplify make-split-table main loop
Previous was using nested ifs. use cond instead which is more appropriate. Also handle dangling-split separately.
This commit is contained in:
parent
bae74fed0a
commit
b1763ed13d
@ -605,16 +605,14 @@
|
||||
(let loop ((splits splits)
|
||||
(odd-row? #t))
|
||||
|
||||
(if (null? splits)
|
||||
(cond
|
||||
|
||||
;; ----------------------------------
|
||||
;; exit condition reached
|
||||
;; ----------------------------------
|
||||
(begin
|
||||
;; ------------------------------------
|
||||
;; add debit/credit totals to the table
|
||||
;; ------------------------------------
|
||||
(if (reg-report-show-totals?)
|
||||
(begin
|
||||
;; ----------------------------------
|
||||
((null? splits)
|
||||
(when reg-report-show-totals?
|
||||
(add-subtotal-row (_ "Total Debits") leader table used-columns
|
||||
debit-collector "grand-total" #f)
|
||||
(add-subtotal-row (_ "Total Credits") leader table used-columns
|
||||
@ -622,31 +620,36 @@
|
||||
(add-subtotal-row (_ "Total Value Debits") leader table used-columns
|
||||
debit-value "grand-total" #t)
|
||||
(add-subtotal-row (_ "Total Value Credits") leader table used-columns
|
||||
credit-value "grand-total" #t)))
|
||||
(if ledger-type?
|
||||
credit-value "grand-total" #t))
|
||||
(when ledger-type?
|
||||
(add-subtotal-row (_ "Net Change") leader table used-columns
|
||||
total-collector "grand-total" #f))
|
||||
(add-subtotal-row (_ "Value Change") leader table used-columns
|
||||
total-value "grand-total" #t))
|
||||
|
||||
;; The general journal has a split that doesn't have an account
|
||||
;; set yet (the new entry transaction).
|
||||
;; This split should be skipped or the report errors out. See
|
||||
;; bug #639082
|
||||
((null? (xaccSplitGetAccount (car splits)))
|
||||
(loop (cdr splits) (not odd-row?)))
|
||||
|
||||
;; ----------------------------------
|
||||
;; process the splits list
|
||||
;; ----------------------------------
|
||||
(else
|
||||
(let* ((current (car splits))
|
||||
(current-row-style (if multi-rows? "normal-row"
|
||||
(if odd-row? "normal-row"
|
||||
(current-row-style (if (or multi-rows? odd-row?)
|
||||
"normal-row"
|
||||
"alternate-row")))
|
||||
(rest (cdr splits))
|
||||
(valid-split? (not (null? (xaccSplitGetAccount current)))))
|
||||
;; ----------------------------------------------
|
||||
;; update totals, but don't add them to the table
|
||||
;; ----------------------------------------------
|
||||
(if (and multi-rows? valid-split?)
|
||||
(for-each (lambda (split)
|
||||
(if (string=? (gncAccountGetGUID
|
||||
(xaccSplitGetAccount current))
|
||||
(gncAccountGetGUID
|
||||
(xaccSplitGetAccount split)))
|
||||
(if multi-rows?
|
||||
(for-each
|
||||
(lambda (split)
|
||||
(if (equal? (xaccSplitGetAccount current)
|
||||
(xaccSplitGetAccount split))
|
||||
(accumulate-totals split
|
||||
total-collector total-value
|
||||
debit-collector debit-value
|
||||
@ -659,24 +662,18 @@
|
||||
;; ----------------------------------
|
||||
;; add the splits to the table
|
||||
;; ----------------------------------
|
||||
;; The general journal has a split that doesn't have an account
|
||||
;; set yet (the new entry transaction).
|
||||
;; This split should be skipped or the report errors out.
|
||||
;; See bug #639082
|
||||
(if valid-split?
|
||||
(add-split-row table current used-columns
|
||||
current-row-style #t (not multi-rows?)
|
||||
action-for-num? ledger-type?
|
||||
double? (opt-val "Display" "Memo")
|
||||
(opt-val "Display" "Description")
|
||||
total-collector))
|
||||
(if (and multi-rows? valid-split?)
|
||||
total-collector)
|
||||
(if multi-rows?
|
||||
(add-other-split-rows current table used-columns
|
||||
"alternate-row" action-for-num?
|
||||
ledger-type? total-collector))
|
||||
|
||||
(loop rest (not odd-row?)))))
|
||||
|
||||
(loop (cdr splits)
|
||||
(not odd-row?))))))
|
||||
table))
|
||||
|
||||
(define (reg-renderer report-obj)
|
||||
|
Loading…
Reference in New Issue
Block a user