[register] simplify splits-leader

They were using complicated algorithm to get the split account.  Also
change leader output from account/null to account/#f.

It is simpler to return #f if there is no 'leader'
This commit is contained in:
Christopher Lam 2019-02-22 22:40:23 +08:00
parent 27c0ab490a
commit a23b945a11

View File

@ -511,7 +511,7 @@
(define (display-subtotal monetary)
(if single-col
(if (and (not (null? leader)) (gnc-reverse-balance leader))
(if (and leader (gnc-reverse-balance leader))
(gnc:monetary-neg monetary)
monetary)
(if (gnc-numeric-negative-p (gnc:gnc-monetary-amount monetary))
@ -573,12 +573,10 @@
(define (splits-leader splits)
(let ((accounts (map xaccSplitGetAccount splits)))
(if (null? accounts) '()
(begin
(set! accounts (cons (car accounts)
(delete (car accounts) (cdr accounts))))
(if (not (null? (cdr accounts))) '()
(car accounts))))))
(and (pair? accounts)
(apply equal? accounts)
(car accounts))))
;; ----------------------------------
;; make the split table
;; ----------------------------------