Skip to content

Commit

Permalink
[options] compact valid-gains-loss-account?
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Mar 29, 2019
1 parent 79d72fd commit faf1b08
Showing 1 changed file with 12 additions and 29 deletions.
41 changes: 12 additions & 29 deletions libgnucash/app-utils/options.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1449,36 +1449,19 @@ the option '~a'."))
(currency-lookup currency))

(define (valid-gains-loss-account? book-currency gains-loss-account-guid)
;; xaccAccountLookup returns Account if guid valid otherwise NULL; also must
;; be in book-currency, income or expense, and not placeholder nor hidden
;; xaccAccountLookup returns Account if guid valid otherwise NULL; also must
;; be in book-currency, income or expense, and not placeholder nor hidden
(let* ((account (xaccAccountLookup gains-loss-account-guid
(gnc-get-current-book)))
(hidden? (if account
(xaccAccountIsHidden account)
#t))
(placeholder? (if account
(xaccAccountGetPlaceholder account)
#t))
(account-type (if account
(xaccAccountGetType account)
#f))
(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)))
(gnc-get-current-book))))
(and account
(not (null? account))
(not (xaccAccountIsHidden account))
(not (xaccAccountGetPlaceholder account))
(memv (xaccAccountGetType account)
(list ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE))
(gnc-commodity-equal
(currency-lookup book-currency)
(xaccAccountGetCommodity account)))))

(let* ((value (if (eq? 'book-currency default-radiobutton-value)
(cons default-radiobutton-value
Expand Down

0 comments on commit faf1b08

Please sign in to comment.