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