[options] compact valid-gains-loss-account?

This commit is contained in:
Christopher Lam 2019-03-28 11:48:41 +08:00
parent 79d72fdc33
commit faf1b08cec

View File

@ -1449,36 +1449,19 @@ the option '~a'."))
(currency-lookup currency)) (currency-lookup currency))
(define (valid-gains-loss-account? book-currency gains-loss-account-guid) (define (valid-gains-loss-account? book-currency gains-loss-account-guid)
;; xaccAccountLookup returns Account if guid valid otherwise NULL; also must ;; xaccAccountLookup returns Account if guid valid otherwise NULL; also must
;; be in book-currency, income or expense, and not placeholder nor hidden ;; be in book-currency, income or expense, and not placeholder nor hidden
(let* ((account (xaccAccountLookup gains-loss-account-guid (let* ((account (xaccAccountLookup gains-loss-account-guid
(gnc-get-current-book))) (gnc-get-current-book))))
(hidden? (if account (and account
(xaccAccountIsHidden account) (not (null? account))
#t)) (not (xaccAccountIsHidden account))
(placeholder? (if account (not (xaccAccountGetPlaceholder account))
(xaccAccountGetPlaceholder account) (memv (xaccAccountGetType account)
#t)) (list ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE))
(account-type (if account (gnc-commodity-equal
(xaccAccountGetType account) (currency-lookup book-currency)
#f)) (xaccAccountGetCommodity account)))))
(income-or-expense? (if (and account account-type)
(or (= ACCT-TYPE-INCOME account-type)
(= ACCT-TYPE-EXPENSE account-type))
#f))
(commodity-eq-book-curr? (if account
(gnc-commodity-equal
(currency-lookup book-currency)
(xaccAccountGetCommodity account))
#f))
)
(if (and account
(not hidden?)
(not placeholder?)
income-or-expense?
commodity-eq-book-curr?)
#t
#f)))
(let* ((value (if (eq? 'book-currency default-radiobutton-value) (let* ((value (if (eq? 'book-currency default-radiobutton-value)
(cons default-radiobutton-value (cons default-radiobutton-value