ENH: Add sortkey Reconciled Status

Can be useful for reconcilation report.
This commit is contained in:
Christopher Lam 2017-11-30 17:04:58 +08:00
parent 3de3d3cc9a
commit 408f609a58

View File

@ -116,7 +116,12 @@ options specified in the Options panels."))
;; The option-values of the sorting key multichoice option, for ;; The option-values of the sorting key multichoice option, for
;; which a subtotal should be enabled. ;; which a subtotal should be enabled.
(define SUBTOTAL-ENABLED (list 'account-name 'corresponding-acc-name (define SUBTOTAL-ENABLED (list 'account-name 'corresponding-acc-name
'account-code 'corresponding-acc-code)) 'account-code 'corresponding-acc-code
'reconciled-status))
(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-INFORMAL-HEADERS (list 'account-name 'account-code))
@ -132,6 +137,7 @@ options specified in the Options panels."))
;; behaviour varies according to sortkey. ;; behaviour varies according to sortkey.
;; account-types converts split->account ;; account-types converts split->account
;; #f means the sortkey cannot be subtotalled ;; #f means the sortkey cannot be subtotalled
;; otherwise it converts split->string
;; ;;
(list (cons 'account-name (list (cons 'sortkey (list SPLIT-ACCT-FULLNAME)) (list (cons 'account-name (list (cons 'sortkey (list SPLIT-ACCT-FULLNAME))
(cons 'split-sortvalue (lambda (a) (gnc-account-get-full-name (xaccSplitGetAccount a)))) (cons 'split-sortvalue (lambda (a) (gnc-account-get-full-name (xaccSplitGetAccount a))))
@ -157,6 +163,19 @@ options specified in the Options panels."))
(cons 'tip (_ "Sort by the Reconciled Date.")) (cons 'tip (_ "Sort by the Reconciled Date."))
(cons 'renderer-fn #f))) (cons 'renderer-fn #f)))
(cons 'reconciled-status (list (cons 'sortkey #f)
(cons 'split-sortvalue (lambda (s) (length (memq (xaccSplitGetReconcile s)
'(#\n #\c #\y #\f #\v)))))
(cons 'text (_ "Reconciled Status"))
(cons 'tip (_ "Sort by the Reconciled Status"))
(cons 'renderer-fn (lambda (s) (case (xaccSplitGetReconcile s)
((#\y) (_ "Reconciled"))
((#\c) (_ "Cleared"))
((#\n) (_ "Unreconciled"))
((#\f) (_ "Frozen"))
((#\v) (_ "Voided"))
(else (_ "Unknown")))))))
(cons 'register-order (list (cons 'sortkey (list QUERY-DEFAULT-SORT)) (cons 'register-order (list (cons 'sortkey (list QUERY-DEFAULT-SORT))
(cons 'split-sortvalue #f) (cons 'split-sortvalue #f)
(cons 'text (_ "Register Order")) (cons 'text (_ "Register Order"))
@ -1262,6 +1281,10 @@ tags within description, notes or memo. ")
description) description)
name))) name)))
;; generic renderer. retrieve renderer-fn which should return a str
(define (render-generic sortkey split)
((keylist-get-info sortkey-list sortkey 'renderer-fn) split))
(define (render-summary split level anchor?) (define (render-summary split level anchor?)
(let ((sortkey (opt-val pagename-sorting (let ((sortkey (opt-val pagename-sorting
(case level (case level
@ -1271,9 +1294,13 @@ tags within description, notes or memo. ")
(case level (case level
((primary) optname-prime-date-subtotal) ((primary) optname-prime-date-subtotal)
((secondary) optname-sec-date-subtotal))))) ((secondary) optname-sec-date-subtotal)))))
(if (member sortkey DATE-SORTING-TYPES) (cond
(render-date date-subtotal-key split) ((member sortkey DATE-SORTING-TYPES)
(render-account sortkey split anchor?)))) (render-date date-subtotal-key split))
((member sortkey ACCOUNT-SORTING-TYPES)
(render-account sortkey split anchor?))
((eq? sortkey 'reconciled-status)
(render-generic sortkey split)))))
(define (render-grand-total) (define (render-grand-total)
(_ "Grand Total")) (_ "Grand Total"))
@ -1538,7 +1565,9 @@ tags within description, notes or memo. ")
(custom-sort? (or (and (member primary-key DATE-SORTING-TYPES) ; this will remain (custom-sort? (or (and (member primary-key DATE-SORTING-TYPES) ; this will remain
(not (eq? primary-date-subtotal 'none))) ; until qof-query (not (eq? primary-date-subtotal 'none))) ; until qof-query
(and (member secondary-key DATE-SORTING-TYPES) ; is upgraded (and (member secondary-key DATE-SORTING-TYPES) ; is upgraded
(not (eq? secondary-date-subtotal 'none))))) (not (eq? secondary-date-subtotal 'none)))
(or (member primary-key CUSTOM-SORTING)
(member secondary-key CUSTOM-SORTING))))
(infobox-display (opt-val gnc:pagename-general optname-infobox-display)) (infobox-display (opt-val gnc:pagename-general optname-infobox-display))
(query (qof-query-create-for-splits))) (query (qof-query-create-for-splits)))
@ -1560,6 +1589,8 @@ tags within description, notes or memo. ")
((account-code) (lambda (s) (xaccAccountGetCode (xaccSplitGetAccount s)))) ((account-code) (lambda (s) (xaccAccountGetCode (xaccSplitGetAccount s))))
((corresponding-acc-name) (lambda (s) (xaccSplitGetCorrAccountFullName s))) ((corresponding-acc-name) (lambda (s) (xaccSplitGetCorrAccountFullName s)))
((corresponding-acc-code) (lambda (s) (xaccSplitGetCorrAccountCode s))) ((corresponding-acc-code) (lambda (s) (xaccSplitGetCorrAccountCode s)))
((reconciled-status) (lambda (s) (length (memq (xaccSplitGetReconcile s)
'(#\n #\c #\y #\f #\v)))))
((amount) (lambda (s) (gnc-numeric-to-double (xaccSplitGetValue s)))) ((amount) (lambda (s) (gnc-numeric-to-double (xaccSplitGetValue s))))
((description) (lambda (s) (xaccTransGetDescription (xaccSplitGetParent s)))) ((description) (lambda (s) (xaccTransGetDescription (xaccSplitGetParent s))))
((number) (lambda (s) ((number) (lambda (s)