[trep-engine] move currency options into their own section

tidier, also includes backward compatibility with saved-reports
This commit is contained in:
Christopher Lam 2020-12-02 18:36:37 +08:00
parent a8bed43dcb
commit 854c117820
2 changed files with 31 additions and 23 deletions

View File

@ -76,12 +76,15 @@
;;General ;;General
(define optname-startdate (N_ "Start Date")) (define optname-startdate (N_ "Start Date"))
(define optname-enddate (N_ "End Date")) (define optname-enddate (N_ "End Date"))
(define optname-price-source (N_ "Price Source"))
(define optname-table-export (N_ "Table for Exporting")) (define optname-table-export (N_ "Table for Exporting"))
(define optname-infobox-display (N_ "Add options summary"))
;; Currency
(define pagename-currency (N_ "Currency"))
(define optname-price-source (N_ "Price Source"))
(define optname-common-currency (N_ "Common Currency")) (define optname-common-currency (N_ "Common Currency"))
(define optname-orig-currency (N_ "Show original currency amount")) (define optname-orig-currency (N_ "Show original currency amount"))
(define optname-currency (N_ "Report's currency")) (define optname-currency (N_ "Report's currency"))
(define optname-infobox-display (N_ "Add options summary"))
;;Filtering ;;Filtering
(define pagename-filter (N_ "Filter")) (define pagename-filter (N_ "Filter"))
@ -537,25 +540,26 @@ Credit Card, and Income accounts."))
(gnc:register-trep-option (gnc:register-trep-option
(gnc:make-complex-boolean-option (gnc:make-complex-boolean-option
gnc:pagename-general optname-common-currency pagename-currency optname-common-currency
"e" (G_ "Convert all transactions into a common currency.") #f "a" (G_ "Convert all transactions into a common currency.") #f #f
#f
(lambda (x) (lambda (x)
(gnc-option-db-set-option-selectable-by-name (gnc-option-db-set-option-selectable-by-name
options gnc:pagename-general optname-currency x) options pagename-currency optname-currency x)
(gnc-option-db-set-option-selectable-by-name (gnc-option-db-set-option-selectable-by-name
options gnc:pagename-general optname-orig-currency x)))) options pagename-currency optname-orig-currency x)
(gnc-option-db-set-option-selectable-by-name
(gnc:options-add-price-source! options pagename-currency optname-price-source x))))
options gnc:pagename-general optname-price-source "e5" 'pricedb-nearest)
(gnc:options-add-currency!
options gnc:pagename-general optname-currency "f")
(gnc:register-trep-option (gnc:register-trep-option
(gnc:make-simple-boolean-option (gnc:make-simple-boolean-option
gnc:pagename-general optname-orig-currency pagename-currency optname-orig-currency
"f1" (G_ "Also show original currency amounts") #f)) "b" (G_ "Also show original currency amounts") #f))
(gnc:options-add-currency!
options pagename-currency optname-currency "c")
(gnc:options-add-price-source!
options pagename-currency optname-price-source "d" 'pricedb-nearest)
(gnc:register-trep-option (gnc:register-trep-option
(gnc:make-simple-boolean-option (gnc:make-simple-boolean-option
@ -1084,10 +1088,10 @@ be excluded from periodic reporting.")
(cons 'link (opt-val gnc:pagename-display (N_ "Link"))) (cons 'link (opt-val gnc:pagename-display (N_ "Link")))
(cons 'amount-single (eq? amount-setting 'single)) (cons 'amount-single (eq? amount-setting 'single))
(cons 'amount-double (eq? amount-setting 'double)) (cons 'amount-double (eq? amount-setting 'double))
(cons 'common-currency (opt-val gnc:pagename-general optname-common-currency)) (cons 'common-currency (opt-val pagename-currency optname-common-currency))
(cons 'amount-original-currency (cons 'amount-original-currency
(and (opt-val gnc:pagename-general optname-common-currency) (and (opt-val pagename-currency optname-common-currency)
(opt-val gnc:pagename-general optname-orig-currency))) (opt-val pagename-currency optname-orig-currency)))
(cons 'indenting (opt-val pagename-sorting optname-indenting)) (cons 'indenting (opt-val pagename-sorting optname-indenting))
(cons 'subtotals-only (cons 'subtotals-only
(and (opt-val pagename-sorting optname-show-subtotals-only) (and (opt-val pagename-sorting optname-show-subtotals-only)
@ -1154,8 +1158,8 @@ be excluded from periodic reporting.")
(define exchange-fn (define exchange-fn
(if (column-uses? 'common-currency) (if (column-uses? 'common-currency)
(gnc:case-exchange-time-fn (gnc:case-exchange-time-fn
(opt-val gnc:pagename-general optname-price-source) (opt-val pagename-currency optname-price-source)
(opt-val gnc:pagename-general optname-currency) (opt-val pagename-currency optname-currency)
(gnc:accounts-get-commodities c_account_1 #f) enddate #f #f) (gnc:accounts-get-commodities c_account_1 #f) enddate #f #f)
gnc:exchange-by-pricedb-nearest)) gnc:exchange-by-pricedb-nearest))
@ -1300,7 +1304,7 @@ be excluded from periodic reporting.")
(xaccSplitGetAmount s)))) (xaccSplitGetAmount s))))
(split-currency (compose xaccAccountGetCommodity xaccSplitGetAccount)) (split-currency (compose xaccAccountGetCommodity xaccSplitGetAccount))
(row-currency (lambda (s) (if (column-uses? 'common-currency) (row-currency (lambda (s) (if (column-uses? 'common-currency)
(opt-val gnc:pagename-general optname-currency) (opt-val pagename-currency optname-currency)
(split-currency s)))) (split-currency s))))
(friendly-debit (lambda (a) (gnc-account-get-debit-string (xaccAccountGetType a)))) (friendly-debit (lambda (a) (gnc-account-get-debit-string (xaccAccountGetType a))))
(friendly-credit (lambda (a) (gnc-account-get-credit-string (xaccAccountGetType a)))) (friendly-credit (lambda (a) (gnc-account-get-credit-string (xaccAccountGetType a))))
@ -1310,7 +1314,7 @@ be excluded from periodic reporting.")
(if (column-uses? 'common-currency) (if (column-uses? 'common-currency)
(format #f " (~a)" (format #f " (~a)"
(gnc-commodity-get-mnemonic (gnc-commodity-get-mnemonic
(opt-val gnc:pagename-general (opt-val pagename-currency
optname-currency))) optname-currency)))
"")))) ""))))
;; For conversion to row-currency. Use midday as the ;; For conversion to row-currency. Use midday as the

View File

@ -1681,6 +1681,10 @@ the option '~a'."))
("Void Transactions" "Filter" "Void Transactions") ("Void Transactions" "Filter" "Void Transactions")
("Account Substring" "Filter" "Account Name Filter") ("Account Substring" "Filter" "Account Name Filter")
("Enable links" #f "Enable Links") ("Enable links" #f "Enable Links")
;; trep-engine: moved currency options to own tab
("Common Currency" "Currency" "Common Currency")
("Show original currency amount" "Currency" "Show original currency amount")
("Report's currency" "Currency" "Report's currency")
;; new-owner-report.scm, renamed Oct 2020 to differentiate with ;; new-owner-report.scm, renamed Oct 2020 to differentiate with
;; Document Links: ;; Document Links:
("Links" #f "Transaction Links") ("Links" #f "Transaction Links")
@ -1708,7 +1712,7 @@ the option '~a'."))
(and name-match (and name-match
(let ((new-section (car name-match)) (let ((new-section (car name-match))
(new-name (cadr name-match))) (new-name (cadr name-match)))
(gnc:debug (gnc:warn
(format #f "option ~a/~a has been renamed to ~a/~a\n" (format #f "option ~a/~a has been renamed to ~a/~a\n"
section name new-section new-name)) section name new-section new-name))
(cond (cond