REFACTOR: centralize BOOK-SPLIT-ACTION

Centralize BOOK-SPLIT-ACTION
This commit is contained in:
Christopher Lam 2017-12-10 10:13:40 +08:00
parent 070c99c1c2
commit e1ba5f3248

View File

@ -109,7 +109,6 @@ options specified in the Options panels."))
(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))
(define (add-subheading-row data table width subheading-style) (define (add-subheading-row data table width subheading-style)
(let ((heading-cell (gnc:make-html-table-cell data))) (let ((heading-cell (gnc:make-html-table-cell data)))
(gnc:html-table-cell-set-colspan! heading-cell width) (gnc:html-table-cell-set-colspan! heading-cell width)
@ -360,7 +359,7 @@ options specified in the Options panels."))
(cons 'subheading-renderer #f) (cons 'subheading-renderer #f)
(cons 'subtotal-renderer #f))) (cons 'subtotal-renderer #f)))
(if BOOK-SPLIT-ACTION (if (qof-book-use-split-action-for-num-field (gnc-get-current-book))
(cons 'number (list (cons 'sortkey (list SPLIT-ACTION)) (cons 'number (list (cons 'sortkey (list SPLIT-ACTION))
(cons 'split-sortvalue #f) (cons 'split-sortvalue #f)
(cons 'text (N_ "Number/Action")) (cons 'text (N_ "Number/Action"))
@ -604,7 +603,7 @@ options specified in the Options panels."))
(define (trep-options-generator) (define (trep-options-generator)
(define options (gnc:new-options)) (define options (gnc:new-options))
(define BOOK-SPLIT-ACTION (qof-book-use-split-action-for-num-field (gnc-get-current-book)))
(define (gnc:register-trep-option new-option) (define (gnc:register-trep-option new-option)
(gnc:register-option options new-option)) (gnc:register-option options new-option))
@ -914,7 +913,7 @@ tags within description, notes or memo. ")
(list (list
(list (N_ "Date") "a" (N_ "Display the date?") #t) (list (N_ "Date") "a" (N_ "Display the date?") #t)
(list (N_ "Reconciled Date") "a2" (N_ "Display the reconciled date?") #f) (list (N_ "Reconciled Date") "a2" (N_ "Display the reconciled date?") #f)
(if (qof-book-use-split-action-for-num-field (gnc-get-current-book)) (if BOOK-SPLIT-ACTION
(list (N_ "Num/Action") "b" (N_ "Display the check number?") #t) (list (N_ "Num/Action") "b" (N_ "Display the check number?") #t)
(list (N_ "Num") "b" (N_ "Display the check number?") #t)) (list (N_ "Num") "b" (N_ "Display the check number?") #t))
(list (N_ "Description") "c" (N_ "Display the description?") #t) (list (N_ "Description") "c" (N_ "Display the description?") #t)
@ -931,7 +930,7 @@ tags within description, notes or memo. ")
(list (N_ "Running Balance") "n" (N_ "Display a running balance?") #f) (list (N_ "Running Balance") "n" (N_ "Display a running balance?") #f)
(list (N_ "Totals") "o" (N_ "Display the totals?") #t))) (list (N_ "Totals") "o" (N_ "Display the totals?") #t)))
(if (qof-book-use-split-action-for-num-field (gnc-get-current-book)) (if BOOK-SPLIT-ACTION
(gnc:register-trep-option (gnc:register-trep-option
(gnc:make-simple-boolean-option (gnc:make-simple-boolean-option
gnc:pagename-display (N_ "Trans Number") gnc:pagename-display (N_ "Trans Number")
@ -1025,15 +1024,16 @@ Credit Card, and Income accounts."))))))
secondary-subtotal-renderer) secondary-subtotal-renderer)
(define (opt-val section name) (gnc:option-value (gnc:lookup-option options section name))) (define (opt-val section name) (gnc:option-value (gnc:lookup-option options section name)))
(define BOOK-SPLIT-ACTION (qof-book-use-split-action-for-num-field (gnc-get-current-book)))
(define (build-columns-used) (define (build-columns-used)
(define is-single? (eq? (opt-val gnc:pagename-display optname-detail-level) 'single)) (define is-single? (eq? (opt-val gnc:pagename-display optname-detail-level) 'single))
(define amount-setting (opt-val gnc:pagename-display (N_ "Amount"))) (define amount-setting (opt-val gnc:pagename-display (N_ "Amount")))
(list (cons 'date (opt-val gnc:pagename-display (N_ "Date"))) (list (cons 'date (opt-val gnc:pagename-display (N_ "Date")))
(cons 'reconciled-date (opt-val gnc:pagename-display (N_ "Reconciled Date"))) (cons 'reconciled-date (opt-val gnc:pagename-display (N_ "Reconciled Date")))
(cons 'num (if (gnc:lookup-option options gnc:pagename-display (N_ "Num")) (cons 'num (if BOOK-SPLIT-ACTION
(opt-val gnc:pagename-display (N_ "Num")) (opt-val gnc:pagename-display (N_ "Num/Action"))
(opt-val gnc:pagename-display (N_ "Num/Action")))) (opt-val gnc:pagename-display (N_ "Num"))))
(cons 'description (opt-val gnc:pagename-display (N_ "Description"))) (cons 'description (opt-val gnc:pagename-display (N_ "Description")))
(cons 'account-name (opt-val gnc:pagename-display (N_ "Account Name"))) (cons 'account-name (opt-val gnc:pagename-display (N_ "Account Name")))
(cons 'other-account-name (and is-single? (cons 'other-account-name (and is-single?
@ -1297,6 +1297,7 @@ Credit Card, and Income accounts."))))))
(define (trep-renderer report-obj) (define (trep-renderer report-obj)
(define options (gnc:report-options report-obj)) (define options (gnc:report-options report-obj))
(define (opt-val section name) (gnc:option-value (gnc:lookup-option options section name))) (define (opt-val section name) (gnc:option-value (gnc:lookup-option options section name)))
(define BOOK-SPLIT-ACTION (qof-book-use-split-action-for-num-field (gnc-get-current-book)))
(define (subtotal-get-info name-sortkey name-subtotal name-date-subtotal info) (define (subtotal-get-info name-sortkey name-subtotal name-date-subtotal info)
;; The value of the sorting-key multichoice option. ;; The value of the sorting-key multichoice option.