TR: (simplify) dynamically check CUSTOM-SORTING?

Instead of a list needing manual adjustments, this function will check
if sortkey requires custom sorter, depending on sortkey capabilities.
This commit is contained in:
Christopher Lam 2018-05-01 20:41:38 +08:00
parent 6210b80fd0
commit b95fa5ba8c

View File

@ -116,8 +116,6 @@ in the Options panel."))
(define ACCOUNT-SORTING-TYPES (list 'account-name 'corresponding-acc-name
'account-code 'corresponding-acc-code))
(define CUSTOM-SORTING (list 'reconciled-status))
(define SORTKEY-INFORMAL-HEADERS (list 'account-name 'account-code))
(define sortkey-list
@ -398,6 +396,16 @@ Credit Card, and Income accounts."))
;; it checks whether a renderer-fn is defined.
(keylist-get-info sortkey-list sortkey 'renderer-fn))
(define (CUSTOM-SORTING? sortkey)
;; sortkey -> bool
;;
;; this returns which sortkeys which *must* use the custom sorter.
;; it filters whereby a split-sortvalue is defined (i.e. the splits
;; can be compared according to their 'sortvalue) but the QofQuery
;; sortkey is not defined (i.e. their 'sortkey is #f).
(and (keylist-get-info sortkey-list sortkey 'split-sortvalue)
(not (keylist-get-info sortkey-list sortkey 'sortkey))))
;;
;; Set defaults for reconcilation report
;;
@ -1771,8 +1779,8 @@ tags within description, notes or memo. ")
(not (eq? primary-date-subtotal 'none))) ; until qof-query
(and (member secondary-key DATE-SORTING-TYPES) ; is upgraded
(not (eq? secondary-date-subtotal 'none)))
(or (member primary-key CUSTOM-SORTING)
(member secondary-key CUSTOM-SORTING))))
(or (CUSTOM-SORTING? primary-key)
(CUSTOM-SORTING? secondary-key))))
(infobox-display (opt-val gnc:pagename-general optname-infobox-display))
(query (qof-query-create-for-splits)))