[c++options] Convert remaining reports and tests to new API.

This commit is contained in:
John Ralls 2022-12-23 10:01:52 -08:00
parent cec27308d8
commit 40c55899bc
42 changed files with 1257 additions and 1815 deletions

View File

@ -82,7 +82,7 @@
(define-public (gnc:color-option->hex-string opt) (define-public (gnc:color-option->hex-string opt)
(format #f "~a" (GncOption-get-value opt))) (format #f "~a" (GncOption-get-value opt)))
(define-public (gnc:option-get-value book category key) (define-public (gnc:book-get-option-value book category key)
(define acc (if (pair? key) cons list)) (define acc (if (pair? key) cons list))
(qof-book-get-option book (acc category key))) (qof-book-get-option book (acc category key)))
@ -408,11 +408,11 @@
(define (gnc:company-info book key) (define (gnc:company-info book key)
;; Access company info from key-value pairs for current book ;; Access company info from key-value pairs for current book
(gnc:option-get-value book gnc:*business-label* key)) (gnc:book-get-option-value book gnc:*business-label* key))
(define (gnc:fancy-date-info book key) (define (gnc:fancy-date-info book key)
;; Access fancy date info from key-value pairs for current book ;; Access fancy date info from key-value pairs for current book
(gnc:option-get-value book gnc:*business-label* (list gnc:*fancy-date-label* key))) (gnc:book-get-option-value book gnc:*business-label* (list gnc:*fancy-date-label* key)))

View File

@ -52,91 +52,78 @@
;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;
(define (options-generator) (define (options-generator)
(let* ((options (gnc:new-options)) (let ((options (gnc-new-optiondb)))
;; register a configuration option for the report
(register-option
(lambda (new-option)
(gnc:register-option options new-option))))
;; General tab ;; General tab
(gnc:options-add-date-interval! (gnc:options-add-date-interval!
options gnc:pagename-general optname-from-date optname-to-date "a") options gnc:pagename-general optname-from-date optname-to-date "a")
(gnc:options-add-interval-choice! (gnc:options-add-interval-choice!
options gnc:pagename-general optname-stepsize "b" 'MonthDelta) options gnc:pagename-general optname-stepsize "b" 'MonthDelta)
;; Report's currency ;; Report's currency
(gnc:options-add-currency! (gnc:options-add-currency!
options gnc:pagename-general optname-report-currency "c") options gnc:pagename-general optname-report-currency "c")
(gnc:options-add-price-source! (gnc:options-add-price-source!
options gnc:pagename-general options gnc:pagename-general
optname-price-source "d" 'weighted-average) optname-price-source "d" 'weighted-average)
;; Account tab ;; Account tab
(register-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-accounts optname-subacct gnc:pagename-accounts optname-subacct
"a" (N_ "Include sub-accounts of all selected accounts.") #t)) "a" (N_ "Include sub-accounts of all selected accounts.") #t)
(register-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-accounts optname-internal gnc:pagename-accounts optname-internal
"b" "b"
(N_ "Exclude transactions that only involve two accounts, both of which are selected below. This only affects the profit and loss columns of the table.") (N_ "Exclude transactions that only involve two accounts, both of which are selected below. This only affects the profit and loss columns of the table.")
#f)) #f)
;; account(s) to do report on ;; account(s) to do report on
(register-option (gnc-register-account-list-option options
(gnc:make-account-list-option
gnc:pagename-accounts (N_ "Accounts") gnc:pagename-accounts (N_ "Accounts")
"c" (N_ "Do transaction report on this account.") "c" (N_ "Do transaction report on this account.")
(lambda () (let ((current-accounts '()))
;; FIXME : gnc:get-current-accounts disappeared ;; If some accounts were selected, use those
(let ((current-accounts '())) (cond ((not (null? current-accounts))
;; If some accounts were selected, use those current-accounts)
(cond ((not (null? current-accounts)) (else
current-accounts) ;; otherwise get some accounts -- here as an
(else ;; example we get the asset and liability stuff
;; otherwise get some accounts -- here as an (gnc-account-list-from-types (gnc-get-current-book)
;; example we get the asset and liability stuff (list ACCT-TYPE-BANK ACCT-TYPE-CASH ACCT-TYPE-CREDIT
(gnc:filter-accountlist-type ACCT-TYPE-ASSET ACCT-TYPE-LIABILITY
(list ACCT-TYPE-BANK ACCT-TYPE-CASH ACCT-TYPE-CREDIT ACCT-TYPE-PAYABLE ACCT-TYPE-RECEIVABLE)
ACCT-TYPE-ASSET ACCT-TYPE-LIABILITY ;; or: (list ACCT-TYPE-BANK ACCT-TYPE-CASH
ACCT-TYPE-PAYABLE ACCT-TYPE-RECEIVABLE) ;; ACCT-TYPE-CHECKING ACCT-TYPE-SAVINGS ACCT-TYPE-STOCK
;; or: (list ACCT-TYPE-BANK ACCT-TYPE-CASH ;; ACCT-TYPE-MUTUAL ACCT-TYPE-MONEYMRKT)
;; ACCT-TYPE-CHECKING ACCT-TYPE-SAVINGS ACCT-TYPE-STOCK )))))
;; ACCT-TYPE-MUTUAL ACCT-TYPE-MONEYMRKT)
(gnc-account-get-children-sorted (gnc-get-current-root-account)))))))
#f #t))
;; Display tab ;; Display tab
(register-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display (N_ "Show table") gnc:pagename-display (N_ "Show table")
"a" (N_ "Display a table of the selected data.") #f)) "a" (N_ "Display a table of the selected data.") #f)
(register-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display (N_ "Show plot") gnc:pagename-display (N_ "Show plot")
"b" (N_ "Display a graph of the selected data.") #t)) "b" (N_ "Display a graph of the selected data.") #t)
(register-option (gnc-register-list-option options
(gnc:make-list-option
gnc:pagename-display (N_ "Plot Type") gnc:pagename-display (N_ "Plot Type")
"c" (N_ "The type of graph to generate.") (list 'AvgBalPlot) "c" (N_ "The type of graph to generate.") "AvgBalPlot"
(list (list
(vector 'AvgBalPlot (N_ "Average")) (vector 'AvgBalPlot (N_ "Average"))
(vector 'GainPlot (N_ "Profit")) (vector 'GainPlot (N_ "Profit"))
(vector 'GLPlot (N_ "Gain/Loss"))))) (vector 'GLPlot (N_ "Gain/Loss"))))
(gnc:options-add-plot-size! (gnc:options-add-plot-size!
options gnc:pagename-display options gnc:pagename-display
optname-plot-width optname-plot-height "d" (cons 'percent 100.0) (cons 'percent 100.0)) optname-plot-width optname-plot-height "d" (cons 'percent 100.0) (cons 'percent 100.0))
;; Set the general page as default option tab ;; Set the general page as default option tab
(gnc:options-set-default-section options gnc:pagename-general) (GncOptionDBPtr-set-default-section options gnc:pagename-general)
options)) options))
;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;
@ -273,8 +260,7 @@
(define (renderer report-obj) (define (renderer report-obj)
(define (get-option section name) (define (get-option section name)
(gnc:option-value (gnc-optiondb-lookup-value (gnc:report-options report-obj) section name))
(gnc:lookup-option (gnc:report-options report-obj) section name)))
(gnc:report-starting reportname) (gnc:report-starting reportname)
(let* ((report-title (get-option gnc:pagename-general (let* ((report-title (get-option gnc:pagename-general

View File

@ -66,47 +66,35 @@
;; is the list of account types that the account selection option ;; is the list of account types that the account selection option
;; accepts. ;; accepts.
(define (options-generator account-types) (define (options-generator account-types)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb)))
(add-option
(lambda (new-option)
(gnc:register-option options new-option))))
(gnc:options-add-date-interval! (gnc:options-add-date-interval!
options gnc:pagename-general options gnc:pagename-general
optname-from-date optname-to-date "a") optname-from-date optname-to-date "a")
(gnc:options-add-currency! (gnc:options-add-currency!
options gnc:pagename-general optname-report-currency "b") options gnc:pagename-general optname-report-currency "b")
(gnc:options-add-price-source! (gnc:options-add-price-source!
options gnc:pagename-general options gnc:pagename-general
optname-price-source "c" 'weighted-average) optname-price-source "c" 'weighted-average)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-accounts optname-subacct gnc:pagename-accounts optname-subacct
"a" (N_ "Include sub-accounts of all selected accounts.") #t)) "a" (N_ "Include sub-accounts of all selected accounts.") #t)
(add-option (gnc-register-account-list-limited-option options
(gnc:make-account-list-option
gnc:pagename-accounts optname-accounts gnc:pagename-accounts optname-accounts
"a" "a"
(N_ "Report on these accounts, if chosen account level allows.") (N_ "Report on these accounts, if chosen account level allows.")
(lambda () (gnc:filter-accountlist-type
(gnc:filter-accountlist-type account-types
account-types (gnc-account-get-descendants-sorted (gnc-get-current-root-account)))
(gnc-account-get-descendants-sorted (gnc-get-current-root-account)))) account-types)
(lambda (accounts)
(list #t
(gnc:filter-accountlist-type
account-types
accounts)))
#t))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-total gnc:pagename-display optname-show-total
"b" (N_ "Show the total balance in legend?") #t)) "b" (N_ "Show the total balance in legend?") #t)
(gnc:options-add-plot-size! (gnc:options-add-plot-size!
options gnc:pagename-display options gnc:pagename-display
@ -126,9 +114,8 @@
account-types) account-types)
;; This is a helper function for looking up option values. ;; This is a helper function for looking up option values.
(define (get-option section name) (define (get-option section name)
(gnc:option-value (gnc-optiondb-lookup-value
(gnc:lookup-option (gnc:report-options report-obj) section name))
(gnc:report-options report-obj) section name)))
(gnc:report-starting reportname) (gnc:report-starting reportname)

View File

@ -37,14 +37,10 @@
;; This function will generate a set of options that GnuCash ;; This function will generate a set of options that GnuCash
;; will use to display a dialog where the user can select ;; will use to display a dialog where the user can select
;; values for your report's parameters. ;; values for your report's parameters.
(define (options-generator) (define (options-generator)
(let* ((options (gnc:new-options)) (let* ((options (gnc:new-options))
;; This is just a helper function for making options. (optiondb (options #t))) ;; Hack to get the optiondb from options
;; See libgnucash/app-utils/options.scm for details.
(add-option
(lambda (new-option)
(gnc:register-option options new-option))))
;; This is a boolean option. It is in Section 'Hello, World!' ;; This is a boolean option. It is in Section 'Hello, World!'
;; and is named 'Boolean Option'. Its sorting key is 'a', ;; and is named 'Boolean Option'. Its sorting key is 'a',
;; thus it will come before options with sorting keys ;; thus it will come before options with sorting keys
@ -52,155 +48,123 @@
;; is #t (true). The phrase 'This is a boolean option' ;; is #t (true). The phrase 'This is a boolean option'
;; will be displayed as help text when the user puts ;; will be displayed as help text when the user puts
;; the mouse pointer over the option. ;; the mouse pointer over the option.
(add-option (gnc-register-simple-boolean-option optiondb
(gnc:make-simple-boolean-option (N_ "Hello, World!") (N_ "Boolean Option")
(N_ "Hello, World!") (N_ "Boolean Option") "a" (N_ "This is a boolean option.") #t)
"a" (N_ "This is a boolean option.") #t))
;; This is a multichoice option. The user can choose between the
;; This is a multichoice option. The user can choose between ;; values 'first, 'second, 'third, or 'fourth. These are guile
;; the values 'first, 'second, 'third, or 'fourth. These are guile ;; symbols. The value 'first will be displayed as "First Option".
;; symbols. The value 'first will be displayed as "First Option" ;; The default value is 'third. Note that multichoice option is a
;; and have a help string of "Help for first option.". The default ;; special case where we need an intermediate scheme function to
;; value is 'third. ;; interpret the default value--'third in this case--because it
(add-option ;; can be either a symbol or a number.
(gnc:make-multichoice-option (gnc-register-multichoice-option optiondb
(N_ "Hello, World!") (N_ "Multi Choice Option") (N_ "Hello, World!") (N_ "Multi Choice Option")
"b" (N_ "This is a multi choice option.") 'third "b" (N_ "This is a multi choice option.") "third"
(list (vector 'first (N_ "First Option")) (list (vector 'first (N_ "First Option"))
(vector 'second (N_ "Second Option")) (vector 'second (N_ "Second Option"))
(vector 'third (N_ "Third Option")) (vector 'third (N_ "Third Option"))
(vector 'fourth (N_ "Fourth Options"))))) (vector 'fourth (N_ "Fourth Options"))))
;; This is a string option. Users can type anything they want ;; This is a string option. Users can type anything they want
;; as a value. The default value is "Hello, World". This is ;; as a value. The default value is "Hello, World". This is
;; in the same section as the option above. It will be shown ;; in the same section as the option above. It will be shown
;; after the option above because its key is 'b' while the ;; after the option above because its key is 'b' while the
;; other key is 'a'. ;; other key is 'a'.
(add-option (gnc-register-string-option optiondb
(gnc:make-string-option
(N_ "Hello, World!") (N_ "String Option") (N_ "Hello, World!") (N_ "String Option")
"c" (N_ "This is a string option.") (N_ "Hello, World"))) "c" (N_ "This is a string option.") (N_ "Hello, World"))
;; This is a date/time option. The user can pick a date and, ;; The following are date options. There are three here reflecting
;; possibly, a time. Times are stored as an integer specifying ;; the trhee types of date controls that can be displayed in the
;; number of seconds measured from Jan 1, 1970, i.e., ;; options dialog: Absolute, Relative, or Both. You'll usually
;; Unix time. The last option is false, so the user can only ;; want to use Both, which is the middle example. Other than the
;; select a date, not a time. The default value is the current ;; usual strings the two paramters are a list of relative date
;; time. ;; types and a boolean to indicate whether you want a Both date
(add-option ;; control. Note that to get an absolute control you pass a
(gnc:make-date-option ;; one-item list containing 'absolute and #f. If you pass (list
;; 'absolute) #t you'll get a Both but the relative listbox will
;; be empty. That will irritate users so avoid doing that.
(gnc-register-date-option-set optiondb
(N_ "Hello, World!") (N_ "Just a Date Option") (N_ "Hello, World!") (N_ "Just a Date Option")
"d" (N_ "This is a date option.") "d" (N_ "This is a date option.")
(lambda () (cons 'absolute (current-time))) (list 'absolute) #f )
#f 'absolute #f ))
(gnc-register-date-option-set optiondb
(add-option
(gnc:make-date-option
(N_ "Hello, World!") (N_ "Combo Date Option") (N_ "Hello, World!") (N_ "Combo Date Option")
"y" (N_ "This is a combination date option.") "y" (N_ "This is a combination date option.")
(lambda () (cons 'relative 'start-cal-year)) '(start-cal-year start-prev-year end-prev-year) #t)
#f 'both '(start-cal-year start-prev-year end-prev-year) ))
(gnc-register-date-option-set optiondb
(add-option
(gnc:make-date-option
(N_ "Hello, World!") (N_ "Relative Date Option") (N_ "Hello, World!") (N_ "Relative Date Option")
"x" (N_ "This is a relative date option.") "x" (N_ "This is a relative date option.")
(lambda () (cons 'relative 'start-cal-year)) '(start-cal-year start-prev-year end-prev-year) #f)
#f 'relative '(start-cal-year start-prev-year end-prev-year) ))
;; This is a number range option. The user can enter a number ;; This is a number range option. The user can enter a number
;; between a lower and upper bound given below. There are also ;; between a lower and upper bound given below. There are also
;; arrows the user can click to go up or down, the amount changed ;; arrows or + and - buttons depending on the icon theme that the
;; by a single click is given by the step size. ;; user can click to go up or down, the amount changed by a single
(add-option ;; click is given by the step size.
(gnc:make-number-range-option (gnc-register-number-range-option optiondb
(N_ "Hello, World!") (N_ "Number Option") (N_ "Hello, World!") (N_ "Number Option")
"ee" (N_ "This is a number option.") "ee" (N_ "This is a number option.")
1500.0 ;; default 1500.0 ;; default
0.0 ;; lower bound 0.0 ;; lower bound
10000.0 ;; upper bound 10000.0 ;; upper bound
2.0 ;; number of decimals
0.01 ;; step size 0.01 ;; step size
)) )
;; This is a color option, defined by rgba values. A color value ;; This is a color option, defined by rgb values. A color value is
;; is a list where the elements are the red, green, blue, and ;; a string representing a 3-byte hex number with the bytes
;; alpha channel values respectively. The penultimate argument ;; representing red, blue, and green values.
;; (255) is the allowed range of rgba values. The final argument (gnc-register-color-option optiondb
;; (#f) indicates the alpha value should be ignored. You can get
;; a color string from a color option with gnc:color-option->html,
;; which will scale the values appropriately according the range.
(add-option
(gnc:make-color-option
(N_ "Hello, World!") (N_ "Background Color") (N_ "Hello, World!") (N_ "Background Color")
"f" (N_ "This is a color option.") "f" (N_ "This is a color option.")
(list #xf6 #xff #xdb #xff) "f6ffdb")
255
#f)) ;; This is an account list option. The user can select one or more
;; accounts from the list of accounts in the current file. Values
;; This is an account list option. The user can select one ;; are GUIDs of the selected accounts. Since those depend on the
;; or (possibly) more accounts from the list of accounts ;; book in use you'll probably want to create a list from the
;; in the current file. Values are scheme handles to actual ;; account types as we've done here. There's another function
;; C pointers to accounts. ;; gnc-register-account-list-limited-option which takes as a
;; The #f value indicates that any account will be accepted. ;; second argument a list of account types; only accounts of the
;; Instead of a #f values, you could provide a function that ;; types in the list, similar to the list passed to
;; accepts a list of account values and returns a pair. If ;; gnc-account-list-from-types in this example, will be available
;; the first element is #t, the second element is the list ;; for selection.
;; of accounts actually accepted. If the first element is
;; #f, the accounts are rejected and the second element is (gnc-register-account-list-option optiondb
;; and error string. The last argument is #t which means
;; the user is allowed to select more than one account.
;; The default value for this option is the currently
;; selected account in the main window, if any.
(add-option
(gnc:make-account-list-option
(N_ "Hello Again") (N_ "An account list option") (N_ "Hello Again") (N_ "An account list option")
"g" (N_ "This is an account list option.") "g" (N_ "This is an account list option.")
;; FIXME : this used to be gnc:get-current-accounts, but (gnc-account-list-from-types
;; that doesn't exist any more. (gnc-get-current-book)
(lambda () '()) (list ACCT-TYPE-ASSET ACCT-TYPE-EQUITY ACCT-TYPE-LIABILITY)))
#f #t))
;; This is a list option. The user can select one or (possibly) ;; This is a list option. The user can select one or (possibly)
;; more values from a list. The list of acceptable values is ;; more values from a list. The list of acceptable values is
;; the same format as a multichoice option. The value of the ;; the same format as a multichoice option. The value of the
;; option is a list of symbols. ;; option is a list of symbols.
(add-option (gnc-register-list-option optiondb
(gnc:make-list-option
(N_ "Hello Again") (N_ "A list option") (N_ "Hello Again") (N_ "A list option")
"h" (N_ "This is a list option.") "h" (N_ "This is a list option.")
'(good) (symbol->string 'good)
(list (vector 'good (N_ "The Good")) (list (vector 'good (N_ "The Good"))
(vector 'bad (N_ "The Bad")) (vector 'bad (N_ "The Bad"))
(vector 'ugly (N_ "The Ugly"))))) (vector 'ugly (N_ "The Ugly"))))
;; This option is for testing. When true, the report generates ;; This option is for testing. When true, the report generates
;; an exception. ;; an exception.
(add-option (gnc-register-simple-boolean-option optiondb
(gnc:make-simple-boolean-option
(N_ "Testing") (N_ "Crash the report") (N_ "Testing") (N_ "Crash the report")
"a" "a"
(N_ "This is for testing. \ (N_ "This is for testing. \
Your reports probably shouldn't have an \ Your reports probably shouldn't have an \
option like this.") option like this.")
#f)) #f)
;; This is a Radio Button option. The user can only select one (GncOptionDBPtr-set-default-section optiondb "Hello, World!")
;; value from the list of buttons. ;; We still need to return the function wrapper instead of the GncOptionDBPtr bfor all of the options functions in the reports system.
(add-option
(gnc:make-radiobutton-option
(N_ "Hello Again") "A Radio Button option" "z" (N_ "This is a Radio Button option.") 'good
(list (vector 'good
(N_ "The Good")
(N_ "Good option."))
(vector 'bad
(N_ "The Bad")
(N_ "Bad option."))
(vector 'ugly
(N_ "The Ugly")
(N_ "Ugly option.")))))
(gnc:options-set-default-section options "Hello, World!")
options)) options))
;; This is the rendering function. It accepts a database of options ;; This is the rendering function. It accepts a database of options
@ -210,12 +174,10 @@ option like this.")
;; to the function is one created by the options-generator function ;; to the function is one created by the options-generator function
;; defined above. ;; defined above.
(define (hello-world-renderer report-obj) (define (hello-world-renderer report-obj)
;; These are some helper functions for looking up option values. ;; Helper function for looking up option values.
(define (get-op section name)
(gnc:lookup-option (gnc:report-options report-obj) section name))
(define (op-value section name) (define (op-value section name)
(gnc:option-value (get-op section name))) (gnc-optiondb-lookup-value ((gnc:report-options report-obj) 'lookup)
section name))
;; The first thing we do is make local variables for all the specific ;; The first thing we do is make local variables for all the specific
;; options in the set of options given to the function. This set will ;; options in the set of options given to the function. This set will
@ -230,7 +192,7 @@ option like this.")
(combo-date-val (gnc:date-option-absolute-time (combo-date-val (gnc:date-option-absolute-time
(op-value "Hello, World!" "Combo Date Option"))) (op-value "Hello, World!" "Combo Date Option")))
(num-val (op-value "Hello, World!" "Number Option")) (num-val (op-value "Hello, World!" "Number Option"))
(bg-color-op (get-op "Hello, World!" "Background Color")) (bg-color (op-value "Hello, World!" "Background Color"))
(accounts (op-value "Hello Again" "An account list option")) (accounts (op-value "Hello Again" "An account list option"))
(list-val (op-value "Hello Again" "A list option")) (list-val (op-value "Hello Again" "A list option"))
(radio-val (op-value "Hello Again" "A Radio Button option")) (radio-val (op-value "Hello Again" "A Radio Button option"))
@ -287,7 +249,7 @@ option like this.")
(gnc:html-document-set-style! (gnc:html-document-set-style!
document "body" document "body"
'attribute (list "bgcolor" (gnc:color-option->html bg-color-op))) 'attribute (list "bgcolor" (format #f "#~a" bg-color)))
;; the title of the report will be rendered by the ;; the title of the report will be rendered by the
;; selected style sheet. All we have to do is set it in the ;; selected style sheet. All we have to do is set it in the

View File

@ -117,7 +117,7 @@
chart)) chart))
(define (options-generator) (define (options-generator)
(gnc:new-options)) (gnc-new-optiondb))
;; This is the rendering function. It accepts a database of options ;; This is the rendering function. It accepts a database of options
;; and generates an object of type <html-document>. See the file ;; and generates an object of type <html-document>. See the file
@ -126,13 +126,6 @@
;; to the function is one created by the options-generator function ;; to the function is one created by the options-generator function
;; defined above. ;; defined above.
(define (test-graphing-renderer report-obj) (define (test-graphing-renderer report-obj)
;; These are some helper functions for looking up option values.
(define options (gnc:report-options report-obj))
(define (get-op section name)
(gnc:lookup-option options section name))
(define (op-value section name)
(gnc:option-value (get-op section name)))
(let ((document (gnc:make-html-document))) (let ((document (gnc:make-html-document)))
(gnc:html-document-set-title! document (G_ reportname)) (gnc:html-document-set-title! document (G_ reportname))

View File

@ -30,7 +30,7 @@
(use-modules (gnucash report)) (use-modules (gnucash report))
(define (options) (define (options)
(gnc:new-options)) (gnc-new-optiondb))
(define (renderer report-obj) (define (renderer report-obj)
(let ((doc (gnc:make-html-document))) (let ((doc (gnc:make-html-document)))

View File

@ -137,20 +137,17 @@
(define tax-qtr-real-qtr-year 0) (define tax-qtr-real-qtr-year 0)
(define (tax-options-generator) (define (tax-options-generator)
(define options (gnc:new-options)) (define options (gnc-new-optiondb))
(define (gnc:register-tax-option new-option)
(gnc:register-option options new-option))
;; date at which to report ;; date at which to report
(gnc:options-add-date-interval! (gnc:options-add-date-interval!
options gnc:pagename-general options gnc:pagename-general
(N_ "From") (N_ "To") "a") (N_ "From") (N_ "To") "a")
(gnc:register-tax-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
gnc:pagename-general (N_ "Alternate Period") gnc:pagename-general (N_ "Alternate Period")
"c" (N_ "Override or modify From: & To:.") "c" (N_ "Override or modify From: & To:.")
(if after-tax-day 'from-to 'last-year) (if after-tax-day "from-to" "last-year")
(list (vector 'from-to (N_ "Use From - To")) (list (vector 'from-to (N_ "Use From - To"))
(vector '1st-est (N_ "1st Est Tax Quarter (Jan 1 - Mar 31)")) (vector '1st-est (N_ "1st Est Tax Quarter (Jan 1 - Mar 31)"))
(vector '2nd-est (N_ "2nd Est Tax Quarter (Apr 1 - May 31)")) (vector '2nd-est (N_ "2nd Est Tax Quarter (Apr 1 - May 31)"))
@ -160,24 +157,20 @@
(vector '1st-last (N_ "Last Yr 1st Est Tax Qtr (Jan 1 - Mar 31)")) (vector '1st-last (N_ "Last Yr 1st Est Tax Qtr (Jan 1 - Mar 31)"))
(vector '2nd-last (N_ "Last Yr 2nd Est Tax Qtr (Apr 1 - May 31)")) (vector '2nd-last (N_ "Last Yr 2nd Est Tax Qtr (Apr 1 - May 31)"))
(vector '3rd-last (N_ "Last Yr 3rd Est Tax Qtr (Jun 1 - Aug 31)")) (vector '3rd-last (N_ "Last Yr 3rd Est Tax Qtr (Jun 1 - Aug 31)"))
(vector '4th-last (N_ "Last Yr 4th Est Tax Qtr (Sep 1 - Dec 31)"))))) (vector '4th-last (N_ "Last Yr 4th Est Tax Qtr (Sep 1 - Dec 31)"))))
(gnc:register-tax-option (gnc-register-account-list-option options
(gnc:make-account-list-option
gnc:pagename-accounts (N_ "Select Accounts (none = all)") gnc:pagename-accounts (N_ "Select Accounts (none = all)")
"d" (N_ "Select accounts.") "d" (N_ "Select accounts.")
(lambda () '()) '())
#f #t))
(gnc:register-tax-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display (N_ "Suppress $0.00 values") gnc:pagename-display (N_ "Suppress $0.00 values")
"f" (N_ "$0.00 valued Accounts won't be printed.") #t)) "f" (N_ "$0.00 valued Accounts won't be printed.") #t)
(gnc:register-tax-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display (N_ "Print Full account names") gnc:pagename-display (N_ "Print Full account names")
"g" (N_ "Print all Parent account names.") #f)) "g" (N_ "Print all Parent account names.") #f)
(gnc:options-set-default-section options gnc:pagename-general) (gnc:options-set-default-section options gnc:pagename-general)
@ -451,9 +444,8 @@
tax-mode?) tax-mode?)
(define (get-option pagename optname) (define (get-option pagename optname)
(gnc:option-value (gnc-optiondb-lookup-value
(gnc:lookup-option (gnc:report-options report-obj) pagename optname))
(gnc:report-options report-obj) pagename optname)))
;; the number of account generations: children, grandchildren etc. ;; the number of account generations: children, grandchildren etc.
(define (num-generations account gen) (define (num-generations account gen)
@ -748,7 +740,7 @@
(to-year (gnc-print-time64 to-value "%Y")) (to-year (gnc-print-time64 to-value "%Y"))
(today-date (gnc-print-time64 (time64CanonicalDayTime (current-time)) (today-date (gnc-print-time64 (time64CanonicalDayTime (current-time))
"%d.%m.%Y")) "%d.%m.%Y"))
(tax-nr (gnc:option-get-value book gnc:*tax-label* gnc:*tax-nr-label*))) (tax-nr (gnc:book-get-option-value book gnc:*tax-label* gnc:*tax-nr-label*)))
;; Now, the main body ;; Now, the main body
;; Reset all the balance collectors ;; Reset all the balance collectors

View File

@ -167,20 +167,17 @@
(define tax-qtr-real-qtr-year 10000) (define tax-qtr-real-qtr-year 10000)
(define (tax-options-generator) (define (tax-options-generator)
(define options (gnc:new-options)) (define options (gnc-new-optiondb))
(define (gnc:register-tax-option new-option)
(gnc:register-option options new-option))
;; date at which to report ;; date at which to report
(gnc:options-add-date-interval! (gnc:options-add-date-interval!
options gnc:pagename-general options gnc:pagename-general
(N_ "From") (N_ "To") "a") (N_ "From") (N_ "To") "a")
(gnc:register-tax-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
gnc:pagename-general (N_ "Alternate Period") gnc:pagename-general (N_ "Alternate Period")
"c" (N_ "Override or modify From: & To:.") "c" (N_ "Override or modify From: & To:.")
(if after-tax-day 'from-to 'last-year) (if after-tax-day "from-to" "last-year")
(list (vector 'from-to (N_ "Use From - To")) (list (vector 'from-to (N_ "Use From - To"))
(vector '1st-est (N_ "1st Est Tax Quarter (Jan 1 - Mar 31)")) (vector '1st-est (N_ "1st Est Tax Quarter (Jan 1 - Mar 31)"))
(vector '2nd-est (N_ "2nd Est Tax Quarter (Apr 1 - May 31)")) (vector '2nd-est (N_ "2nd Est Tax Quarter (Apr 1 - May 31)"))
@ -196,65 +193,53 @@
;; actual year's quarters! See the definition of ;; actual year's quarters! See the definition of
;; tax-qtr-real-qtr-year variable above. ;; tax-qtr-real-qtr-year variable above.
(vector '3rd-last (N_ "Last Yr 3rd Est Tax Qtr (Jun 1 - Aug 31)")) (vector '3rd-last (N_ "Last Yr 3rd Est Tax Qtr (Jun 1 - Aug 31)"))
(vector '4th-last (N_ "Last Yr 4th Est Tax Qtr (Sep 1 - Dec 31)"))))) (vector '4th-last (N_ "Last Yr 4th Est Tax Qtr (Sep 1 - Dec 31)"))))
(gnc:register-tax-option (gnc-register-account-list-option options
(gnc:make-account-list-option
gnc:pagename-accounts (N_ "Select Accounts (none = all)") gnc:pagename-accounts (N_ "Select Accounts (none = all)")
"d" (N_ "Select accounts.") "d" (N_ "Select accounts.")
(lambda () '()) '())
#f #t)) (gnc-register-simple-boolean-option options
(gnc:register-tax-option
(gnc:make-simple-boolean-option
gnc:pagename-display (N_ "Suppress $0.00 values") gnc:pagename-display (N_ "Suppress $0.00 values")
"f" (N_ "$0.00 valued Tax codes won't be printed.") #f)) "f" (N_ "$0.00 valued Tax codes won't be printed.") #f)
(gnc:register-tax-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display (N_ "Do not print full account names") gnc:pagename-display (N_ "Do not print full account names")
"g" (N_ "Do not print all Parent account names.") #f)) "g" (N_ "Do not print all Parent account names.") #f)
(gnc:register-tax-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display (N_ "Print all Transfer To/From Accounts") gnc:pagename-display (N_ "Print all Transfer To/From Accounts")
"h" (N_ "Print all split details for multi-split transactions.") #f)) "h" (N_ "Print all split details for multi-split transactions.") #f)
(gnc:register-tax-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display (N_ "Print TXF export parameters") gnc:pagename-display (N_ "Print TXF export parameters")
"i" (N_ "Show TXF export parameters for each TXF code/account on report.") #f)) "i" (N_ "Show TXF export parameters for each TXF code/account on report.") #f)
(if (qof-book-use-split-action-for-num-field (gnc-get-current-book)) (if (qof-book-use-split-action-for-num-field (gnc-get-current-book))
(gnc:register-tax-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display (N_ "Do not print T-Num:Memo data") gnc:pagename-display (N_ "Do not print T-Num:Memo data")
"j" (N_ "Do not print T-Num:Memo data for transactions.") #f)) "j" (N_ "Do not print T-Num:Memo data for transactions.") #f)
(gnc:register-tax-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display (N_ "Do not print Action:Memo data") gnc:pagename-display (N_ "Do not print Action:Memo data")
"j" (N_ "Do not print Action:Memo data for transactions.") #f))) "j" (N_ "Do not print Action:Memo data for transactions.") #f))
(gnc:register-tax-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display (N_ "Do not print transaction detail") gnc:pagename-display (N_ "Do not print transaction detail")
"k" (N_ "Do not print transaction detail for accounts.") #f)) "k" (N_ "Do not print transaction detail for accounts.") #f)
(gnc:register-tax-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display (N_ "Do not use special date processing") gnc:pagename-display (N_ "Do not use special date processing")
"l" (N_ "Do not print transactions out of specified dates.") #f)) "l" (N_ "Do not print transactions out of specified dates.") #f)
(gnc:register-tax-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
gnc:pagename-display (N_ "Currency conversion date") gnc:pagename-display (N_ "Currency conversion date")
"m" (N_ "Select date to use for PriceDB lookups.") "m" (N_ "Select date to use for PriceDB lookups.")
'conv-to-tran-date "conv-to-tran-date"
(list (list->vector (list (list->vector
(list 'conv-to-tran-date (N_ "Nearest to transaction date"))) (list 'conv-to-tran-date (N_ "Nearest to transaction date")))
(list->vector (list->vector
(list 'conv-to-report-date (N_ "Nearest to report date"))) (list 'conv-to-report-date (N_ "Nearest to report date")))
))) ))
#t #t
@ -1658,9 +1643,8 @@
tax-mode?) tax-mode?)
(define (get-option pagename optname) (define (get-option pagename optname)
(gnc:option-value (gnc-optiondb-lookup-value
(gnc:lookup-option (gnc:report-options report-obj) pagename optname))
(gnc:report-options report-obj) pagename optname)))
(define tax-entity-type (gnc-get-current-book-tax-type)) (define tax-entity-type (gnc-get-current-book-tax-type))

View File

@ -85,10 +85,7 @@ balance at a given time"))
;; is the list of account types that the account selection option ;; is the list of account types that the account selection option
;; accepts. ;; accepts.
(define (options-generator account-types do-intervals? depth-based?) (define (options-generator account-types do-intervals? depth-based?)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb)))
(add-option
(lambda (new-option)
(gnc:register-option options new-option))))
(if do-intervals? (if do-intervals?
(gnc:options-add-date-interval! (gnc:options-add-date-interval!
@ -98,39 +95,31 @@ balance at a given time"))
options gnc:pagename-general options gnc:pagename-general
optname-to-date "a")) optname-to-date "a"))
(gnc:options-add-currency! (gnc:options-add-currency!
options gnc:pagename-general optname-report-currency "b") options gnc:pagename-general optname-report-currency "b")
(gnc:options-add-price-source! (gnc:options-add-price-source!
options gnc:pagename-general options gnc:pagename-general
optname-price-source "c" 'pricedb-nearest) optname-price-source "c" 'pricedb-nearest)
(if do-intervals? (if do-intervals?
(add-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
gnc:pagename-general optname-averaging gnc:pagename-general optname-averaging
"f" opthelp-averaging "f" opthelp-averaging
'None "None"
(list (vector 'None (N_ "No Averaging")) (list (vector 'None (N_ "No Averaging"))
(vector 'YearDelta (N_ "Yearly")) (vector 'YearDelta (N_ "Yearly"))
(vector 'MonthDelta (N_ "Monthly")) (vector 'MonthDelta (N_ "Monthly"))
(vector 'WeekDelta (N_ "Weekly")))))) (vector 'WeekDelta (N_ "Weekly")))))
(add-option (gnc-register-account-list-limited-option options
(gnc:make-account-list-option
gnc:pagename-accounts optname-accounts gnc:pagename-accounts optname-accounts
"a" "a"
(N_ "Report on these accounts, if chosen account level allows.") (N_ "Report on these accounts, if chosen account level allows.")
(lambda () (gnc:filter-accountlist-type
(gnc:filter-accountlist-type account-types
account-types (gnc-account-get-descendants-sorted (gnc-get-current-root-account)))
(gnc-account-get-descendants-sorted (gnc-get-current-root-account)))) account-types)
(lambda (accounts)
(list #t
(gnc:filter-accountlist-type
account-types
accounts)))
#t))
(if depth-based? (if depth-based?
(gnc:options-add-account-levels! (gnc:options-add-account-levels!
@ -138,38 +127,34 @@ balance at a given time"))
(N_ "Maximum number of levels in the account tree displayed.") (N_ "Maximum number of levels in the account tree displayed.")
2)) 2))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-fullname gnc:pagename-display optname-fullname
"a" "a"
(if depth-based? (if depth-based?
(N_ "Show the full account name in legend?") (N_ "Show the full account name in legend?")
(N_ "Show the full security name in the legend?")) (N_ "Show the full security name in the legend?"))
#f)) #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-total gnc:pagename-display optname-show-total
"b" (N_ "Show the total balance in legend?") #t)) "b" (N_ "Show the total balance in legend?") #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-percent gnc:pagename-display optname-show-percent
"b" (N_ "Show the percentage in legend?") #t)) "b" (N_ "Show the percentage in legend?") #t)
(add-option (gnc-register-number-range-option options
(gnc:make-number-range-option
gnc:pagename-display optname-slices gnc:pagename-display optname-slices
"c" (N_ "Maximum number of slices in pie.") 7 "c" (N_ "Maximum number of slices in pie.") 7
2 24 0 1)) 2 24 1)
(gnc:options-add-plot-size! (gnc:options-add-plot-size!
options gnc:pagename-display options gnc:pagename-display
optname-plot-width optname-plot-height "d" (cons 'percent 100.0) (cons 'percent 100.0)) optname-plot-width optname-plot-height "d" (cons 'percent 100.0) (cons 'percent 100.0))
(gnc:options-add-sort-method! (gnc:options-add-sort-method!
options gnc:pagename-display options gnc:pagename-display
optname-sort-method "e" 'amount) optname-sort-method "e" 'amount)
@ -307,10 +292,9 @@ balance at a given time"))
;; This is a helper function for looking up option values. ;; This is a helper function for looking up option values.
(define (get-option section name) (define (get-option section name)
(gnc:option-value (gnc-optiondb-lookup-value
(gnc:lookup-option (gnc:report-options report-obj) section name))
(gnc:report-options report-obj) section name)))
(gnc:report-starting reportname) (gnc:report-starting reportname)
;; Get all options ;; Get all options
@ -478,9 +462,8 @@ balance at a given time"))
(gnc:options-copy-values (gnc:report-options report-obj) (gnc:options-copy-values (gnc:report-options report-obj)
options) options)
;; and set the destination accounts ;; and set the destination accounts
(gnc:option-set-value (gnc-option-set-value
(gnc:lookup-option options gnc:pagename-accounts options gnc:pagename-accounts optname-accounts
optname-accounts)
(map cadr finish)) (map cadr finish))
(set! id (gnc:make-report report-guid options)) (set! id (gnc:make-report report-guid options))
;; set the URL. ;; set the URL.

View File

@ -142,13 +142,12 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (accsum-options-generator sx? reportname) (define (accsum-options-generator sx? reportname)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb)))
(odb (gnc:optiondb options)))
(gnc-register-string-option odb (gnc-register-string-option options
gnc:pagename-general optname-report-title gnc:pagename-general optname-report-title
"a" opthelp-report-title (G_ reportname)) "a" opthelp-report-title (G_ reportname))
(gnc-register-string-option odb (gnc-register-string-option options
gnc:pagename-general optname-party-name gnc:pagename-general optname-party-name
"b" opthelp-party-name "") "b" opthelp-party-name "")
;; this should default to company name in (gnc-get-current-book) ;; this should default to company name in (gnc-get-current-book)
@ -163,7 +162,7 @@
options gnc:pagename-general optname-date "c")) options gnc:pagename-general optname-date "c"))
;; accounts to work on ;; accounts to work on
(gnc-register-account-list-option odb (gnc-register-account-list-option options
gnc:pagename-accounts optname-accounts gnc:pagename-accounts optname-accounts
"a" "a"
opthelp-accounts opthelp-accounts
@ -179,7 +178,7 @@
options gnc:pagename-accounts optname-depth-limit options gnc:pagename-accounts optname-depth-limit
"b" opthelp-depth-limit 3) "b" opthelp-depth-limit 3)
(gnc-register-multichoice-option odb (gnc-register-multichoice-option options
gnc:pagename-accounts optname-bottom-behavior gnc:pagename-accounts optname-bottom-behavior
"c" opthelp-bottom-behavior "summarize" "c" opthelp-bottom-behavior "summarize"
(list (list
@ -196,19 +195,19 @@
options pagename-commodities options pagename-commodities
optname-price-source "b" 'pricedb-nearest) optname-price-source "b" 'pricedb-nearest)
(gnc-register-simple-boolean-option odb (gnc-register-simple-boolean-option options
pagename-commodities optname-show-foreign pagename-commodities optname-show-foreign
"c" opthelp-show-foreign #t) "c" opthelp-show-foreign #t)
(gnc-register-simple-boolean-option odb (gnc-register-simple-boolean-option options
pagename-commodities optname-show-rates pagename-commodities optname-show-rates
"d" opthelp-show-rates #f) "d" opthelp-show-rates #f)
;; what to show for zero-balance accounts ;; what to show for zero-balance accounts
(gnc-register-simple-boolean-option odb (gnc-register-simple-boolean-option options
gnc:pagename-display optname-show-zb-accts gnc:pagename-display optname-show-zb-accts
"a" opthelp-show-zb-accts #t) "a" opthelp-show-zb-accts #t)
(gnc-register-simple-boolean-option odb (gnc-register-simple-boolean-option options
gnc:pagename-display optname-omit-zb-bals gnc:pagename-display optname-omit-zb-bals
"b" opthelp-omit-zb-bals #f) "b" opthelp-omit-zb-bals #f)
;; what to show for non-leaf accounts ;; what to show for non-leaf accounts
@ -218,26 +217,26 @@
"c") "c")
;; some detailed formatting options ;; some detailed formatting options
(gnc-register-simple-boolean-option odb (gnc-register-simple-boolean-option options
gnc:pagename-display optname-account-links gnc:pagename-display optname-account-links
"e" opthelp-account-links #t) "e" opthelp-account-links #t)
(gnc-register-simple-boolean-option odb (gnc-register-simple-boolean-option options
gnc:pagename-display optname-use-rules gnc:pagename-display optname-use-rules
"f" opthelp-use-rules #f) "f" opthelp-use-rules #f)
(gnc-register-simple-boolean-option odb (gnc-register-simple-boolean-option options
gnc:pagename-display optname-show-bals gnc:pagename-display optname-show-bals
"g" opthelp-show-bals #t) "g" opthelp-show-bals #t)
(gnc-register-simple-boolean-option odb (gnc-register-simple-boolean-option options
gnc:pagename-display optname-show-code gnc:pagename-display optname-show-code
"h" opthelp-show-code #t) "h" opthelp-show-code #t)
(gnc-register-simple-boolean-option odb (gnc-register-simple-boolean-option options
gnc:pagename-display optname-show-desc gnc:pagename-display optname-show-desc
"i" opthelp-show-desc #f) "i" opthelp-show-desc #f)
(gnc-register-simple-boolean-option odb (gnc-register-simple-boolean-option options
gnc:pagename-display optname-show-type gnc:pagename-display optname-show-type
"j" opthelp-show-type #f) "j" opthelp-show-type #f)
(gnc-register-simple-boolean-option odb (gnc-register-simple-boolean-option options
gnc:pagename-display optname-show-notes gnc:pagename-display optname-show-notes
"k" opthelp-show-notes #f) "k" opthelp-show-notes #f)
@ -252,9 +251,8 @@
(define (accsum-renderer report-obj sx? reportname) (define (accsum-renderer report-obj sx? reportname)
(define (get-option pagename optname) (define (get-option pagename optname)
(gnc:option-value (gnc-optiondb-lookup-value
(gnc:lookup-option (gnc:report-options report-obj) pagename optname))
(gnc:report-options report-obj) pagename optname)))
(gnc:report-starting reportname) (gnc:report-starting reportname)

View File

@ -59,12 +59,7 @@ by preventing negative stock balances.<br/>")
(define units-denom 100000000) (define units-denom 100000000)
(define (options-generator) (define (options-generator)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb)))
;; This is just a helper function for making options.
;; See libgnucash/scm/options.scm for details.
(add-option
(lambda (new-option)
(gnc:register-option options new-option))))
;; General Tab ;; General Tab
;; date at which to report balance ;; date at which to report balance
@ -75,88 +70,71 @@ by preventing negative stock balances.<br/>")
(gnc:options-add-currency! (gnc:options-add-currency!
options gnc:pagename-general (N_ "Report's currency") "c") options gnc:pagename-general (N_ "Report's currency") "c")
(add-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
gnc:pagename-general optname-price-source gnc:pagename-general optname-price-source
"d" (N_ "The source of price information.") 'pricedb-nearest "d" (N_ "The source of price information.") "pricedb-nearest"
(list (vector 'pricedb-latest (N_ "Most recent")) (list (vector 'pricedb-latest (N_ "Most recent"))
(vector 'pricedb-nearest (N_ "Nearest to report date"))))) (vector 'pricedb-nearest (N_ "Nearest to report date"))))
(add-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
gnc:pagename-general optname-basis-method gnc:pagename-general optname-basis-method
"e" (N_ "Basis calculation method.") 'average-basis "e" (N_ "Basis calculation method.") "average-basis"
(list (vector 'average-basis (N_ "Average cost of all shares")) (list (vector 'average-basis (N_ "Average cost of all shares"))
(vector 'fifo-basis (N_ "First-in first-out")) (vector 'fifo-basis (N_ "First-in first-out"))
(vector 'filo-basis (N_ "Last-in first-out"))))) (vector 'filo-basis (N_ "Last-in first-out"))))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-general optname-prefer-pricelist "f" gnc:pagename-general optname-prefer-pricelist "f"
(N_ "Prefer use of price editor pricing over transactions, where applicable.") (N_ "Prefer use of price editor pricing over transactions, where applicable.")
#t)) #t)
(add-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
gnc:pagename-general optname-brokerage-fees gnc:pagename-general optname-brokerage-fees
"g" (N_ "How to report commissions and other brokerage fees.") 'include-in-basis "g" (N_ "How to report commissions and other brokerage fees.")
"include-in-basis"
(list (vector 'include-in-basis (N_ "Include in basis")) (list (vector 'include-in-basis (N_ "Include in basis"))
(vector 'include-in-gain (N_ "Include in gain/loss")) (vector 'include-in-gain (N_ "Include in gain/loss"))
(vector 'ignore-brokerage (N_ "Omit from report"))))) (vector 'ignore-brokerage (N_ "Omit from report"))))
(gnc:register-option (gnc-register-simple-boolean-option options
options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-symbol "a" gnc:pagename-display optname-show-symbol "a"
(N_ "Display the ticker symbols.") (N_ "Display the ticker symbols.")
#t)) #t)
(gnc:register-option (gnc-register-simple-boolean-option options
options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-listing "b" gnc:pagename-display optname-show-listing "b"
(N_ "Display exchange listings.") (N_ "Display exchange listings.")
#t)) #t)
(gnc:register-option (gnc-register-simple-boolean-option options
options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-shares "c" gnc:pagename-display optname-show-shares "c"
(N_ "Display numbers of shares in accounts.") (N_ "Display numbers of shares in accounts.")
#t)) #t)
(add-option (gnc-register-number-range-option options
(gnc:make-number-range-option
gnc:pagename-display optname-shares-digits gnc:pagename-display optname-shares-digits
"d" (N_ "The number of decimal places to use for share numbers.") 2 "d" (N_ "The number of decimal places to use for share numbers.") 2
0 9 0 1)) 0 9 1)
(gnc:register-option (gnc-register-simple-boolean-option options
options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-price "e" gnc:pagename-display optname-show-price "e"
(N_ "Display share prices.") (N_ "Display share prices.")
#t)) #t)
;; Account tab ;; Account tab
(add-option (gnc-register-account-list-limited-option options
(gnc:make-account-list-option
gnc:pagename-accounts (N_ "Accounts") gnc:pagename-accounts (N_ "Accounts")
"b" "b"
(N_ "Stock Accounts to report on.") (N_ "Stock Accounts to report on.")
(lambda () (filter gnc:account-is-stock? (filter gnc:account-is-stock?
(gnc-account-get-descendants-sorted (gnc-account-get-descendants-sorted
(gnc-get-current-root-account)))) (gnc-get-current-root-account)))
(lambda (accounts) (list #t (list ACCT-TYPE-STOCK))
(filter gnc:account-is-stock? accounts)))
#t))
(gnc:register-option (gnc-register-simple-boolean-option options
options
(gnc:make-simple-boolean-option
gnc:pagename-accounts optname-zero-shares "e" gnc:pagename-accounts optname-zero-shares "e"
(N_ "Include accounts that have a zero share balances.") (N_ "Include accounts that have a zero share balances.")
#f)) #f)
(gnc:options-set-default-section options gnc:pagename-general) (gnc:options-set-default-section options gnc:pagename-general)
options)) options))
@ -176,11 +154,8 @@ by preventing negative stock balances.<br/>")
(warn-price-dirty #f)) (warn-price-dirty #f))
;; These are some helper functions for looking up option values. ;; These are some helper functions for looking up option values.
(define (get-op section name)
(gnc:lookup-option (gnc:report-options report-obj) section name))
(define (get-option section name) (define (get-option section name)
(gnc:option-value (get-op section name))) (gnc-optiondb-lookup-value (gnc:report-options report-obj) section name))
(define (split-account-type? split type) (define (split-account-type? split type)
(eq? type (xaccAccountGetType (xaccSplitGetAccount split)))) (eq? type (xaccAccountGetType (xaccSplitGetAccount split))))

View File

@ -70,17 +70,14 @@ date point, a projected minimum balance including scheduled transactions."))
; Options generator ; Options generator
(define (options-generator) (define (options-generator)
(let* ((options (gnc:new-options))) (let* ((options (gnc-new-optiondb)))
; Account selector ; Account selector
(gnc:register-option options (gnc-register-account-list-option options
(gnc:make-account-list-option
gnc:pagename-accounts optname-accounts "a" opthelp-accounts gnc:pagename-accounts optname-accounts "a" opthelp-accounts
(lambda () (gnc:filter-accountlist-type
(gnc:filter-accountlist-type (list ACCT-TYPE-BANK ACCT-TYPE-CASH)
(list ACCT-TYPE-BANK ACCT-TYPE-CASH) (gnc-account-get-descendants-sorted
(gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
(gnc-get-current-root-account))))
#f #t))
; Date range ; Date range
(gnc:options-add-date-interval! options (gnc:options-add-date-interval! options
@ -100,29 +97,29 @@ date point, a projected minimum balance including scheduled transactions."))
optname-plot-width optname-plot-height "a" optname-plot-width optname-plot-height "a"
(cons 'percent 100.0) (cons 'percent 100.0)) (cons 'percent 100.0) (cons 'percent 100.0))
; Markers ; Markers
(gnc:register-option options (gnc:make-simple-boolean-option (gnc-register-simple-boolean-option options
gnc:pagename-display optname-show-markers "b" opthelp-show-markers #f)) gnc:pagename-display optname-show-markers "b" opthelp-show-markers #f)
; Reserve line ; Reserve line
(gnc:register-option options (gnc:make-complex-boolean-option (gnc-register-complex-boolean-option options
gnc:pagename-display optname-show-reserve "c" opthelp-show-reserve #f #f gnc:pagename-display optname-show-reserve "c" opthelp-show-reserve #f
(lambda (x) (lambda (x)
(gnc-option-db-set-option-selectable-by-name (gnc-optiondb-set-option-selectable-by-name
options gnc:pagename-display optname-reserve x)))) options gnc:pagename-display optname-reserve x)))
(gnc:register-option options (gnc:make-number-range-option (gnc-register-number-range-option options
gnc:pagename-display optname-reserve "d" opthelp-reserve gnc:pagename-display optname-reserve "d" opthelp-reserve
0 -10E9 10E9 2 0.01)) 0 -10E9 10E9 0.01)
; Purchasing power target ; Purchasing power target
(gnc:register-option options (gnc:make-complex-boolean-option (gnc-register-complex-boolean-option options
gnc:pagename-display optname-show-target "e" opthelp-show-target #f #f gnc:pagename-display optname-show-target "e" opthelp-show-target #f
(lambda (x) (lambda (x)
(gnc-option-db-set-option-selectable-by-name (gnc-optiondb-set-option-selectable-by-name
options gnc:pagename-display optname-target x)))) options gnc:pagename-display optname-target x)))
(gnc:register-option options (gnc:make-number-range-option (gnc-register-number-range-option options
gnc:pagename-display optname-target "f" opthelp-target gnc:pagename-display optname-target "f" opthelp-target
0 -10E9 10E9 2 0.01)) 0 -10E9 10E9 0.01)
; Future minimum ; Future minimum
(gnc:register-option options (gnc:make-simple-boolean-option (gnc-register-simple-boolean-option options
gnc:pagename-display optname-show-minimum "g" opthelp-show-minimum #f)) gnc:pagename-display optname-show-minimum "g" opthelp-show-minimum #f)
(gnc:options-set-default-section options gnc:pagename-general) (gnc:options-set-default-section options gnc:pagename-general)
options) options)
) )
@ -131,8 +128,8 @@ date point, a projected minimum balance including scheduled transactions."))
(define (document-renderer report-obj) (define (document-renderer report-obj)
; Option-getting helper function. ; Option-getting helper function.
(define (get-option pagename optname) (define (get-option pagename optname)
(gnc:option-value (gnc-optiondb-lookup-value
(gnc:lookup-option (gnc:report-options report-obj) pagename optname))) (gnc:report-options report-obj) pagename optname))
(define report-title (define report-title
(get-option gnc:pagename-general gnc:optname-reportname)) (get-option gnc:pagename-general gnc:optname-reportname))

View File

@ -144,43 +144,34 @@
;; options generator ;; options generator
(define (balance-sheet-options-generator) (define (balance-sheet-options-generator)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb))
(book (gnc-get-current-book)) ; XXX Find a way to get the book that opened the report (book (gnc-get-current-book)))
(add-option
(lambda (new-option) (gnc-register-string-option options
(gnc:register-option options new-option))))
(add-option
(gnc:make-string-option
gnc:pagename-general optname-report-title gnc:pagename-general optname-report-title
"a" opthelp-report-title (G_ reportname))) "a" opthelp-report-title (G_ reportname))
(add-option (gnc-register-string-option options
(gnc:make-string-option
gnc:pagename-general optname-party-name gnc:pagename-general optname-party-name
"b" opthelp-party-name (or (gnc:company-info book gnc:*company-name*) ""))) "b" opthelp-party-name (or (gnc:company-info book gnc:*company-name*) ""))
;; date at which to report balance ;; date at which to report balance
(gnc:options-add-report-date! (gnc:options-add-report-date!
options gnc:pagename-general optname-date "c") options gnc:pagename-general optname-date "c")
(add-option
(gnc:make-simple-boolean-option
gnc:pagename-general optname-report-form
"d" opthelp-report-form #t))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option gnc:pagename-general optname-report-form
"d" opthelp-report-form #t)
(gnc-register-simple-boolean-option options
gnc:pagename-general optname-standard-order gnc:pagename-general optname-standard-order
"dd" opthelp-standard-order #t)) "dd" opthelp-standard-order #t)
;; accounts to work on ;; accounts to work on
(add-option (gnc-register-account-list-option options
(gnc:make-account-list-option
gnc:pagename-accounts optname-accounts gnc:pagename-accounts optname-accounts
"a" "a"
opthelp-accounts opthelp-accounts
(lambda () (gnc:filter-accountlist-type
(gnc:filter-accountlist-type
(list ACCT-TYPE-BANK ACCT-TYPE-CASH ACCT-TYPE-CREDIT (list ACCT-TYPE-BANK ACCT-TYPE-CASH ACCT-TYPE-CREDIT
ACCT-TYPE-ASSET ACCT-TYPE-LIABILITY ACCT-TYPE-ASSET ACCT-TYPE-LIABILITY
ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL ACCT-TYPE-CURRENCY ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL ACCT-TYPE-CURRENCY
@ -188,43 +179,37 @@
ACCT-TYPE-EQUITY ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE ACCT-TYPE-EQUITY ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE
ACCT-TYPE-TRADING) ACCT-TYPE-TRADING)
(gnc-account-get-descendants-sorted (gnc-get-current-root-account)))) (gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
#f #t))
(gnc:options-add-account-levels! (gnc:options-add-account-levels!
options gnc:pagename-accounts optname-depth-limit options gnc:pagename-accounts optname-depth-limit
"b" opthelp-depth-limit 3) "b" opthelp-depth-limit 3)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-accounts optname-bottom-behavior gnc:pagename-accounts optname-bottom-behavior
"c" opthelp-bottom-behavior #f)) "c" opthelp-bottom-behavior #f)
;; all about currencies ;; all about currencies
(gnc:options-add-currency! (gnc:options-add-currency!
options pagename-commodities options pagename-commodities
optname-report-commodity "a") optname-report-commodity "a")
(gnc:options-add-price-source! (gnc:options-add-price-source!
options pagename-commodities options pagename-commodities
optname-price-source "b" 'pricedb-nearest) optname-price-source "b" 'pricedb-nearest)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option pagename-commodities optname-show-foreign
pagename-commodities optname-show-foreign "c" opthelp-show-foreign #t)
"c" opthelp-show-foreign #t))
(gnc-register-simple-boolean-option options
(add-option
(gnc:make-simple-boolean-option
pagename-commodities optname-show-rates pagename-commodities optname-show-rates
"d" opthelp-show-rates #f)) "d" opthelp-show-rates #f)
;; what to show for zero-balance accounts ;; what to show for zero-balance accounts
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-zb-accts gnc:pagename-display optname-show-zb-accts
"a" opthelp-show-zb-accts #t)) "a" opthelp-show-zb-accts #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-omit-zb-bals gnc:pagename-display optname-omit-zb-bals
"b" opthelp-omit-zb-bals #f)) "b" opthelp-omit-zb-bals #f)
;; what to show for non-leaf accounts ;; what to show for non-leaf accounts
(gnc:options-add-subtotal-view! (gnc:options-add-subtotal-view!
options gnc:pagename-display options gnc:pagename-display
@ -232,45 +217,37 @@
"c") "c")
;; some detailed formatting options ;; some detailed formatting options
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-account-links gnc:pagename-display optname-account-links
"e" opthelp-account-links #t)) "e" opthelp-account-links #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-use-rules gnc:pagename-display optname-use-rules
"f" opthelp-use-rules #f)) "f" opthelp-use-rules #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-label-assets gnc:pagename-display optname-label-assets
"g" opthelp-label-assets #t)) "g" opthelp-label-assets #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-total-assets gnc:pagename-display optname-total-assets
"h" opthelp-total-assets #t)) "h" opthelp-total-assets #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-label-liabilities gnc:pagename-display optname-label-liabilities
"i" opthelp-label-liabilities #t)) "i" opthelp-label-liabilities #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-total-liabilities gnc:pagename-display optname-total-liabilities
"j" opthelp-total-liabilities #t)) "j" opthelp-total-liabilities #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-label-equity gnc:pagename-display optname-label-equity
"k" opthelp-label-equity #t)) "k" opthelp-label-equity #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-total-equity gnc:pagename-display optname-total-equity
"l" opthelp-total-equity #t)) "l" opthelp-total-equity #t)
;; Set the accounts page as default option tab ;; Set the accounts page as default option tab
(gnc:options-set-default-section options gnc:pagename-accounts) (gnc:options-set-default-section options gnc:pagename-accounts)
options)) options))
;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -282,9 +259,8 @@
(define (balance-sheet-renderer report-obj) (define (balance-sheet-renderer report-obj)
(define (get-option pagename optname) (define (get-option pagename optname)
(gnc:option-value (gnc-optiondb-lookup-value
(gnc:lookup-option (gnc:report-options report-obj) pagename optname))
(gnc:report-options report-obj) pagename optname)))
(gnc:report-starting reportname) (gnc:report-starting reportname)

View File

@ -189,59 +189,66 @@
;; options generator ;; options generator
(define (balsheet-options-generator) (define (balsheet-options-generator)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb)))
(add-option
(lambda (new-option)
(gnc:register-option options new-option))))
;; Accounts options ;; Accounts options
(add-option (gnc:make-simple-boolean-option accounts-page optname-omit-zb-accts (gnc-register-simple-boolean-option options
"a" opthelp-omit-zb-accts #f)) accounts-page optname-omit-zb-accts
(add-option (gnc:make-simple-boolean-option accounts-page optname-account-links "a" opthelp-omit-zb-accts #f)
"b" opthelp-account-links #t)) (gnc-register-simple-boolean-option options
accounts-page optname-account-links
"b" opthelp-account-links #t)
(gnc:options-add-account-levels! options accounts-page optname-depth-limit (gnc:options-add-account-levels! options accounts-page optname-depth-limit
"c" opthelp-depth-limit 'all) "c" opthelp-depth-limit 'all)
(add-option (gnc:make-simple-boolean-option accounts-page optname-flatten? (gnc-register-simple-boolean-option options
"d" opthelp-flatten? #f)) accounts-page optname-flatten?
"d" opthelp-flatten? #f)
;; Commodity options ;; Commodity options
(gnc:options-add-currency! options commodities-page optname-report-commodity "a") (gnc:options-add-currency! options commodities-page optname-report-commodity "a")
(gnc:options-add-price-source! options commodities-page (gnc:options-add-price-source! options commodities-page
optname-price-source "b" 'average-cost) optname-price-source "b" 'average-cost)
(add-option (gnc:make-simple-boolean-option commodities-page optname-show-foreign (gnc-register-simple-boolean-option options
"c" opthelp-show-foreign #t)) commodities-page optname-show-foreign
"c" opthelp-show-foreign #t)
;; Display options ;; Display options
(add-option (gnc:make-multichoice-option (gnc-register-multichoice-option options
display-page optname-columns display-page optname-columns
"a" opthelp-columns 'onecol "a" opthelp-columns "onecol"
(list (vector 'autocols (N_ "Adjust the layout to fit the width of the screen or page")) (list (vector 'autocols (N_ "Adjust the layout to fit the width of the screen or page"))
(vector 'onecol (N_ "Display liabilities and equity below assets")) (vector 'onecol (N_ "Display liabilities and equity below assets"))
(vector 'twocols (N_ "Display assets on the left, liabilities and equity on the right"))))) (vector 'twocols (N_ "Display assets on the left, liabilities and equity on the right"))))
(add-option (gnc:make-multichoice-option (gnc-register-multichoice-option options
display-page optname-neg-format display-page optname-neg-format
"b" opthelp-neg-format 'negsign "b" opthelp-neg-format "negsign"
(list (vector 'negsign (N_ "Sign: -$10.00")) (list (vector 'negsign (N_ "Sign: -$10.00"))
(vector 'negbrackets (N_ "Brackets: ($10.00)"))))) (vector 'negbrackets (N_ "Brackets: ($10.00)"))))
(add-option (gnc:make-string-option display-page optname-font-family "c" (gnc-register-string-option options
opthelp-font-family "sans")) display-page optname-font-family "c"
(add-option (gnc:make-string-option display-page optname-font-size "d" opthelp-font-family "sans")
opthelp-font-size "medium")) (gnc-register-string-option options
(add-option (gnc:make-string-option display-page optname-template-file "e" display-page optname-font-size "d"
opthelp-template-file "balsheet-eg.eguile.scm")) opthelp-font-size "medium")
(add-option (gnc:make-string-option display-page optname-css-file "f" (gnc-register-string-option options
opthelp-css-file "balsheet-eg.css")) display-page optname-template-file "e"
opthelp-template-file "balsheet-eg.eguile.scm")
(gnc-register-string-option options
display-page optname-css-file "f"
opthelp-css-file "balsheet-eg.css")
;; General options ;; General options
(add-option (gnc:make-string-option general-page optname-report-title (gnc-register-string-option options
"a" opthelp-report-title reportname)) general-page optname-report-title
"a" opthelp-report-title reportname)
(gnc:options-add-report-date! options general-page optname-date "b") (gnc:options-add-report-date! options general-page optname-date "b")
;; Notes options ;; Notes options
(add-option (gnc:make-text-option notes-page optname-extra-notes (gnc-register-text-option options
"a" opthelp-extra-notes notes-page optname-extra-notes
(N_ "(Development version -- don't rely on the numbers on this report without double-checking them.<br>Change the 'Extra Notes' option to get rid of this message)"))) "a" opthelp-extra-notes
(N_ "(Development version -- don't rely on the numbers on this report without double-checking them.<br>Change the 'Extra Notes' option to get rid of this message)"))
;; Set the accounts page as default option tab ;; Set the accounts page as default option tab
(gnc:options-set-default-section options general-page) (gnc:options-set-default-section options general-page)
@ -253,9 +260,8 @@
(define (balsheet-renderer report-obj) (define (balsheet-renderer report-obj)
(define (get-option pagename optname) (define (get-option pagename optname)
(gnc:option-value (gnc-optiondb-lookup-value
(gnc:lookup-option (gnc:report-options report-obj) pagename optname))
(gnc:report-options report-obj) pagename optname)))
(gnc:report-starting reportname) (gnc:report-starting reportname)
(let* ( (let* (

View File

@ -136,20 +136,16 @@ also show overall period profit & loss."))
;; options generator ;; options generator
(define (multicol-report-options-generator report-type) (define (multicol-report-options-generator report-type)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb)))
(add-option
(lambda (new-option)
(gnc:register-option options new-option))))
;; date at which to report balance ;; date at which to report balance
(gnc:options-add-date-interval! (gnc:options-add-date-interval!
options gnc:pagename-general optname-startdate optname-enddate "c") options gnc:pagename-general optname-startdate optname-enddate "c")
(add-option (gnc-register-multichoice-callback-option options
(gnc:make-multichoice-callback-option
gnc:pagename-general optname-period gnc:pagename-general optname-period
"c2" opthelp-period "c2" opthelp-period
'disabled "disabled"
(list (list
(vector 'disabled (G_ "Disabled")) (vector 'disabled (G_ "Disabled"))
(vector 'YearDelta (G_ "One Year")) (vector 'YearDelta (G_ "One Year"))
@ -158,67 +154,59 @@ also show overall period profit & loss."))
(vector 'MonthDelta (G_ "One Month")) (vector 'MonthDelta (G_ "One Month"))
(vector 'TwoWeekDelta (G_ "Two Weeks")) (vector 'TwoWeekDelta (G_ "Two Weeks"))
(vector 'WeekDelta (G_ "One Week"))) (vector 'WeekDelta (G_ "One Week")))
#f
(lambda (x) (lambda (x)
(let ((x (not (eq? x 'disabled)))) (let ((x (not (eq? x 'disabled))))
(gnc-option-db-set-option-selectable-by-name (gnc-optiondb-set-option-selectable-by-name
options options
gnc:pagename-general optname-disable-amount-indent gnc:pagename-general optname-disable-amount-indent
(not x)) (not x))
(gnc-option-db-set-option-selectable-by-name (gnc-optiondb-set-option-selectable-by-name
options options
gnc:pagename-general optname-dual-columns gnc:pagename-general optname-dual-columns
(not x)) (not x))
(gnc-option-db-set-option-selectable-by-name (gnc-optiondb-set-option-selectable-by-name
options gnc:pagename-general optname-reverse-chrono x) options gnc:pagename-general optname-reverse-chrono x)
(case report-type (case report-type
((balsheet) ((balsheet)
(gnc-option-db-set-option-selectable-by-name (gnc-optiondb-set-option-selectable-by-name
options gnc:pagename-general optname-include-chart x) options gnc:pagename-general optname-include-chart x)
(gnc-option-db-set-option-selectable-by-name (gnc-optiondb-set-option-selectable-by-name
options gnc:pagename-general optname-startdate x)) options gnc:pagename-general optname-startdate x))
((pnl) ((pnl)
(gnc-option-db-set-option-selectable-by-name (gnc-optiondb-set-option-selectable-by-name
options gnc:pagename-general optname-include-overall-period x))))))) options gnc:pagename-general optname-include-overall-period x))))))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-general optname-disable-amount-indent gnc:pagename-general optname-disable-amount-indent
"c3" opthelp-disable-amount-indent #f)) "c3" opthelp-disable-amount-indent #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-general optname-include-chart gnc:pagename-general optname-include-chart
"c5" opthelp-include-chart #f)) "c5" opthelp-include-chart #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-general optname-dual-columns gnc:pagename-general optname-dual-columns
"c4" opthelp-dual-columns #t)) "c4" opthelp-dual-columns #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-general optname-reverse-chrono gnc:pagename-general optname-reverse-chrono
"c5" opthelp-reverse-chrono #t)) "c5" opthelp-reverse-chrono #t)
(add-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
gnc:pagename-general optname-options-summary gnc:pagename-general optname-options-summary
"d" opthelp-options-summary "d" opthelp-options-summary
'never "never"
(list (vector 'always (G_ "Always")) (list (vector 'always (G_ "Always"))
(vector 'never (G_ "Never"))))) (vector 'never (G_ "Never"))))
;; accounts to work on ;; accounts to work on
(add-option (gnc-register-account-list-option options
(gnc:make-account-list-option
gnc:pagename-accounts optname-accounts gnc:pagename-accounts optname-accounts
"a" "a"
opthelp-accounts opthelp-accounts
(lambda () (gnc:filter-accountlist-type
(gnc:filter-accountlist-type
(list ACCT-TYPE-BANK ACCT-TYPE-CASH ACCT-TYPE-CREDIT (list ACCT-TYPE-BANK ACCT-TYPE-CASH ACCT-TYPE-CREDIT
ACCT-TYPE-ASSET ACCT-TYPE-LIABILITY ACCT-TYPE-ASSET ACCT-TYPE-LIABILITY
ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL ACCT-TYPE-CURRENCY ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL ACCT-TYPE-CURRENCY
@ -226,7 +214,6 @@ also show overall period profit & loss."))
ACCT-TYPE-EQUITY ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE ACCT-TYPE-EQUITY ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE
ACCT-TYPE-TRADING) ACCT-TYPE-TRADING)
(gnc-account-get-descendants-sorted (gnc-get-current-root-account)))) (gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
#f #t))
;; the depth-limit option is not well debugged; it may be better ;; the depth-limit option is not well debugged; it may be better
;; to disable it altogether ;; to disable it altogether
@ -235,19 +222,18 @@ also show overall period profit & loss."))
"b" opthelp-depth-limit 'all) "b" opthelp-depth-limit 'all)
;; all about currencies ;; all about currencies
(add-option (gnc-register-complex-boolean-option options
(gnc:make-complex-boolean-option
pagename-commodities optname-common-currency pagename-commodities optname-common-currency
"b" opthelp-common-currency #f #f "b" opthelp-common-currency #f
(lambda (x) (lambda (x)
(for-each (for-each
(lambda (optname) (lambda (optname)
(gnc-option-db-set-option-selectable-by-name (gnc-optiondb-set-option-selectable-by-name
options pagename-commodities optname x)) options pagename-commodities optname x))
(list optname-report-commodity (list optname-report-commodity
optname-show-rates optname-show-rates
optname-show-foreign optname-show-foreign
optname-price-source))))) optname-price-source))))
(gnc:options-add-currency! (gnc:options-add-currency!
options pagename-commodities options pagename-commodities
@ -257,62 +243,51 @@ also show overall period profit & loss."))
options pagename-commodities options pagename-commodities
optname-price-source "d" 'pricedb-nearest) optname-price-source "d" 'pricedb-nearest)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-commodities optname-show-foreign pagename-commodities optname-show-foreign
"e" opthelp-show-foreign #t)) "e" opthelp-show-foreign #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-commodities optname-show-rates pagename-commodities optname-show-rates
"f" opthelp-show-rates #t)) "f" opthelp-show-rates #t)
;; what to show for zero-balance accounts ;; what to show for zero-balance accounts
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-zb-accts gnc:pagename-display optname-show-zb-accts
"a" opthelp-show-zb-accts #t)) "a" opthelp-show-zb-accts #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-omit-zb-bals gnc:pagename-display optname-omit-zb-bals
"b" opthelp-omit-zb-bals #f)) "b" opthelp-omit-zb-bals #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-parent-balance-mode gnc:pagename-display optname-parent-balance-mode
"c" opthelp-parent-balance-mode #t)) "c" opthelp-parent-balance-mode #t)
;; some detailed formatting options ;; some detailed formatting options
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-account-links gnc:pagename-display optname-account-links
"e" opthelp-account-links #t)) "e" opthelp-account-links #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-amount-links gnc:pagename-display optname-amount-links
"e5" opthelp-amount-links #t)) "e5" opthelp-amount-links #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-account-full-name gnc:pagename-display optname-account-full-name
"f" opthelp-account-full-name #f)) "f" opthelp-account-full-name #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option gnc:pagename-display optname-label-sections "g" opthelp-label-sections #t)
gnc:pagename-display optname-label-sections "g" opthelp-label-sections #t))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option gnc:pagename-display optname-total-sections "h" opthelp-total-sections #t)
gnc:pagename-display optname-total-sections "h" opthelp-total-sections #t))
(when (eq? report-type 'pnl) (when (eq? report-type 'pnl)
;; include overall period column? ;; include overall period column?
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-general optname-include-overall-period gnc:pagename-general optname-include-overall-period
"c6" opthelp-include-overall-period #f))) "c6" opthelp-include-overall-period #f))
(gnc:options-set-default-section options gnc:pagename-general) (gnc:options-set-default-section options gnc:pagename-general)
@ -651,9 +626,8 @@ also show overall period profit & loss."))
(define (multicol-report-renderer report-obj report-type) (define (multicol-report-renderer report-obj report-type)
(define (get-option pagename optname) (define (get-option pagename optname)
(gnc:option-value (gnc-optiondb-lookup-value
(gnc:lookup-option (gnc:report-options report-obj) pagename optname))
(gnc:report-options report-obj) pagename optname)))
(gnc:report-starting (get-option gnc:pagename-general gnc:optname-reportname)) (gnc:report-starting (get-option gnc:pagename-general gnc:optname-reportname))

View File

@ -113,82 +113,67 @@
;; options generator ;; options generator
(define (budget-balance-sheet-options-generator) (define (budget-balance-sheet-options-generator)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb))
(book (gnc-get-current-book)) ; XXX Find a way to get the book that opened the report (book (gnc-get-current-book)))
(add-option
(lambda (new-option)
(gnc:register-option options new-option))))
(add-option
(gnc:make-string-option
gnc:pagename-general optname-report-title
"a" opthelp-report-title (G_ reportname)))
(add-option
(gnc:make-string-option
gnc:pagename-general optname-party-name
"b" opthelp-party-name (or (gnc:company-info book gnc:*company-name*) "")))
(add-option
(gnc:make-simple-boolean-option
gnc:pagename-general optname-report-form
"c" opthelp-report-form #t))
(add-option (gnc-register-string-option options
(gnc:make-budget-option gnc:pagename-general optname-report-title
"a" opthelp-report-title (G_ reportname))
(gnc-register-string-option options
gnc:pagename-general optname-party-name
"b" opthelp-party-name (or (gnc:company-info book gnc:*company-name*) ""))
(gnc-register-simple-boolean-option options
gnc:pagename-general optname-report-form
"c" opthelp-report-form #t)
(gnc-register-budget-option options
gnc:pagename-general optname-budget gnc:pagename-general optname-budget
"d" opthelp-budget)) "d" opthelp-budget (gnc-budget-get-default book))
;; accounts to work on ;; accounts to work on
(add-option (gnc-register-account-list-option options
(gnc:make-account-list-option
gnc:pagename-accounts optname-accounts gnc:pagename-accounts optname-accounts
"a" "a"
opthelp-accounts opthelp-accounts
(lambda () (gnc:filter-accountlist-type
(gnc:filter-accountlist-type
(list ACCT-TYPE-BANK ACCT-TYPE-CASH ACCT-TYPE-CREDIT (list ACCT-TYPE-BANK ACCT-TYPE-CASH ACCT-TYPE-CREDIT
ACCT-TYPE-ASSET ACCT-TYPE-LIABILITY ACCT-TYPE-ASSET ACCT-TYPE-LIABILITY
ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL ACCT-TYPE-CURRENCY ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL ACCT-TYPE-CURRENCY
ACCT-TYPE-PAYABLE ACCT-TYPE-RECEIVABLE ACCT-TYPE-PAYABLE ACCT-TYPE-RECEIVABLE
ACCT-TYPE-EQUITY ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE) ACCT-TYPE-EQUITY ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE)
(gnc-account-get-descendants-sorted (gnc-get-current-root-account)))) (gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
#f #t))
(gnc:options-add-account-levels! (gnc:options-add-account-levels!
options gnc:pagename-accounts optname-depth-limit options gnc:pagename-accounts optname-depth-limit
"b" opthelp-depth-limit 3) "b" opthelp-depth-limit 3)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-accounts optname-bottom-behavior gnc:pagename-accounts optname-bottom-behavior
"c" opthelp-bottom-behavior #f)) "c" opthelp-bottom-behavior #f)
;; all about currencies ;; all about currencies
(gnc:options-add-currency! (gnc:options-add-currency!
options pagename-commodities options pagename-commodities
optname-report-commodity "a") optname-report-commodity "a")
(gnc:options-add-price-source! (gnc:options-add-price-source!
options pagename-commodities options pagename-commodities
optname-price-source "b" 'pricedb-nearest) optname-price-source "b" 'pricedb-nearest)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-commodities optname-show-foreign pagename-commodities optname-show-foreign
"c" opthelp-show-foreign #t)) "c" opthelp-show-foreign #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-commodities optname-show-rates pagename-commodities optname-show-rates
"d" opthelp-show-rates #f)) "d" opthelp-show-rates #f)
;; what to show for zero-balance accounts ;; what to show for zero-balance accounts
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-zb-accts gnc:pagename-display optname-show-zb-accts
"a" opthelp-show-zb-accts #t)) "a" opthelp-show-zb-accts #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-omit-zb-bals gnc:pagename-display optname-omit-zb-bals
"b" opthelp-omit-zb-bals #f)) "b" opthelp-omit-zb-bals #f)
;; what to show for non-leaf accounts ;; what to show for non-leaf accounts
(gnc:options-add-subtotal-view! (gnc:options-add-subtotal-view!
options gnc:pagename-display options gnc:pagename-display
@ -196,46 +181,37 @@
"c") "c")
;; some detailed formatting options ;; some detailed formatting options
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-account-links gnc:pagename-display optname-account-links
"d" opthelp-account-links #t)) "d" opthelp-account-links #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-use-rules gnc:pagename-display optname-use-rules
"e" opthelp-use-rules #f)) "e" opthelp-use-rules #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-label-assets gnc:pagename-display optname-label-assets
"f" opthelp-label-assets #t)) "f" opthelp-label-assets #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-total-assets gnc:pagename-display optname-total-assets
"g" opthelp-total-assets #t)) "g" opthelp-total-assets #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-label-liabilities gnc:pagename-display optname-label-liabilities
"h" opthelp-label-liabilities #t)) "h" opthelp-label-liabilities #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-total-liabilities gnc:pagename-display optname-total-liabilities
"i" opthelp-total-liabilities #t)) "i" opthelp-total-liabilities #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-label-equity gnc:pagename-display optname-label-equity
"j" opthelp-label-equity #t)) "j" opthelp-label-equity #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-total-equity gnc:pagename-display optname-total-equity
"k" opthelp-total-equity #t)) "k" opthelp-total-equity #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-new-existing gnc:pagename-display optname-new-existing
"l" opthelp-new-existing #t)) "l" opthelp-new-existing #t)
;; Set the accounts page as default option tab ;; Set the accounts page as default option tab
(gnc:options-set-default-section options gnc:pagename-accounts) (gnc:options-set-default-section options gnc:pagename-accounts)
@ -251,9 +227,8 @@
(define (budget-balance-sheet-renderer report-obj) (define (budget-balance-sheet-renderer report-obj)
(define (get-option pagename optname) (define (get-option pagename optname)
(gnc:option-value (gnc-optiondb-lookup-value
(gnc:lookup-option (gnc:report-options report-obj) pagename optname))
(gnc:report-options report-obj) pagename optname)))
(define (get-budget-account-budget-balance budget account) (define (get-budget-account-budget-balance budget account)
(let ((bal (gnc:budget-account-get-net budget account #f #f))) (let ((bal (gnc:budget-account-get-net budget account #f #f)))

View File

@ -70,79 +70,69 @@
(vector 'manual (N_ "Manual period selection")))) (vector 'manual (N_ "Manual period selection"))))
(define (options-generator) (define (options-generator)
(let ((options (gnc:new-options)) (let ((options (gnc-new-optiondb))
(book (gnc-get-current-book))
(ui-start-period-type 'current) (ui-start-period-type 'current)
(ui-end-period-type 'next)) (ui-end-period-type 'next))
(define (add-option new-option)
(gnc:register-option options new-option))
(define (set-option-enabled options page opt-name enabled) (define (set-option-enabled options page opt-name enabled)
(gnc-option-db-set-option-selectable-by-name options page opt-name enabled)) (gnc-optiondb-set-option-selectable-by-name options page opt-name enabled))
;; Option to select Budget ;; Option to select Budget
(add-option (gnc-register-budget-option options
(gnc:make-budget-option gnc:pagename-general optname-budget "a"
gnc:pagename-general optname-budget "a" (N_ "Budget to use."))) (N_ "Budget to use.")
(gnc-budget-get-default book))
(add-option (gnc-register-multichoice-callback-option options
(gnc:make-multichoice-callback-option
gnc:pagename-general optname-budget-period-start gnc:pagename-general optname-budget-period-start
"g1.1" opthelp-budget-period-start 'current period-options #f "g1.1" opthelp-budget-period-start "current" period-options
(lambda (new-val) (lambda (new-val)
(set-option-enabled options gnc:pagename-general (set-option-enabled options gnc:pagename-general
optname-budget-period-start-exact (eq? 'manual new-val)) optname-budget-period-start-exact (eq? 'manual new-val))
(set! ui-start-period-type new-val)))) (set! ui-start-period-type new-val)))
(add-option (gnc-register-number-range-option options
(gnc:make-number-range-option
gnc:pagename-general optname-budget-period-start-exact gnc:pagename-general optname-budget-period-start-exact
"g1.2" opthelp-budget-period-start-exact "g1.2" opthelp-budget-period-start-exact
1 1 60 0 1)) 1 1 60 1)
(add-option (gnc-register-multichoice-callback-option options
(gnc:make-multichoice-callback-option
gnc:pagename-general optname-budget-period-end gnc:pagename-general optname-budget-period-end
"g2.1" opthelp-budget-period-end 'next period-options #f "g2.1" opthelp-budget-period-end "next" period-options
(lambda (new-val) (lambda (new-val)
(set-option-enabled options gnc:pagename-general (set-option-enabled options gnc:pagename-general
optname-budget-period-end-exact (eq? 'manual new-val)) optname-budget-period-end-exact (eq? 'manual new-val))
(set! ui-end-period-type new-val)))) (set! ui-end-period-type new-val)))
(add-option (gnc-register-number-range-option options
(gnc:make-number-range-option
gnc:pagename-general optname-budget-period-end-exact gnc:pagename-general optname-budget-period-end-exact
"g2.2" opthelp-budget-period-end-exact "g2.2" opthelp-budget-period-end-exact
1 1 60 0 1)) 1 1 60 1)
;; Option to select the accounts to that will be displayed ;; Option to select the accounts to that will be displayed
(add-option (gnc-register-account-list-option options
(gnc:make-account-list-option
gnc:pagename-accounts optname-accounts gnc:pagename-accounts optname-accounts
"c" (N_ "Report on these accounts.") "c" (N_ "Report on these accounts.")
(lambda () (gnc:filter-accountlist-type
(gnc:filter-accountlist-type
(list ACCT-TYPE-BANK ACCT-TYPE-ASSET ACCT-TYPE-LIABILITY) (list ACCT-TYPE-BANK ACCT-TYPE-ASSET ACCT-TYPE-LIABILITY)
(gnc-account-get-descendants-sorted (gnc-get-current-root-account)))) (gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
#f #t))
(gnc:options-add-account-levels! (gnc:options-add-account-levels!
options gnc:pagename-accounts optname-depth-limit "d" opthelp-depth-limit 6) options gnc:pagename-accounts optname-depth-limit "d" opthelp-depth-limit 6)
;; Display tab ;; Display tab
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-running-sum "a" gnc:pagename-display optname-running-sum "a"
(N_ "Calculate as running sum?") #t)) (N_ "Calculate as running sum?") #t)
;; Display tab ;; Display tab
(add-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
gnc:pagename-display optname-chart-type "b" gnc:pagename-display optname-chart-type "b"
(N_ "Select which chart type to use.") 'bars (N_ "Select which chart type to use.") "bars"
(list (list
(vector 'bars (N_ "Bar Chart")) (vector 'bars (N_ "Bar Chart"))
(vector 'lines (N_ "Line Chart"))))) (vector 'lines (N_ "Line Chart"))))
(gnc:options-add-plot-size! (gnc:options-add-plot-size!
options gnc:pagename-display options gnc:pagename-display
@ -242,8 +232,8 @@
;; This is a helper function for looking up option values. ;; This is a helper function for looking up option values.
(define (get-option section name) (define (get-option section name)
(gnc:option-value (gnc-optiondb-lookup-value
(gnc:lookup-option (gnc:report-options report-obj) section name))) (gnc:report-options report-obj) section name))
;; This is a helper function to find out the level of the account ;; This is a helper function to find out the level of the account
;; with in the account tree ;; with in the account tree

View File

@ -46,19 +46,16 @@
;; options generator ;; options generator
(define (budget-report-options-generator) (define (budget-report-options-generator)
(let ((options (gnc:new-options))) (let ((options (gnc-new-optiondb)))
;; Option to select Budget ;; Option to select Budget
(gnc:register-option (gnc-register-budget-option options
options
(gnc:make-budget-option
gnc:pagename-general optname-budget gnc:pagename-general optname-budget
"a" (N_ "Budget to use."))) "a" (N_ "Budget to use.")
(gnc-budget-get-default (gnc-get-current-book)))
;; Option to select Period of selected Budget ;; Option to select Period of selected Budget
(gnc:register-option (gnc-register-number-range-option options
options
(gnc:make-number-range-option
gnc:pagename-general optname-periods gnc:pagename-general optname-periods
;; FIXME: It would be nice if the max number of budget periods (60) was ;; FIXME: It would be nice if the max number of budget periods (60) was
;; defined globally somewhere so we could reference it here. However, it ;; defined globally somewhere so we could reference it here. However, it
@ -67,7 +64,7 @@
;; FIXME: It would be even nicer if the max number of budget ;; FIXME: It would be even nicer if the max number of budget
;; periods was determined by the number of periods in the ;; periods was determined by the number of periods in the
;; currently selected budget ;; currently selected budget
"b" (N_ "Period number.") 1 1 60 0 1)) "b" (N_ "Period number.") 1 1 60 1)
;; Option to select the currency the report will be shown in ;; Option to select the currency the report will be shown in
(gnc:options-add-currency! (gnc:options-add-currency!
@ -79,15 +76,11 @@
options gnc:pagename-general optname-price-source "c" 'pricedb-latest) options gnc:pagename-general optname-price-source "c" 'pricedb-latest)
;;Option to select the accounts to that will be displayed ;;Option to select the accounts to that will be displayed
(gnc:register-option (gnc-register-account-list-option options
options
(gnc:make-account-list-option
gnc:pagename-accounts optname-accounts gnc:pagename-accounts optname-accounts
(string-append "a" "c") (string-append "a" "c")
(N_ "Report on these accounts.") (N_ "Report on these accounts.")
(lambda () (gnc-account-get-descendants-sorted (gnc-get-current-root-account)))
(gnc-account-get-descendants-sorted (gnc-get-current-root-account)))
#f #t))
;; Set the general page as default option tab ;; Set the general page as default option tab
(gnc:options-set-default-section options gnc:pagename-general) (gnc:options-set-default-section options gnc:pagename-general)
@ -255,9 +248,8 @@
;; Helper function retrieves options ;; Helper function retrieves options
(define (get-option pagename optname) (define (get-option pagename optname)
(gnc:option-value (gnc-optiondb-lookup-value
(gnc:lookup-option (gnc:report-options report-obj) pagename optname))
(gnc:report-options report-obj) pagename optname)))
;; Update progress bar ;; Update progress bar
(gnc:report-starting reportname) (gnc:report-starting reportname)

View File

@ -131,86 +131,74 @@
;; options generator ;; options generator
(define (budget-income-statement-options-generator-internal reportname) (define (budget-income-statement-options-generator-internal reportname)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb))
(book (gnc-get-current-book)) ; XXX Find a way to get the book that opened the report (book (gnc-get-current-book)))
(add-option
(lambda (new-option) (gnc-register-string-option options
(gnc:register-option options new-option))))
(add-option
(gnc:make-string-option
gnc:pagename-general optname-report-title gnc:pagename-general optname-report-title
"a" opthelp-report-title (G_ reportname))) "a" opthelp-report-title (G_ reportname))
(add-option (gnc-register-string-option options
(gnc:make-string-option
gnc:pagename-general optname-party-name gnc:pagename-general optname-party-name
"b" opthelp-party-name (or (gnc:company-info book gnc:*company-name*) ""))) "b" opthelp-party-name (or (gnc:company-info book gnc:*company-name*) ""))
(add-option (gnc-register-budget-option options
(gnc:make-budget-option
gnc:pagename-general optname-budget gnc:pagename-general optname-budget
"c" opthelp-budget)) "c" opthelp-budget
(gnc-budget-get-default book))
(add-option (gnc-register-complex-boolean-option options
(gnc:make-complex-boolean-option
gnc:pagename-general gnc:pagename-general
optname-use-budget-period-range optname-use-budget-period-range
"d" "d"
opthelp-use-budget-period-range opthelp-use-budget-period-range
#f #f
#f
;; Make budget-period-start and budget-period-end option widgets ;; Make budget-period-start and budget-period-end option widgets
;; selectable only when we are running the report for a budget period ;; selectable only when we are running the report for a budget period
;; range. ;; range.
(lambda (value) (lambda (value)
(gnc-option-db-set-option-selectable-by-name (gnc-optiondb-set-option-selectable-by-name
options options
gnc:pagename-general gnc:pagename-general
optname-budget-period-start optname-budget-period-start
value) value)
(gnc-option-db-set-option-selectable-by-name (gnc-optiondb-set-option-selectable-by-name
options options
gnc:pagename-general gnc:pagename-general
optname-budget-period-end optname-budget-period-end
value)))) value)))
(add-option (gnc-register-number-range-option options
(gnc:make-number-range-option
gnc:pagename-general optname-budget-period-start gnc:pagename-general optname-budget-period-start
"e" opthelp-budget-period-start "e" opthelp-budget-period-start
;; FIXME: It would be nice if the max number of budget periods (60) was ;; FIXME: It would be nice if the max number of budget periods (60) was
;; defined globally somewhere so we could reference it here. However, it ;; defined globally somewhere so we could reference it here. However, it
;; only appears to be defined currently in src/gnome/glade/budget.glade. ;; only appears to be defined currently in src/gnome/glade/budget.glade.
1 1 60 0 1)) 1 1 60 1)
(add-option (gnc-register-number-range-option options
(gnc:make-number-range-option
gnc:pagename-general optname-budget-period-end gnc:pagename-general optname-budget-period-end
"f" opthelp-budget-period-end "f" opthelp-budget-period-end
;; FIXME: It would be nice if the max number of budget periods (60) was ;; FIXME: It would be nice if the max number of budget periods (60) was
;; defined globally somewhere so we could reference it here. However, it ;; defined globally somewhere so we could reference it here. However, it
;; only appears to be defined currently in src/gnome/glade/budget.glade. ;; only appears to be defined currently in src/gnome/glade/budget.glade.
1 1 60 0 1)) 1 1 60 1)
;; accounts to work on ;; accounts to work on
(add-option (gnc-register-account-list-option options
(gnc:make-account-list-option
gnc:pagename-accounts optname-accounts gnc:pagename-accounts optname-accounts
"a" "a"
opthelp-accounts opthelp-accounts
(lambda () (gnc:filter-accountlist-type
(gnc:filter-accountlist-type
;; select, by default, only income and expense accounts ;; select, by default, only income and expense accounts
(list ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE) (list ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE)
(gnc-account-get-descendants-sorted (gnc-get-current-root-account)))) (gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
#f #t))
(gnc:options-add-account-levels! (gnc:options-add-account-levels!
options gnc:pagename-accounts optname-depth-limit options gnc:pagename-accounts optname-depth-limit
"b" opthelp-depth-limit 3) "b" opthelp-depth-limit 3)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-accounts optname-bottom-behavior gnc:pagename-accounts optname-bottom-behavior
"c" opthelp-bottom-behavior #f)) "c" opthelp-bottom-behavior #f)
;; all about currencies ;; all about currencies
(gnc:options-add-currency! (gnc:options-add-currency!
@ -221,25 +209,21 @@
options pagename-commodities options pagename-commodities
optname-price-source "b" 'pricedb-nearest) optname-price-source "b" 'pricedb-nearest)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-commodities optname-show-foreign pagename-commodities optname-show-foreign
"c" opthelp-show-foreign #t)) "c" opthelp-show-foreign #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-commodities optname-show-rates pagename-commodities optname-show-rates
"d" opthelp-show-rates #f)) "d" opthelp-show-rates #f)
;; what to show for zero-balance accounts ;; what to show for zero-balance accounts
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-zb-accts gnc:pagename-display optname-show-zb-accts
"a" opthelp-show-zb-accts #t)) "a" opthelp-show-zb-accts #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-omit-zb-bals gnc:pagename-display optname-omit-zb-bals
"b" opthelp-omit-zb-bals #f)) "b" opthelp-omit-zb-bals #f)
;; what to show for non-leaf accounts ;; what to show for non-leaf accounts
(gnc:options-add-subtotal-view! (gnc:options-add-subtotal-view!
options gnc:pagename-display options gnc:pagename-display
@ -247,42 +231,34 @@
"c") "c")
;; some detailed formatting options ;; some detailed formatting options
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-account-links gnc:pagename-display optname-account-links
"d" opthelp-account-links #t)) "d" opthelp-account-links #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-use-rules gnc:pagename-display optname-use-rules
"e" opthelp-use-rules #f)) "e" opthelp-use-rules #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-label-revenue gnc:pagename-display optname-label-revenue
"f" opthelp-label-revenue #t)) "f" opthelp-label-revenue #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-total-revenue gnc:pagename-display optname-total-revenue
"g" opthelp-total-revenue #t)) "g" opthelp-total-revenue #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-label-expense gnc:pagename-display optname-label-expense
"h" opthelp-label-expense #t)) "h" opthelp-label-expense #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-total-expense gnc:pagename-display optname-total-expense
"i" opthelp-total-expense #t)) "i" opthelp-total-expense #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-two-column gnc:pagename-display optname-two-column
"j" opthelp-two-column #f)) "j" opthelp-two-column #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-standard-order gnc:pagename-display optname-standard-order
"k" opthelp-standard-order #t)) "k" opthelp-standard-order #t)
;; Set the accounts page as default option tab ;; Set the accounts page as default option tab
(gnc:options-set-default-section options gnc:pagename-accounts) (gnc:options-set-default-section options gnc:pagename-accounts)
@ -296,9 +272,8 @@
(define (budget-income-statement-renderer-internal report-obj reportname) (define (budget-income-statement-renderer-internal report-obj reportname)
(define (get-option pagename optname) (define (get-option pagename optname)
(gnc:option-value (gnc-optiondb-lookup-value
(gnc:lookup-option (gnc:report-options report-obj) pagename optname))
(gnc:report-options report-obj) pagename optname)))
(define (get-assoc-account-balances-budget (define (get-assoc-account-balances-budget
budget accountlist period-start period-end get-balance-fn) budget accountlist period-start period-end get-balance-fn)

View File

@ -94,19 +94,15 @@
;;List of common helper functions, that is not bound only to options generation or report evaluation ;;List of common helper functions, that is not bound only to options generation or report evaluation
(define (get-option-val options pagename optname) (define (get-option-val options pagename optname)
(gnc:option-value (gnc-optiondb-lookup-value options pagename optname))
(gnc:lookup-option options pagename optname)))
(define (set-option-enabled options page opt-name enabled) (define (set-option-enabled options page opt-name enabled)
(gnc-option-db-set-option-selectable-by-name (gnc-optiondb-set-option-selectable-by-name
options page opt-name enabled)) options page opt-name enabled))
;; options generator ;; options generator
(define (budget-report-options-generator) (define (budget-report-options-generator)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb))
(add-option
(lambda (new-option)
(gnc:register-option options new-option)))
(period-options (period-options
(list (vector 'first (N_ "First budget period")) (list (vector 'first (N_ "First budget period"))
(vector 'previous (N_ "Previous budget period")) (vector 'previous (N_ "Previous budget period"))
@ -118,21 +114,18 @@
(ui-start-period-type 'current) (ui-start-period-type 'current)
(ui-end-period-type 'next)) (ui-end-period-type 'next))
(gnc:register-option (gnc-register-budget-option options
options
(gnc:make-budget-option
gnc:pagename-general optname-budget gnc:pagename-general optname-budget
"a" (N_ "Budget to use."))) "a" (N_ "Budget to use.")
(gnc-budget-get-default (gnc-get-current-book)))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-general optname-accumulate gnc:pagename-general optname-accumulate
"b" opthelp-accumulate #f)) "b" opthelp-accumulate #f)
(add-option (gnc-register-complex-boolean-option options
(gnc:make-complex-boolean-option
gnc:pagename-general optname-use-budget-period-range gnc:pagename-general optname-use-budget-period-range
"f" opthelp-use-budget-period-range #f #f "f" opthelp-use-budget-period-range #f
(lambda (value) (lambda (value)
(for-each (for-each
(lambda (opt) (lambda (opt)
@ -148,56 +141,50 @@
optname-budget-period-end-exact optname-budget-period-end-exact
(and value (eq? 'manual ui-end-period-type))) (and value (eq? 'manual ui-end-period-type)))
(set! ui-use-periods value)))) (set! ui-use-periods value)))
(add-option (gnc-register-multichoice-callback-option options
(gnc:make-multichoice-callback-option
gnc:pagename-general optname-budget-period-start gnc:pagename-general optname-budget-period-start
"g1.1" opthelp-budget-period-start 'current period-options #f "g1.1" opthelp-budget-period-start "current" period-options
(lambda (new-val) (lambda (new-val)
(set-option-enabled options gnc:pagename-general (set-option-enabled options gnc:pagename-general
optname-budget-period-start-exact optname-budget-period-start-exact
(and ui-use-periods (eq? 'manual new-val))) (and ui-use-periods (eq? 'manual new-val)))
(set! ui-start-period-type new-val)))) (set! ui-start-period-type new-val)))
(add-option (gnc-register-number-range-option options
(gnc:make-number-range-option
gnc:pagename-general optname-budget-period-start-exact gnc:pagename-general optname-budget-period-start-exact
"g1.2" opthelp-budget-period-start-exact "g1.2" opthelp-budget-period-start-exact
;; FIXME: It would be nice if the max number of budget periods (60) was ;; FIXME: It would be nice if the max number of budget periods (60) was
;; defined globally somewhere so we could reference it here. However, it ;; defined globally somewhere so we could reference it here. However, it
;; only appears to be defined currently in src/gnome/glade/budget.glade. ;; only appears to be defined currently in src/gnome/glade/budget.glade.
1 1 60 0 1)) 1 1 60 1)
(add-option (gnc-register-multichoice-callback-option options
(gnc:make-multichoice-callback-option
gnc:pagename-general optname-budget-period-end gnc:pagename-general optname-budget-period-end
"g2.1" opthelp-budget-period-end 'next period-options #f "g2.1" opthelp-budget-period-end "next" period-options
(lambda (new-val) (lambda (new-val)
(set-option-enabled options gnc:pagename-general (set-option-enabled options gnc:pagename-general
optname-budget-period-end-exact optname-budget-period-end-exact
(and ui-use-periods (eq? 'manual new-val))) (and ui-use-periods (eq? 'manual new-val)))
(set! ui-end-period-type new-val)))) (set! ui-end-period-type new-val)))
(add-option (gnc-register-number-range-option options
(gnc:make-number-range-option
gnc:pagename-general optname-budget-period-end-exact gnc:pagename-general optname-budget-period-end-exact
"g2.2" opthelp-budget-period-end-exact "g2.2" opthelp-budget-period-end-exact
;; FIXME: It would be nice if the max number of budget periods (60) was ;; FIXME: It would be nice if the max number of budget periods (60) was
;; defined globally somewhere so we could reference it here. However, it ;; defined globally somewhere so we could reference it here. However, it
;; only appears to be defined currently in src/gnome/glade/budget.glade. ;; only appears to be defined currently in src/gnome/glade/budget.glade.
1 1 60 0 1)) 1 1 60 1)
;; accounts to work on ;; accounts to work on
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-general optname-period-collapse-before gnc:pagename-general optname-period-collapse-before
"g3" opthelp-period-collapse-before #t)) "g3" opthelp-period-collapse-before #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-general optname-period-collapse-after gnc:pagename-general optname-period-collapse-after
"g4" opthelp-period-collapse-after #t)) "g4" opthelp-period-collapse-after #t)
(gnc:options-add-account-selection! (gnc:options-add-account-selection!
options gnc:pagename-accounts optname-display-depth options gnc:pagename-accounts optname-display-depth
@ -209,38 +196,31 @@
(gnc-account-get-descendants-sorted (gnc-get-current-root-account)))) (gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
#f) #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-accounts optname-bottom-behavior gnc:pagename-accounts optname-bottom-behavior
"c" opthelp-bottom-behavior #f)) "c" opthelp-bottom-behavior #f)
;; columns to display ;; columns to display
(add-option (gnc-register-complex-boolean-option options
(gnc:make-complex-boolean-option
gnc:pagename-display optname-show-budget gnc:pagename-display optname-show-budget
"s1" opthelp-show-budget #t #f "s1" opthelp-show-budget #t
(lambda (x) (lambda (x)
(set-option-enabled options gnc:pagename-display optname-show-notes x)))) (set-option-enabled options gnc:pagename-display optname-show-notes x)))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-notes gnc:pagename-display optname-show-notes
"s15" opthelp-show-notes #t)) "s15" opthelp-show-notes #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-actual gnc:pagename-display optname-show-actual
"s2" opthelp-show-actual #t)) "s2" opthelp-show-actual #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-difference gnc:pagename-display optname-show-difference
"s3" opthelp-show-difference #f)) "s3" opthelp-show-difference #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-totalcol gnc:pagename-display optname-show-totalcol
"s4" opthelp-show-totalcol #f)) "s4" opthelp-show-totalcol #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-zb-accounts gnc:pagename-display optname-show-zb-accounts
"s5" opthelp-show-zb-accounts #t)) "s5" opthelp-show-zb-accounts #t)
;; Set the general page as default option tab ;; Set the general page as default option tab
(gnc:options-set-default-section options gnc:pagename-general) (gnc:options-set-default-section options gnc:pagename-general)

View File

@ -54,7 +54,7 @@
;; options generator ;; options generator
(define (cash-flow-options-generator) (define (cash-flow-options-generator)
(let ((options (gnc:new-options))) (let ((options (gnc-new-optiondb)))
;; date interval ;; date interval
(gnc:options-add-date-interval! (gnc:options-add-date-interval!
@ -70,17 +70,13 @@
options gnc:pagename-general options gnc:pagename-general
optname-price-source "c" 'pricedb-nearest) optname-price-source "c" 'pricedb-nearest)
(gnc:register-option (gnc-register-simple-boolean-option options
options
(gnc:make-simple-boolean-option
gnc:pagename-general optname-show-rates gnc:pagename-general optname-show-rates
"d" (N_ "Show the exchange rates used.") #f)) "d" (N_ "Show the exchange rates used.") #f)
(gnc:register-option (gnc-register-simple-boolean-option options
options
(gnc:make-simple-boolean-option
gnc:pagename-general optname-show-full-names gnc:pagename-general optname-show-full-names
"e" (N_ "Show full account names (including parent accounts).") #t)) "e" (N_ "Show full account names (including parent accounts).") #t)
;; accounts to work on ;; accounts to work on
(gnc:options-add-account-selection! (gnc:options-add-account-selection!
@ -95,11 +91,9 @@
#f) #f)
;; Trading accounts? ;; Trading accounts?
(gnc:register-option (gnc-register-simple-boolean-option options
options
(gnc:make-simple-boolean-option
gnc:pagename-accounts optname-include-trading-accounts gnc:pagename-accounts optname-include-trading-accounts
"b" (N_ "Include transfers to and from Trading Accounts in the report.") #f)) "b" (N_ "Include transfers to and from Trading Accounts in the report.") #f)
;; Set the general page as default option tab ;; Set the general page as default option tab
(gnc:options-set-default-section options gnc:pagename-general) (gnc:options-set-default-section options gnc:pagename-general)
@ -113,9 +107,8 @@
(define (cash-flow-renderer report-obj) (define (cash-flow-renderer report-obj)
(define (get-option pagename optname) (define (get-option pagename optname)
(gnc:option-value (gnc-optiondb-lookup-value
(gnc:lookup-option (gnc:report-options report-obj) pagename optname))
(gnc:report-options report-obj) pagename optname)))
(gnc:report-starting reportname) (gnc:report-starting reportname)

View File

@ -61,10 +61,7 @@
;; options generator function ;; options generator function
(define (cashflow-barchart-options-generator) (define (cashflow-barchart-options-generator)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb)))
(add-option
(lambda (new-option)
(gnc:register-option options new-option))))
;; General tab ;; General tab
(gnc:options-add-date-interval! (gnc:options-add-date-interval!
@ -82,47 +79,34 @@
optname-price-source "d" 'pricedb-nearest) optname-price-source "d" 'pricedb-nearest)
;; Accounts tab ;; Accounts tab
(add-option (gnc-register-account-list-option options
(gnc:make-account-list-option
gnc:pagename-accounts optname-accounts gnc:pagename-accounts optname-accounts
"a" (N_ "Report on these accounts.") "a" (N_ "Report on these accounts.")
(lambda () ; account getter (gnc:filter-accountlist-type
(gnc:filter-accountlist-type
(list ACCT-TYPE-BANK ACCT-TYPE-CASH ACCT-TYPE-ASSET (list ACCT-TYPE-BANK ACCT-TYPE-CASH ACCT-TYPE-ASSET
ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL) ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL)
(gnc-account-get-descendants-sorted (gnc-get-current-root-account)))) (gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
#f #t))
(gnc:register-option (gnc-register-simple-boolean-option options
options
(gnc:make-simple-boolean-option
gnc:pagename-accounts optname-include-trading-accounts gnc:pagename-accounts optname-include-trading-accounts
"b" (N_ "Include transfers to and from Trading Accounts in the report.") #f)) "b" (N_ "Include transfers to and from Trading Accounts in the report.") #f)
;; Display tab ;; Display tab
(gnc:register-option (gnc-register-simple-boolean-option options
options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-in gnc:pagename-display optname-show-in
"a" (N_ "Show money in?") #t)) "a" (N_ "Show money in?") #t)
(gnc:register-option (gnc-register-simple-boolean-option options
options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-out gnc:pagename-display optname-show-out
"b" (N_ "Show money out?") #t)) "b" (N_ "Show money out?") #t)
(gnc:register-option (gnc-register-simple-boolean-option options
options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-net gnc:pagename-display optname-show-net
"c" (N_ "Show net money flow?") #t)) "c" (N_ "Show net money flow?") #t)
(gnc:register-option (gnc-register-simple-boolean-option options
options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-table gnc:pagename-display optname-show-table
"d" (N_ "Display a table of the selected data.") #f)) "d" (N_ "Display a table of the selected data.") #f)
;; Plot size options ;; Plot size options
(gnc:options-add-plot-size! (gnc:options-add-plot-size!
@ -141,9 +125,8 @@
(define (cashflow-barchart-renderer report-obj) (define (cashflow-barchart-renderer report-obj)
(define (get-option pagename optname) (define (get-option pagename optname)
(gnc:option-value (gnc-optiondb-lookup-value
(gnc:lookup-option (gnc:report-options report-obj) pagename optname))
(gnc:report-options report-obj) pagename optname)))
(gnc:report-starting reportname) (gnc:report-starting reportname)

View File

@ -94,10 +94,7 @@ developing over time"))
(define opthelp-averaging (N_ "Select whether the amounts should be shown over the full time period or rather as the average e.g. per month.")) (define opthelp-averaging (N_ "Select whether the amounts should be shown over the full time period or rather as the average e.g. per month."))
(define (options-generator account-types do-intervals?) (define (options-generator account-types do-intervals?)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb)))
(add-option
(lambda (new-option)
(gnc:register-option options new-option))))
;; General tab ;; General tab
(gnc:options-add-date-interval! (gnc:options-add-date-interval!
@ -115,31 +112,25 @@ developing over time"))
optname-price-source "d" 'weighted-average) optname-price-source "d" 'weighted-average)
(if do-intervals? (if do-intervals?
(add-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
gnc:pagename-general optname-averaging gnc:pagename-general optname-averaging
"e" opthelp-averaging "e" opthelp-averaging
'None "None"
(list (vector 'None (N_ "No Averaging")) (list (vector 'None (N_ "No Averaging"))
(vector 'MonthDelta (N_ "Monthly")) (vector 'MonthDelta (N_ "Monthly"))
(vector 'WeekDelta (N_ "Weekly")) (vector 'WeekDelta (N_ "Weekly"))
(vector 'DayDelta (N_ "Daily")))))) (vector 'DayDelta (N_ "Daily")))))
;; Accounts tab ;; Accounts tab
(add-option (gnc-register-account-list-limited-option options
(gnc:make-account-list-option
gnc:pagename-accounts optname-accounts gnc:pagename-accounts optname-accounts
"a" "a"
(N_ "Report on these accounts, if chosen account level allows.") (N_ "Report on these accounts, if chosen account level allows.")
(lambda () (gnc:filter-accountlist-type
(gnc:filter-accountlist-type
account-types account-types
(gnc-account-get-descendants-sorted (gnc-get-current-root-account)))) (gnc-account-get-descendants-sorted (gnc-get-current-root-account)))
(lambda (accounts) account-types)
(list #t
(gnc:filter-accountlist-type account-types accounts)))
#t))
(gnc:options-add-account-levels! (gnc:options-add-account-levels!
options gnc:pagename-accounts optname-levels "c" options gnc:pagename-accounts optname-levels "c"
@ -147,47 +138,41 @@ developing over time"))
2) 2)
;; Display tab ;; Display tab
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-fullname gnc:pagename-display optname-fullname
"a" (N_ "Show the full account name in legend?") #f)) "a" (N_ "Show the full account name in legend?") #f)
(add-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
gnc:pagename-display optname-chart-type gnc:pagename-display optname-chart-type
"b" "Select which chart type to use." "b" "Select which chart type to use."
'barchart "barchart"
(list (vector 'barchart (N_ "Bar Chart")) (list (vector 'barchart (N_ "Bar Chart"))
(vector 'linechart (N_ "Line Chart"))))) (vector 'linechart (N_ "Line Chart"))))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-stacked gnc:pagename-display optname-stacked
"c" "c"
(N_ "Show charts as stacked charts?") (N_ "Show charts as stacked charts?")
#t)) #t)
(add-option (gnc-register-number-range-option options
(gnc:make-number-range-option
gnc:pagename-display optname-slices gnc:pagename-display optname-slices
"d" (N_ "Maximum number of stacks in the chart.") 8 "d" (N_ "Maximum number of stacks in the chart.") 8
2 24 0 1)) 2 24 1)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display gnc:pagename-display
(N_ "Show table") (N_ "Show table")
"e" (N_ "Display a table of the selected data.") "e" (N_ "Display a table of the selected data.")
#f)) #f)
;; contributed by https://github.com/exxus ;; contributed by https://github.com/exxus
;; https://github.com/Gnucash/gnucash/pull/1272 ;; https://github.com/Gnucash/gnucash/pull/1272
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display gnc:pagename-display
(N_ "Percentage chart") (N_ "Percentage chart")
"e1" (N_ "Display account contributions as a percentage of the total value for the period.") "e1" (N_ "Display account contributions as a percentage of the total value for the period.")
#f)) #f)
(gnc:options-add-plot-size! (gnc:options-add-plot-size!
options gnc:pagename-display options gnc:pagename-display
@ -218,9 +203,7 @@ developing over time"))
export-type) export-type)
;; A helper functions for looking up option values. ;; A helper functions for looking up option values.
(define (get-option section name) (define (get-option section name)
(gnc-option-value (gnc-option-value (gnc:report-options report-obj) section name))
(gnc:optiondb
(gnc:report-options report-obj)) section name))
(gnc:report-starting reportname) (gnc:report-starting reportname)
(let* ((to-date-t64 (gnc:time64-end-day-time (let* ((to-date-t64 (gnc:time64-end-day-time
@ -567,10 +550,9 @@ Please deselect the accounts with negative balances."))
(gnc:options-copy-values (gnc:options-copy-values
(gnc:report-options report-obj) options) (gnc:report-options report-obj) options)
;; and set the destination accounts ;; and set the destination accounts
(gnc:option-set-value (gnc-set-option options gnc:pagename-accounts
(gnc:lookup-option options gnc:pagename-accounts optname-accounts
optname-accounts) (map car finish))
(map car finish))
;; Set the URL to point to this report. ;; Set the URL to point to this report.
(set! other-anchor (set! other-anchor
(gnc:report-anchor-text (gnc:report-anchor-text
@ -745,4 +727,3 @@ Please deselect the accounts with negative balances."))
(list ACCT-TYPE-LIABILITY ACCT-TYPE-PAYABLE ACCT-TYPE-CREDIT (list ACCT-TYPE-LIABILITY ACCT-TYPE-PAYABLE ACCT-TYPE-CREDIT
ACCT-TYPE-CREDITLINE) ACCT-TYPE-CREDITLINE)
#f menuname-liabilities menutip-liabilities #t category-barchart-liability-uuid))) #f menuname-liabilities menutip-liabilities #t category-barchart-liability-uuid)))

View File

@ -79,74 +79,59 @@
(define (options-generator) (define (options-generator)
(define options (gnc:new-options)) (define options (gnc-new-optiondb))
(define (add-option new-option)
(gnc:register-option options new-option))
(gnc:options-add-date-interval! (gnc:options-add-date-interval!
options gnc:pagename-general optname-from-date optname-to-date "b") options gnc:pagename-general optname-from-date optname-to-date "b")
(add-option (gnc-register-account-list-option options
(gnc:make-account-list-option
pagename-incomeaccounts optname-incomeaccounts pagename-incomeaccounts optname-incomeaccounts
"b" opthelp-incomeaccounts "b" opthelp-incomeaccounts
(lambda () (gnc:filter-accountlist-type
(gnc:filter-accountlist-type (list ACCT-TYPE-INCOME)
(list ACCT-TYPE-INCOME) (gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
(gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
#f #t))
(add-option (gnc-register-account-list-option options
(gnc:make-account-list-option
pagename-expenseaccounts optname-expenseaccounts pagename-expenseaccounts optname-expenseaccounts
"b" opthelp-expenseaccounts "b" opthelp-expenseaccounts
(lambda () (gnc:filter-accountlist-type
(gnc:filter-accountlist-type (list ACCT-TYPE-EXPENSE)
(list ACCT-TYPE-EXPENSE) (gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
(gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
#f #t))
(add-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
gnc:pagename-display optname-sortkey gnc:pagename-display optname-sortkey
"a" opthelp-sortkey "a" opthelp-sortkey
'customername "customername"
(list (list
(vector 'customername (N_ "Customer Name")) (vector 'customername (N_ "Customer Name"))
(vector 'profit (N_ "Profit")) (vector 'profit (N_ "Profit"))
(vector 'markup (N_ "Markup (which is profit amount divided by sales)")) (vector 'markup (N_ "Markup (which is profit amount divided by sales)"))
(vector 'sales (N_ "Sales")) (vector 'sales (N_ "Sales"))
(vector 'expense (N_ "Expense"))))) (vector 'expense (N_ "Expense"))))
(add-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
gnc:pagename-display optname-sortascending gnc:pagename-display optname-sortascending
"b" opthelp-sortascending "b" opthelp-sortascending
'ascend "ascend"
(list (list
(vector 'ascend (N_ "Ascending")) (vector 'ascend (N_ "Ascending"))
(vector 'descend (N_ "Descending"))))) (vector 'descend (N_ "Descending"))))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-own-address gnc:pagename-display optname-show-own-address
"d" opthelp-show-own-address #t)) "d" opthelp-show-own-address #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-zero-lines gnc:pagename-display optname-show-zero-lines
"e" opthelp-show-zero-lines #f)) "e" opthelp-show-zero-lines #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-inactive gnc:pagename-display optname-show-inactive
"f" opthelp-show-inactive #f)) "f" opthelp-show-inactive #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-column-expense gnc:pagename-display optname-show-column-expense
"g" opthelp-show-column-expense #t)) "g" opthelp-show-column-expense #t)
(gnc:options-set-default-section options gnc:pagename-general) (gnc:options-set-default-section options gnc:pagename-general)
@ -231,8 +216,7 @@
(define (reg-renderer report-obj) (define (reg-renderer report-obj)
(define (opt-val section name) (define (opt-val section name)
(gnc:option-value (gnc-optiondb-lookup-value (gnc:report-options report-obj) section name))
(gnc:lookup-option (gnc:report-options report-obj) section name)))
(let* ((document (gnc:make-html-document)) (let* ((document (gnc:make-html-document))
(report-title (opt-val gnc:pagename-general gnc:optname-reportname)) (report-title (opt-val gnc:pagename-general gnc:optname-reportname))

View File

@ -46,8 +46,7 @@
(options (gnc:report-options (gnc-report-find view)))) (options (gnc:report-options (gnc-report-find view))))
(define (set-option! section name value) (define (set-option! section name value)
(gnc:option-set-value (gnc-set-option (gnc:optiondb options) section name value))
(gnc:lookup-option options section name) value))
(set-option! "General" "Report name" (G_ "Dashboard")) (set-option! "General" "Report name" (G_ "Dashboard"))
(set-option! "General" "Number of columns" 2) (set-option! "General" "Number of columns" 2)

View File

@ -98,20 +98,15 @@
;; options generator ;; options generator
(define (equity-statement-options-generator) (define (equity-statement-options-generator)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb))
(book (gnc-get-current-book)) ; XXX Find a way to get the book that opened the report (book (gnc-get-current-book)))
(add-option
(lambda (new-option)
(gnc:register-option options new-option))))
(add-option (gnc-register-string-option options
(gnc:make-string-option
(N_ "General") optname-report-title (N_ "General") optname-report-title
"a" opthelp-report-title (G_ reportname))) "a" opthelp-report-title (G_ reportname))
(add-option (gnc-register-string-option options
(gnc:make-string-option
(N_ "General") optname-party-name (N_ "General") optname-party-name
"b" opthelp-party-name (or (gnc:company-info book gnc:*company-name*) ""))) "b" opthelp-party-name (or (gnc:company-info book gnc:*company-name*) ""))
;; date at which to report balance ;; date at which to report balance
(gnc:options-add-date-interval! (gnc:options-add-date-interval!
@ -119,13 +114,11 @@
optname-start-date optname-end-date "c") optname-start-date optname-end-date "c")
;; accounts to work on ;; accounts to work on
(add-option (gnc-register-account-list-option options
(gnc:make-account-list-option
gnc:pagename-accounts optname-accounts gnc:pagename-accounts optname-accounts
"a" "a"
opthelp-accounts opthelp-accounts
(lambda () (gnc:filter-accountlist-type
(gnc:filter-accountlist-type
(list ACCT-TYPE-BANK ACCT-TYPE-CASH ACCT-TYPE-CREDIT (list ACCT-TYPE-BANK ACCT-TYPE-CASH ACCT-TYPE-CREDIT
ACCT-TYPE-ASSET ACCT-TYPE-LIABILITY ACCT-TYPE-ASSET ACCT-TYPE-LIABILITY
ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL ACCT-TYPE-CURRENCY ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL ACCT-TYPE-CURRENCY
@ -133,7 +126,6 @@
ACCT-TYPE-EQUITY ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE ACCT-TYPE-EQUITY ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE
ACCT-TYPE-TRADING) ACCT-TYPE-TRADING)
(gnc-account-get-descendants-sorted (gnc-get-current-root-account)))) (gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
#f #t))
;; all about currencies ;; all about currencies
(gnc:options-add-currency! (gnc:options-add-currency!
@ -144,38 +136,32 @@
options pagename-commodities options pagename-commodities
optname-price-source "b" 'pricedb-nearest) optname-price-source "b" 'pricedb-nearest)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-commodities optname-show-foreign pagename-commodities optname-show-foreign
"c" opthelp-show-foreign #t)) "c" opthelp-show-foreign #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-commodities optname-show-rates pagename-commodities optname-show-rates
"d" opthelp-show-rates #f)) "d" opthelp-show-rates #f)
;; some detailed formatting options ;; some detailed formatting options
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-use-rules gnc:pagename-display optname-use-rules
"f" opthelp-use-rules #f)) "f" opthelp-use-rules #f)
;; closing entry match criteria ;; closing entry match criteria
;; ;;
;; N.B.: transactions really should have a field where we can put ;; N.B.: transactions really should have a field where we can put
;; transaction types like "Adjusting/Closing/Correcting Entries" ;; transaction types like "Adjusting/Closing/Correcting Entries"
(add-option (gnc-register-string-option options
(gnc:make-string-option
pagename-entries optname-closing-pattern pagename-entries optname-closing-pattern
"a" opthelp-closing-pattern (G_ "Closing Entries"))) "a" opthelp-closing-pattern (G_ "Closing Entries"))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-entries optname-closing-casing pagename-entries optname-closing-casing
"b" opthelp-closing-casing #f)) "b" opthelp-closing-casing #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-entries optname-closing-regexp pagename-entries optname-closing-regexp
"c" opthelp-closing-regexp #f)) "c" opthelp-closing-regexp #f)
;; Set the accounts page as default option tab ;; Set the accounts page as default option tab
(gnc:options-set-default-section options gnc:pagename-accounts) (gnc:options-set-default-section options gnc:pagename-accounts)
@ -209,9 +195,8 @@
(define (equity-statement-renderer report-obj) (define (equity-statement-renderer report-obj)
(define (get-option pagename optname) (define (get-option pagename optname)
(gnc:option-value (gnc-optiondb-lookup-value
(gnc:lookup-option (gnc:report-options report-obj) pagename optname))
(gnc:report-options report-obj) pagename optname)))
(gnc:report-starting reportname) (gnc:report-starting reportname)

View File

@ -46,8 +46,8 @@
(query (qof-query-create-for-splits))) (query (qof-query-create-for-splits)))
(define (set-option! section name value) (define (set-option! section name value)
(gnc:option-set-default-value (GncOption-set-default-value
(gnc:lookup-option options section name) value)) (gnc-lookup-option (gnc:optiondb options) section name) value))
;; Match, by default, all non-void transactions ever recorded in ;; Match, by default, all non-void transactions ever recorded in
;; all accounts.... Whether or not to match void transactions, ;; all accounts.... Whether or not to match void transactions,

View File

@ -77,10 +77,7 @@ commissions in cumulative average cost and gain/loss after commission")
the split action field to detect capitalized fees on stock activity") the split action field to detect capitalized fees on stock activity")
(define (options-generator) (define (options-generator)
(let ((options (gnc:new-options))) (let ((options (gnc-new-optiondb)))
(define (add-option new-option)
(gnc:register-option options new-option))
(gnc:options-add-date-interval! (gnc:options-add-date-interval!
options gnc:pagename-general optname-startdate optname-enddate " ") options gnc:pagename-general optname-startdate optname-enddate " ")
@ -88,46 +85,37 @@ the split action field to detect capitalized fees on stock activity")
(gnc:options-add-currency! (gnc:options-add-currency!
options gnc:pagename-general optname-report-currency "a") options gnc:pagename-general optname-report-currency "a")
(add-option (gnc-register-account-sel-limited-option options
(gnc:make-account-sel-limited-option
gnc:pagename-general optname-stock-acct "b" "Stock Account" gnc:pagename-general optname-stock-acct "b" "Stock Account"
#f #f (list ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL))) '() (list ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL))
(add-option (gnc-register-account-sel-limited-option options
(gnc:make-account-sel-limited-option
gnc:pagename-general optname-proceeds-acct "c" "Proceeds Account" gnc:pagename-general optname-proceeds-acct "c" "Proceeds Account"
#f #f (list ACCT-TYPE-ASSET ACCT-TYPE-BANK))) '() (list ACCT-TYPE-ASSET ACCT-TYPE-BANK))
(add-option (gnc-register-account-sel-limited-option options
(gnc:make-account-sel-limited-option
gnc:pagename-general optname-dividend-acct "c" "Dividend Account" gnc:pagename-general optname-dividend-acct "c" "Dividend Account"
#f #f (list ACCT-TYPE-INCOME))) '() (list ACCT-TYPE-INCOME))
(add-option (gnc-register-account-sel-limited-option options
(gnc:make-account-sel-limited-option
gnc:pagename-general optname-capgains-acct "d" "Cap Gains Account" gnc:pagename-general optname-capgains-acct "d" "Cap Gains Account"
#f #f (list ACCT-TYPE-INCOME))) '() (list ACCT-TYPE-INCOME))
(add-option (gnc-register-account-sel-limited-option options
(gnc:make-account-sel-limited-option
gnc:pagename-general optname-fees-acct "c5" "Fees Account" gnc:pagename-general optname-fees-acct "c5" "Fees Account"
#f #f (list ACCT-TYPE-EXPENSE))) '() (list ACCT-TYPE-EXPENSE))
(add-option (gnc-register-string-option options
(gnc:make-string-option gnc:pagename-general optname-cap-fee-action "d5" opthelp-cap-fee-action "Fee")
gnc:pagename-general optname-cap-fee-action "d5" opthelp-cap-fee-action "Fee"))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option gnc:pagename-general optname-format-cells "e" opthelp-format-cells #t)
gnc:pagename-general optname-format-cells "e" opthelp-format-cells #t))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option gnc:pagename-general optname-format-short "f" opthelp-format-short #t)
gnc:pagename-general optname-format-short "f" opthelp-format-short #t))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option gnc:pagename-general optname-cap-purch-costs "g" opthelp-cap-purch-costs #t)
gnc:pagename-general optname-cap-purch-costs "g" opthelp-cap-purch-costs #t))
options)) options))
@ -297,8 +285,8 @@ the split action field to detect capitalized fees on stock activity")
(define (ifrs-cost-basis-renderer report-obj) (define (ifrs-cost-basis-renderer report-obj)
(define (opt-val section name) (define (opt-val section name)
(gnc:option-value (gnc-optiondb-lookup-value
(gnc:lookup-option (gnc:report-options report-obj) section name))) (gnc:report-options report-obj) section name))
(define opt-startdate (opt-val gnc:pagename-general optname-startdate)) (define opt-startdate (opt-val gnc:pagename-general optname-startdate))
(define opt-enddate (opt-val gnc:pagename-general optname-enddate)) (define opt-enddate (opt-val gnc:pagename-general optname-enddate))

View File

@ -136,20 +136,15 @@
;; options generator ;; options generator
(define (income-statement-options-generator-internal reportname) (define (income-statement-options-generator-internal reportname)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb))
(book (gnc-get-current-book)) ; XXX Find a way to get the book that opened the report (book (gnc-get-current-book)))
(add-option
(lambda (new-option) (gnc-register-string-option options
(gnc:register-option options new-option))))
(add-option
(gnc:make-string-option
gnc:pagename-general optname-report-title gnc:pagename-general optname-report-title
"a" opthelp-report-title (G_ reportname))) "a" opthelp-report-title (G_ reportname))
(add-option (gnc-register-string-option options
(gnc:make-string-option
gnc:pagename-general optname-party-name gnc:pagename-general optname-party-name
"b" opthelp-party-name (or (gnc:company-info book gnc:*company-name*) ""))) "b" opthelp-party-name (or (gnc:company-info book gnc:*company-name*) ""))
;; period over which to report income ;; period over which to report income
(gnc:options-add-date-interval! (gnc:options-add-date-interval!
@ -157,24 +152,21 @@
optname-start-date optname-end-date "c") optname-start-date optname-end-date "c")
;; accounts to work on ;; accounts to work on
(add-option (gnc-register-account-list-option options
(gnc:make-account-list-option
gnc:pagename-accounts optname-accounts gnc:pagename-accounts optname-accounts
"a" "a"
opthelp-accounts opthelp-accounts
(lambda ()
(gnc:filter-accountlist-type (gnc:filter-accountlist-type
;; select, by default, only income and expense accounts ;; select, by default, only income and expense accounts
(list ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE) (list ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE)
(gnc-account-get-descendants-sorted (gnc-get-current-root-account)))) (gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
#f #t))
(gnc:options-add-account-levels! (gnc:options-add-account-levels!
options gnc:pagename-accounts optname-depth-limit options gnc:pagename-accounts optname-depth-limit
"b" opthelp-depth-limit 3) "b" opthelp-depth-limit 3)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-accounts optname-bottom-behavior gnc:pagename-accounts optname-bottom-behavior
"c" opthelp-bottom-behavior #f)) "c" opthelp-bottom-behavior #f)
;; all about currencies ;; all about currencies
(gnc:options-add-currency! (gnc:options-add-currency!
@ -184,26 +176,22 @@
(gnc:options-add-price-source! (gnc:options-add-price-source!
options pagename-commodities options pagename-commodities
optname-price-source "b" 'pricedb-nearest) optname-price-source "b" 'pricedb-nearest)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-commodities optname-show-foreign pagename-commodities optname-show-foreign
"c" opthelp-show-foreign #t)) "c" opthelp-show-foreign #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-commodities optname-show-rates pagename-commodities optname-show-rates
"d" opthelp-show-rates #f)) "d" opthelp-show-rates #f)
;; what to show for zero-balance accounts ;; what to show for zero-balance accounts
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-show-zb-accts gnc:pagename-display optname-show-zb-accts
"a" opthelp-show-zb-accts #t)) "a" opthelp-show-zb-accts #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-omit-zb-bals gnc:pagename-display optname-omit-zb-bals
"b" opthelp-omit-zb-bals #f)) "b" opthelp-omit-zb-bals #f)
;; what to show for non-leaf accounts ;; what to show for non-leaf accounts
(gnc:options-add-subtotal-view! (gnc:options-add-subtotal-view!
options gnc:pagename-display options gnc:pagename-display
@ -211,68 +199,55 @@
"c") "c")
;; some detailed formatting options ;; some detailed formatting options
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-account-links gnc:pagename-display optname-account-links
"e" opthelp-account-links #t)) "e" opthelp-account-links #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-use-rules gnc:pagename-display optname-use-rules
"f" opthelp-use-rules #f)) "f" opthelp-use-rules #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-label-revenue gnc:pagename-display optname-label-revenue
"g" opthelp-label-revenue #t)) "g" opthelp-label-revenue #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-total-revenue gnc:pagename-display optname-total-revenue
"h" opthelp-total-revenue #t)) "h" opthelp-total-revenue #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-label-trading gnc:pagename-display optname-label-trading
"h1" opthelp-label-trading #t)) "h1" opthelp-label-trading #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-total-trading gnc:pagename-display optname-total-trading
"h2" opthelp-total-trading #t)) "h2" opthelp-total-trading #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-label-expense gnc:pagename-display optname-label-expense
"i" opthelp-label-expense #t)) "i" opthelp-label-expense #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-total-expense gnc:pagename-display optname-total-expense
"j" opthelp-total-expense #t)) "j" opthelp-total-expense #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-two-column gnc:pagename-display optname-two-column
"k" opthelp-two-column #f)) "k" opthelp-two-column #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-standard-order gnc:pagename-display optname-standard-order
"l" opthelp-standard-order #t)) "l" opthelp-standard-order #t)
;; closing entry match criteria ;; closing entry match criteria
;; ;;
;; N.B.: transactions really should have a field where we can put ;; N.B.: transactions really should have a field where we can put
;; transaction types like "Adjusting/Closing/Correcting Entries" ;; transaction types like "Adjusting/Closing/Correcting Entries"
(add-option (gnc-register-string-option options
(gnc:make-string-option
pagename-entries optname-closing-pattern pagename-entries optname-closing-pattern
"a" opthelp-closing-pattern (G_ "Closing Entries"))) "a" opthelp-closing-pattern (G_ "Closing Entries"))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-entries optname-closing-casing pagename-entries optname-closing-casing
"b" opthelp-closing-casing #f)) "b" opthelp-closing-casing #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-entries optname-closing-regexp pagename-entries optname-closing-regexp
"c" opthelp-closing-regexp #f)) "c" opthelp-closing-regexp #f)
;; Set the accounts page as default option tab ;; Set the accounts page as default option tab
(gnc:options-set-default-section options gnc:pagename-accounts) (gnc:options-set-default-section options gnc:pagename-accounts)
@ -286,9 +261,8 @@
(define (income-statement-renderer-internal report-obj reportname) (define (income-statement-renderer-internal report-obj reportname)
(define (get-option pagename optname) (define (get-option pagename optname)
(gnc:option-value (gnc-optiondb-lookup-value
(gnc:lookup-option (gnc:report-options report-obj) pagename optname))
(gnc:report-options report-obj) pagename optname)))
(gnc:report-starting reportname) (gnc:report-starting reportname)

View File

@ -69,8 +69,7 @@
(define (build-column-used options) (define (build-column-used options)
(define (opt-val section name) (define (opt-val section name)
(gnc:option-value (gnc-optiondb-lookup-value options section name))
(gnc:lookup-option options section name)))
(vector (vector
(opt-val "Display Columns" "Date") (opt-val "Display Columns" "Date")
(opt-val "Display Columns" "Description") (opt-val "Display Columns" "Description")
@ -167,218 +166,178 @@
(gnc:multiline-to-html-text str)) (gnc:multiline-to-html-text str))
(define (options-generator variant) (define (options-generator variant)
(let ((options (gnc-new-optiondb)))
(define gnc:*report-options* (gnc:new-options)) (gnc-register-invoice-option options
gnc:pagename-general
gnc:optname-invoice-number "x" "" '())
(define (gnc:register-inv-option new-option) (gnc-register-string-option options
(gnc:register-option gnc:*report-options* new-option))
(gnc:register-inv-option
(gnc:make-invoice-option gnc:pagename-general gnc:optname-invoice-number "x" ""
(lambda () '()) #f))
(gnc:register-inv-option
(gnc:make-string-option
gnc:pagename-general (N_ "Custom Title") gnc:pagename-general (N_ "Custom Title")
"z" (N_ "A custom string to replace Invoice, Bill or Expense Voucher.") "z" (N_ "A custom string to replace Invoice, Bill or Expense Voucher.")
"")) "")
(gnc:register-inv-option (gnc-register-text-option options
(gnc:make-text-option
(N_ "Layout") (N_ "CSS") "zz" (N_ "CSS code. This field specifies the CSS code \ (N_ "Layout") (N_ "CSS") "zz" (N_ "CSS code. This field specifies the CSS code \
for styling the invoice. Please see the exported report for the CSS class names.") for styling the invoice. Please see the exported report for the CSS class names.")
(keylist-get-info variant-list variant 'css))) (keylist-get-info variant-list variant 'css))
(gnc:register-inv-option (gnc-register-pixmap-option options
(gnc:make-pixmap-option
(N_ "Layout") (N_ "Picture Location") "zy" (N_ "Location for Picture") (N_ "Layout") (N_ "Picture Location") "zy" (N_ "Location for Picture")
"")) "")
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") (N_ "Date") (N_ "Display Columns") (N_ "Date")
"b" (N_ "Display the date?") #t)) "b" (N_ "Display the date?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") (N_ "Description") (N_ "Display Columns") (N_ "Description")
"d" (N_ "Display the description?") #t)) "d" (N_ "Display the description?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") (N_ "Action") (N_ "Display Columns") (N_ "Action")
"g" (N_ "Display the action?") #t)) "g" (N_ "Display the action?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") (N_ "Quantity") (N_ "Display Columns") (N_ "Quantity")
"ha" (N_ "Display the quantity of items?") #t)) "ha" (N_ "Display the quantity of items?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") (N_ "Price") (N_ "Display Columns") (N_ "Price")
"hb" (N_ "Display the price per item?") #t)) "hb" (N_ "Display the price per item?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") (N_ "Discount") (N_ "Display Columns") (N_ "Discount")
"k" (N_ "Display the entry's discount?") #t)) "k" (N_ "Display the entry's discount?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") (N_ "Taxable") (N_ "Display Columns") (N_ "Taxable")
"l" (N_ "Display the entry's taxable status?") #t)) "l" (N_ "Display the entry's taxable status?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") (N_ "Tax Amount") (N_ "Display Columns") (N_ "Tax Amount")
"m" (N_ "Display each entry's total total tax?") #f)) "m" (N_ "Display each entry's total total tax?") #f)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") (N_ "Total") (N_ "Display Columns") (N_ "Total")
"n" (N_ "Display the entry's value?") #t)) "n" (N_ "Display the entry's value?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Due Date") (N_ "Display") (N_ "Due Date")
"c" (N_ "Display due date?") #t)) "c" (N_ "Display due date?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Subtotal") (N_ "Display") (N_ "Subtotal")
"d" (N_ "Display the subtotals?") #t)) "d" (N_ "Display the subtotals?") #t)
(gnc:register-inv-option (gnc-register-complex-boolean-option options
(gnc:make-complex-boolean-option
(N_ "Display") (N_ "Payable to") (N_ "Display") (N_ "Payable to")
"ua1" (N_ "Display the Payable to: information.") #f #f "ua1" (N_ "Display the Payable to: information.") #f
(lambda (x) (lambda (x)
(gnc-option-db-set-option-selectable-by-name (gnc-optiondb-set-option-selectable-by-name
gnc:*report-options* "Display" "Payable to string" x)))) options "Display" "Payable to string" x)))
(gnc:register-inv-option (gnc-register-text-option options
(gnc:make-text-option
(N_ "Display") (N_ "Payable to string") (N_ "Display") (N_ "Payable to string")
"ua2" (N_ "The phrase for specifying to whom payments should be made.") "ua2" (N_ "The phrase for specifying to whom payments should be made.")
(G_ "Please make all checks payable to"))) (G_ "Please make all checks payable to"))
(gnc:register-inv-option (gnc-register-complex-boolean-option options
(gnc:make-complex-boolean-option
(N_ "Display") (N_ "Company contact") (N_ "Display") (N_ "Company contact")
"ub1" (N_ "Display the Company contact information.") #f #f "ub1" (N_ "Display the Company contact information.") #f
(lambda (x) (gnc-option-db-set-option-selectable-by-name (lambda (x) (gnc-optiondb-set-option-selectable-by-name
gnc:*report-options* "Display" "Company contact string" x)))) options "Display" "Company contact string" x)))
(gnc:register-inv-option (gnc-register-text-option options
(gnc:make-text-option
(N_ "Display") (N_ "Company contact string") (N_ "Display") (N_ "Company contact string")
"ub2" (N_ "The phrase used to introduce the company contact.") "ub2" (N_ "The phrase used to introduce the company contact.")
(G_ "Please direct all enquiries to"))) (G_ "Please direct all enquiries to"))
(gnc:register-inv-option (gnc-register-number-range-option options
(gnc:make-number-range-option
(N_ "Display") (N_ "Minimum # of entries") (N_ "Display") (N_ "Minimum # of entries")
"zz" (N_ "The minimum number of invoice entries to display.") 1 "zz" (N_ "The minimum number of invoice entries to display.") 1
0 23 0 1)) 0 23 1)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Use Detailed Tax Summary") (N_ "Display") (N_ "Use Detailed Tax Summary")
"o" (N_ "Display all tax categories separately (one per line) instead of one single tax line.?") #f)) "o" (N_ "Display all tax categories separately (one per line) instead of one single tax line.?") #f)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "References") (N_ "Display") (N_ "References")
"s" (N_ "Display the invoice references?") #t)) "s" (N_ "Display the invoice references?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Billing Terms") (N_ "Display") (N_ "Billing Terms")
"t" (N_ "Display the invoice billing terms?") #t)) "t" (N_ "Display the invoice billing terms?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Billing ID") (N_ "Display") (N_ "Billing ID")
"ta" (N_ "Display the billing id?") #t)) "ta" (N_ "Display the billing id?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Invoice owner ID") (N_ "Display") (N_ "Invoice owner ID")
"tam" (N_ "Display the customer/vendor id?") #f)) "tam" (N_ "Display the customer/vendor id?") #f)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Invoice Notes") (N_ "Display") (N_ "Invoice Notes")
"tb" (N_ "Display the invoice notes?") #f)) "tb" (N_ "Display the invoice notes?") #f)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Payments") (N_ "Display") (N_ "Payments")
"tc" (N_ "Display the payments applied to this invoice?") #t)) "tc" (N_ "Display the payments applied to this invoice?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Job Details") (N_ "Display") (N_ "Job Details")
"td" (N_ "Display the job name for this invoice?") #f)) "td" (N_ "Display the job name for this invoice?") #f)
(gnc:register-inv-option (gnc-register-text-option options
(gnc:make-text-option
(N_ "Display") (N_ "Extra Notes") (N_ "Display") (N_ "Extra Notes")
"u" (N_ "Extra notes to put on the invoice.") "u" (N_ "Extra notes to put on the invoice.")
(G_ "Thank you for your patronage!"))) (G_ "Thank you for your patronage!"))
(gnc:register-inv-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
(N_ "Layout") (N_ "Row 1 Left") (N_ "Layout") (N_ "Row 1 Left")
"1a" "1st row, left" "1a" "1st row, left"
(keylist-get-info variant-list variant '1a) (symbol->string (keylist-get-info variant-list variant '1a))
(keylist->vectorlist layout-key-list))) (keylist->vectorlist layout-key-list))
(gnc:register-inv-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
(N_ "Layout") (N_ "Row 1 Right") (N_ "Layout") (N_ "Row 1 Right")
"1b" "1st row, right" "1b" "1st row, right"
(keylist-get-info variant-list variant '1b) (symbol->string (keylist-get-info variant-list variant '1b))
(keylist->vectorlist layout-key-list))) (keylist->vectorlist layout-key-list))
(gnc:register-inv-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
(N_ "Layout") (N_ "Row 2 Left") (N_ "Layout") (N_ "Row 2 Left")
"2a" "2nd row, left" "2a" "2nd row, left"
(keylist-get-info variant-list variant '2a) (symbol->string (keylist-get-info variant-list variant '2a))
(keylist->vectorlist layout-key-list))) (keylist->vectorlist layout-key-list))
(gnc:register-inv-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
(N_ "Layout") (N_ "Row 2 Right") (N_ "Layout") (N_ "Row 2 Right")
"2b" "2nd row, right" "2b" "2nd row, right"
(keylist-get-info variant-list variant '2b) (symbol->string (keylist-get-info variant-list variant '2b))
(keylist->vectorlist layout-key-list))) (keylist->vectorlist layout-key-list))
(gnc:register-inv-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
(N_ "Layout") (N_ "Row 3 Left") (N_ "Layout") (N_ "Row 3 Left")
"3a" "3rd row, left" "3a" "3rd row, left"
(keylist-get-info variant-list variant '3a) (symbol->string (keylist-get-info variant-list variant '3a))
(keylist->vectorlist layout-key-list))) (keylist->vectorlist layout-key-list))
(gnc:register-inv-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
(N_ "Layout") (N_ "Row 3 Right") (N_ "Layout") (N_ "Row 3 Right")
"3b" "3rd row, right" "3b" "3rd row, right"
(keylist-get-info variant-list variant '3b) (symbol->string (keylist-get-info variant-list variant '3b))
(keylist->vectorlist layout-key-list))) (keylist->vectorlist layout-key-list))
(gnc:options-set-default-section gnc:*report-options* "General") (gnc:options-set-default-section options "General")
gnc:*report-options*)
options))
(define (make-entry-table invoice options cust-doc? credit-note?) (define (make-entry-table invoice options cust-doc? credit-note?)
(define (opt-val section name) (define (opt-val section name)
(gnc:option-value (gnc-optiondb-lookup-value options section name))
(gnc:lookup-option options section name)))
(let ((show-payments (opt-val "Display" "Payments")) (let ((show-payments (opt-val "Display" "Payments"))
(display-all-taxes (opt-val "Display" "Use Detailed Tax Summary")) (display-all-taxes (opt-val "Display" "Use Detailed Tax Summary"))
@ -574,8 +533,7 @@ for styling the invoice. Please see the exported report for the CSS class names.
(define (make-invoice-details-table invoice options) (define (make-invoice-details-table invoice options)
;; dual-column. invoice date/due, billingID, terms, job name/number ;; dual-column. invoice date/due, billingID, terms, job name/number
(define (opt-val section name) (define (opt-val section name)
(gnc:option-value (gnc-optiondb-lookup-value options section name))
(gnc:lookup-option options section name)))
(let* ((invoice-details-table (gnc:make-html-table)) (let* ((invoice-details-table (gnc:make-html-table))
(book (gncInvoiceGetBook invoice)) (book (gncInvoiceGetBook invoice))
(date-format (gnc:options-fancy-date book)) (date-format (gnc:options-fancy-date book))
@ -648,8 +606,7 @@ for styling the invoice. Please see the exported report for the CSS class names.
(define (make-client-table owner orders options) (define (make-client-table owner orders options)
(define (opt-val section name) (define (opt-val section name)
(gnc:option-value (gnc-optiondb-lookup-value options section name))
(gnc:lookup-option options section name)))
;; this is a single-column table. ;; this is a single-column table.
(let ((table (gnc:make-html-table))) (let ((table (gnc:make-html-table)))
@ -702,7 +659,7 @@ for styling the invoice. Please see the exported report for the CSS class names.
(fax (gnc:company-info book gnc:*company-fax*)) (fax (gnc:company-info book gnc:*company-fax*))
(email (gnc:company-info book gnc:*company-email*)) (email (gnc:company-info book gnc:*company-email*))
(url (gnc:company-info book gnc:*company-url*)) (url (gnc:company-info book gnc:*company-url*))
(taxnr (gnc:option-get-value book gnc:*tax-label* gnc:*tax-nr-label*)) (taxnr (gnc:book-get-option-value book gnc:*tax-label* gnc:*tax-nr-label*))
(taxid (gnc:company-info book gnc:*company-id*))) (taxid (gnc:company-info book gnc:*company-id*)))
(if (and name (not (string-null? name))) (if (and name (not (string-null? name)))
@ -750,7 +707,7 @@ for styling the invoice. Please see the exported report for the CSS class names.
(define (reg-renderer report-obj) (define (reg-renderer report-obj)
(let* ((document (gnc:make-html-document)) (let* ((document (gnc:make-html-document))
(options (gnc:report-options report-obj)) (options (gnc:report-options report-obj))
(opt-val (lambda (section name) (gnc:option-value (gnc:lookup-option options section name)))) (opt-val (lambda (section name) (gnc-optiondb-lookup-value options section name)))
(invoice (opt-val gnc:pagename-general gnc:optname-invoice-number)) (invoice (opt-val gnc:pagename-general gnc:optname-invoice-number))
(references? (opt-val "Display" "References")) (references? (opt-val "Display" "References"))
(custom-title (opt-val gnc:pagename-general "Custom Title"))) (custom-title (opt-val gnc:pagename-general "Custom Title")))

View File

@ -44,25 +44,20 @@
(cons TXN-TYPE-LINK "Link"))) (cons TXN-TYPE-LINK "Link")))
(define (options-generator) (define (options-generator)
(let ((options (gnc:new-options))) (let ((options (gnc-new-optiondb)))
(define (add-option new-option)
(gnc:register-option options new-option))
;; General tab ;; General tab
(gnc:options-add-date-interval! (gnc:options-add-date-interval!
options gnc:pagename-general options gnc:pagename-general
optname-from-date optname-to-date "a") optname-from-date optname-to-date "a")
(add-option (gnc-register-account-sel-limited-option options
(gnc:make-account-sel-option
gnc:pagename-general optname-account "b" gnc:pagename-general optname-account "b"
(N_ "The account to search for lots.") (N_ "The account to search for lots.")
#f #f)) '() '())
(add-option (gnc-register-string-option options
(gnc:make-string-option gnc:pagename-general optname-desc-filter "b" "Description Filter" "")
gnc:pagename-general optname-desc-filter "b" "Description Filter" ""))
options)) options))
@ -70,8 +65,7 @@
;; This is a helper function for looking up option values. ;; This is a helper function for looking up option values.
(define (get-option section name) (define (get-option section name)
(gnc:option-value (gnc-optiondb-lookup-value (gnc:report-options report-obj) section name))
(gnc:lookup-option (gnc:report-options report-obj) section name)))
(define (get-all-lots splits) (define (get-all-lots splits)
(define lots-seen (make-hash-table)) (define lots-seen (make-hash-table))

View File

@ -62,12 +62,7 @@
(define optname-y-grid (N_ "Grid")) (define optname-y-grid (N_ "Grid"))
(define (options-generator inc-exp? linechart?) (define (options-generator inc-exp? linechart?)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb)))
;; This is just a helper function for making options.
;; See libgnucash/scm/options.scm for details.
(add-option
(lambda (new-option)
(gnc:register-option options new-option))))
;; General tab ;; General tab
(gnc:options-add-date-interval! (gnc:options-add-date-interval!
@ -85,54 +80,44 @@
optname-price-source "d" 'weighted-average) optname-price-source "d" 'weighted-average)
;; Account tab ;; Account tab
(add-option
(gnc:make-account-list-option (gnc-register-account-list-option
gnc:pagename-accounts optname-accounts options gnc:pagename-accounts optname-accounts
"a" "a"
(N_ "Report on these accounts, if chosen account level allows.") (N_ "Report on these accounts, if chosen account level allows.")
(lambda () (if inc-exp?
(filter (gnc:filter-accountlist-type
(if inc-exp? (list ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE)
gnc:account-is-inc-exp? (gnc-account-get-descendants-sorted (gnc-get-current-root-account)))
(lambda (account) (not (gnc:account-is-inc-exp? account))))
(gnc-account-get-descendants-sorted (gnc-get-current-root-account)))) (filter
(lambda (accounts) (lambda (account) (not (gnc:account-is-inc-exp? account)))
(list #t (gnc-account-get-descendants-sorted (gnc-get-current-root-account)))))
(filter
(if inc-exp?
gnc:account-is-inc-exp?
(lambda (account)
(not (gnc:account-is-inc-exp? account))))
accounts)))
#t))
;; Display tab ;; Display tab
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display gnc:pagename-display
(if inc-exp? optname-inc-exp optname-sep-bars) (if inc-exp? optname-inc-exp optname-sep-bars)
"a" "a"
(if inc-exp? (if inc-exp?
(N_ "Show Income and Expenses?") (N_ "Show Income and Expenses?")
(N_ "Show the Asset and the Liability bars?")) (N_ "Show the Asset and the Liability bars?"))
#t)) #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display gnc:pagename-display
(if inc-exp? optname-show-profit optname-net-bars) (if inc-exp? optname-show-profit optname-net-bars)
"b" "b"
(if inc-exp? (if inc-exp?
(N_ "Show the net profit?") (N_ "Show the net profit?")
(N_ "Show a Net Worth bar?")) (N_ "Show a Net Worth bar?"))
#t)) #t)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display gnc:pagename-display
(N_ "Show table") (N_ "Show table")
"c" (N_ "Display a table of the selected data.") "c" (N_ "Display a table of the selected data.")
#f)) #f)
(gnc:options-add-plot-size! (gnc:options-add-plot-size!
options gnc:pagename-display options gnc:pagename-display
@ -141,30 +126,25 @@
(if linechart? (if linechart?
(begin (begin
(add-option (gnc-register-number-range-option options
(gnc:make-number-range-option
gnc:pagename-display optname-line-width gnc:pagename-display optname-line-width
"e" opthelp-line-width "e" opthelp-line-width
1.5 0.5 5 1 0.1 )) 1.5 0.5 5 0.1 )
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-y-grid gnc:pagename-display optname-y-grid
"f" (N_ "Add grid lines.") "f" (N_ "Add grid lines.")
#t)) #t)
;;(add-option ;;(gnc-register-simple-boolean-option options
;; (gnc:make-simple-boolean-option
;; gnc:pagename-display optname-x-grid ;; gnc:pagename-display optname-x-grid
;; "g" (N_ "Add vertical grid lines.") ;; "g" (N_ "Add vertical grid lines.")
;; #f)) ;; #f))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-markers gnc:pagename-display optname-markers
"g" (N_ "Display a mark for each data point.") "g" (N_ "Display a mark for each data point.")
#t)) #t)
)) ))
(gnc:options-set-default-section options gnc:pagename-general) (gnc:options-set-default-section options gnc:pagename-general)
@ -181,8 +161,7 @@
;; This is a helper function for looking up option values. ;; This is a helper function for looking up option values.
(define (get-option section name) (define (get-option section name)
(gnc:option-value (gnc-optiondb-lookup-value (gnc:report-options report-obj) section name))
(gnc:lookup-option (gnc:report-options report-obj) section name)))
(gnc:report-starting "INC/EXP & A/L Charts") (gnc:report-starting "INC/EXP & A/L Charts")
(let* ((to-date-t64 (gnc:time64-end-day-time (let* ((to-date-t64 (gnc:time64-end-day-time

View File

@ -76,60 +76,55 @@ exist but have no suitable transactions."))
(qof-query-set-sort-increasing query #t #t #t)) (qof-query-set-sort-increasing query #t #t #t))
(define (aging-options-generator options) (define (aging-options-generator options)
(let* ((add-option
(lambda (new-option)
(gnc:register-option options new-option))))
(gnc:options-add-report-date! (gnc:options-add-report-date!
options gnc:pagename-general optname-to-date "a") options gnc:pagename-general optname-to-date "a")
;; Use a default report date of 'today' ;; Use a default report date of 'today'
(gnc:option-set-default-value (GncOption-set-default-value
(gnc:lookup-option options gnc:pagename-general optname-to-date) (gnc-lookup-option options gnc:pagename-general optname-to-date)
(cons 'relative 'today)) (cons 'relative 'today))
(add-option (gnc-register-multichoice-option
(gnc:make-multichoice-option options
gnc:pagename-general optname-sort-by "i" (N_ "Sort companies by.") 'name gnc:pagename-general optname-sort-by "i" (N_ "Sort companies by.")
"name"
(list (list
(vector 'name (N_ "Name of the company")) (vector 'name (N_ "Name of the company"))
(vector 'total (N_ "Total amount owed to/from Company")) (vector 'total (N_ "Total amount owed to/from Company"))
(vector 'oldest-bracket (N_ "Bracket Total Owed"))))) (vector 'oldest-bracket (N_ "Bracket Total Owed"))))
(add-option (gnc-register-multichoice-option
(gnc:make-multichoice-option options gnc:pagename-general optname-sort-order "ia" (N_ "Sort order.")
gnc:pagename-general optname-sort-order "ia" (N_ "Sort order.") 'increasing "increasing"
(list (list
(vector 'increasing (N_ "Ascending")) (vector 'increasing (N_ "Ascending"))
(vector 'decreasing (N_ "Descending"))))) (vector 'decreasing (N_ "Descending"))))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-general optname-show-zeros "j" gnc:pagename-general optname-show-zeros "j"
(N_ "Show all vendors/customers even if they have a zero balance.") (N_ "Show all vendors/customers even if they have a zero balance.")
#f)) #f)
(add-option (gnc-register-multichoice-option
(gnc:make-multichoice-option options gnc:pagename-general optname-date-driver "k" (N_ "Leading date.")
gnc:pagename-general optname-date-driver "k" (N_ "Leading date.") 'duedate "duedate"
(list (list
(vector 'duedate (N_ "Due Date")) (vector 'duedate (N_ "Due Date"))
(vector 'postdate (N_ "Post Date"))))) (vector 'postdate (N_ "Post Date"))))
(gnc:options-set-default-section options "General") (gnc:options-set-default-section options "General")
(for-each (for-each
(lambda (opt) (lambda (opt)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option gnc:pagename-display (car opt) (cadr opt) (caddr opt) #f))
gnc:pagename-display (car opt) (cadr opt) (caddr opt) #f)))
addr-options-list) addr-options-list)
options)) options)
(define (options->address options receivable? owner) (define (options->address options receivable? owner)
(define (op-value name) (define (op-value name)
(gnc:option-value (gnc:lookup-option options gnc:pagename-display name))) (gnc-optiondb-lookup-value options gnc:pagename-display name))
(let* ((address-list-names (map car addr-options-list)) (let* ((address-list-names (map car addr-options-list))
(address-list-options (map op-value address-list-names)) (address-list-options (map op-value address-list-names))
(addr-source (if receivable? (op-value optname-addr-source) 'billing)) (addr-source (if receivable? (op-value optname-addr-source) 'billing))
@ -173,7 +168,7 @@ exist but have no suitable transactions."))
(define (aging-renderer report-obj receivable) (define (aging-renderer report-obj receivable)
(define options (gnc:report-options report-obj)) (define options (gnc:report-options report-obj))
(define (op-value section name) (define (op-value section name)
(gnc:option-value (gnc:lookup-option options section name))) (gnc-optiondb-lookup-value options section name))
(define make-heading-list (define make-heading-list
(list (G_ "Company") (list (G_ "Company")
@ -390,19 +385,18 @@ exist but have no suitable transactions."))
document)) document))
(define (payable-options-generator) (define (payable-options-generator)
(aging-options-generator (gnc:new-options))) (aging-options-generator (gnc-new-optiondb)))
(define (receivable-options-generator) (define (receivable-options-generator)
(let ((options (aging-options-generator (gnc:new-options)))) (let ((options (aging-options-generator (gnc-new-optiondb))))
(define (add-option new-option)
(gnc:register-option options new-option))
(add-option (gnc-register-multichoice-option
(gnc:make-multichoice-option options gnc:pagename-display optname-addr-source "a"
gnc:pagename-display optname-addr-source "a" (N_ "Address source.") 'billing (N_ "Address source.")
(list "billing"
(vector 'billing (N_ "Billing address")) (list
(vector 'shipping (N_ "Shipping address"))))) (vector 'billing (N_ "Billing address"))
(vector 'shipping (N_ "Shipping address"))))
options)) options))
(define (payables-renderer report-obj) (define (payables-renderer report-obj)
@ -433,19 +427,17 @@ exist but have no suitable transactions."))
'in-menu? #t) 'in-menu? #t)
(define (receivables-report-create-internal acct title show-zeros?) (define (receivables-report-create-internal acct title show-zeros?)
(let* ((options (gnc:make-report-options receivables-aging-guid)) (let* ((options (gnc:make-report-options receivables-aging-guid)))
(zero-op (gnc:lookup-option options gnc:pagename-general optname-show-zeros)) (when title (gnc-set-option-set-value
(title-op (gnc:lookup-option options gnc:pagename-general gnc:optname-reportname))) options gnc:pagename-general gnc:optname-reportname title))
(when title (gnc:option-set-value title-op title)) (gnc-set-option options gnc:pagename-general optname-show-zeros show-zeros?)
(gnc:option-set-value zero-op show-zeros?)
(gnc:make-report receivables-aging-guid options))) (gnc:make-report receivables-aging-guid options)))
(define (payables-report-create-internal acct title show-zeros?) (define (payables-report-create-internal acct title show-zeros?)
(let* ((options (gnc:make-report-options payables-aging-guid)) (let* ((options (gnc:make-report-options payables-aging-guid)))
(zero-op (gnc:lookup-option options gnc:pagename-general optname-show-zeros)) (when title (gnc-set-option
(title-op (gnc:lookup-option options gnc:pagename-general gnc:optname-reportname))) options gnc:pagename-general gnc:optname-reportname title))
(when title (gnc:option-set-value title-op title)) (gnc-set-option options gnc:pagename-general optname-show-zeros show-zeros?)
(gnc:option-set-value zero-op show-zeros?)
(gnc:make-report payables-aging-guid options))) (gnc:make-report payables-aging-guid options)))
(define (gnc:receivables-create-internal (define (gnc:receivables-create-internal

View File

@ -186,8 +186,7 @@
(define (build-column-used options) (define (build-column-used options)
(define (opt-val name) (define (opt-val name)
(gnc:option-value (gnc-optiondb-lookup-value options "Display Columns" name))
(gnc:lookup-option options "Display Columns" name)))
(list->vector (list->vector
(map opt-val (map opt-val
(list date-header due-date-header reference-header type-header (list date-header due-date-header reference-header type-header
@ -856,79 +855,62 @@ and do not match the transaction."))))))))
sale)))))) sale))))))
(define (options-generator owner-type) (define (options-generator owner-type)
(let ((options (gnc-new-optiondb)))
(define gnc:*report-options* (gnc:new-options)) (gnc-register-owner-option options
(define (gnc:register-inv-option new-option)
(gnc:register-option gnc:*report-options* new-option))
(gnc:register-inv-option
(gnc:make-owner-option
owner-page (owner-string owner-type) "v" owner-page (owner-string owner-type) "v"
(N_ "The company for this report.") (N_ "The company for this report.") '() owner-type)
(lambda () '()) #f owner-type))
(gnc:options-add-date-interval! (gnc:options-add-date-interval!
gnc:*report-options* gnc:pagename-general options gnc:pagename-general
optname-from-date optname-to-date "a") optname-from-date optname-to-date "a")
;; Use a default report date of 'today' ;; Use a default report date of 'today'
(gnc:option-set-default-value (GncOption-set-default-value
(gnc:lookup-option gnc:*report-options* gnc:pagename-general optname-to-date) (gnc-lookup-option options gnc:pagename-general optname-to-date)
(cons 'relative 'today)) (cons 'relative 'today))
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") date-header (N_ "Display Columns") date-header
"b" (N_ "Display the transaction date?") #t)) "b" (N_ "Display the transaction date?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") due-date-header (N_ "Display Columns") due-date-header
"c" (N_ "Display the transaction date?") #t)) "c" (N_ "Display the transaction date?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") reference-header (N_ "Display Columns") reference-header
"d" (N_ "Display the transaction reference?") #t)) "d" (N_ "Display the transaction reference?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") type-header (N_ "Display Columns") type-header
"g" (N_ "Display the transaction type?") #t)) "g" (N_ "Display the transaction type?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") desc-header (N_ "Display Columns") desc-header
"ha" (N_ "Display the transaction description?") #t)) "ha" (N_ "Display the transaction description?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") sale-header (N_ "Display Columns") sale-header
"haa" (N_ "Display the sale amount column?") #f)) "haa" (N_ "Display the sale amount column?") #f)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") tax-header (N_ "Display Columns") tax-header
"hab" (N_ "Display the tax column?") #f)) "hab" (N_ "Display the tax column?") #f)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") debit-header (N_ "Display Columns") debit-header
"hac" (N_ "Display the period debits column?") #t)) "hac" (N_ "Display the period debits column?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") credit-header (N_ "Display Columns") credit-header
"had" (N_ "Display the period credits column?") #t)) "had" (N_ "Display the period credits column?") #t)
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") balance-header (N_ "Display Columns") balance-header
"hb" (N_ "Display a running balance?") #t)) "hb" (N_ "Display a running balance?") #t)
(gnc:register-inv-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
(N_ "Display Columns") linked-txns-header (N_ "Display Columns") linked-txns-header
"hc" "hc"
(string-join (string-join
@ -938,27 +920,25 @@ and do not match the transaction."))))))))
(G_ "Invoices show if paid, payments show invoice numbers.") (G_ "Invoices show if paid, payments show invoice numbers.")
(G_ "Invoices show list of payments, payments show list of invoices and amounts.")) (G_ "Invoices show list of payments, payments show list of invoices and amounts."))
"\n* ") "\n* ")
'none "none"
(list (vector 'none (N_ "Disabled")) (list (vector 'none (N_ "Disabled"))
(vector 'simple (N_ "Simple")) (vector 'simple (N_ "Simple"))
(vector 'detailed (N_ "Detailed"))))) (vector 'detailed (N_ "Detailed"))))
(gnc:register-inv-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display Columns") doclink-header (N_ "Display Columns") doclink-header
"hd" (N_ "Display document link?") #f)) "hd" (N_ "Display document link?") #f)
(gnc:register-inv-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
gnc:pagename-general optname-date-driver "k" gnc:pagename-general optname-date-driver "k"
(N_ "Leading date.") 'duedate (N_ "Leading date.") "duedate"
(list (list
(vector 'duedate (N_ "Due Date")) (vector 'duedate (N_ "Due Date"))
(vector 'postdate (N_ "Post Date"))))) (vector 'postdate (N_ "Post Date"))))
(gnc:options-set-default-section gnc:*report-options* "General") (gnc:options-set-default-section options "General")
gnc:*report-options*) options))
(define (setup-query q owner accounts end-date job?) (define (setup-query q owner accounts end-date job?)
(let ((guid (gncOwnerReturnGUID (if job? owner (gncOwnerGetEndOwner owner)))) (let ((guid (gncOwnerReturnGUID (if job? owner (gncOwnerGetEndOwner owner))))
@ -1020,8 +1000,7 @@ and do not match the transaction."))))))))
(define (reg-renderer report-obj type) (define (reg-renderer report-obj type)
(define options (gnc:report-options report-obj)) (define options (gnc:report-options report-obj))
(define (opt-val section name) (define (opt-val section name)
(gnc:option-value (gnc-optiondb-lookup-value options section name))
(gnc:lookup-option options section name)))
(let* ((start-date (gnc:time64-start-day-time (let* ((start-date (gnc:time64-start-day-time
(gnc:date-option-absolute-time (gnc:date-option-absolute-time
@ -1032,9 +1011,7 @@ and do not match the transaction."))))))))
(book (gnc-get-current-book)) (book (gnc-get-current-book))
(date-format (gnc:options-fancy-date (gnc-get-current-book))) (date-format (gnc:options-fancy-date (gnc-get-current-book)))
(used-columns (build-column-used options)) (used-columns (build-column-used options))
(link-option (link-option (opt-val "Display Columns" linked-txns-header))
(gnc:option-value
(gnc:lookup-option options "Display Columns" linked-txns-header)))
(owner-descr (owner-string type)) (owner-descr (owner-string type))
(date-type (opt-val gnc:pagename-general optname-date-driver)) (date-type (opt-val gnc:pagename-general optname-date-driver))
(owner (opt-val owner-page owner-descr)) (owner (opt-val owner-page owner-descr))
@ -1221,13 +1198,12 @@ and do not match the transaction."))))))))
(define (owner-report-create-internal report-guid owner owner-type enddate) (define (owner-report-create-internal report-guid owner owner-type enddate)
(let* ((options (gnc:make-report-options report-guid)) (let* ((options (gnc:make-report-options report-guid)))
(owner-op (gnc:lookup-option options owner-page (owner-string owner-type)))
(date-op (gnc:lookup-option options gnc:pagename-general optname-to-date)))
(gnc:option-set-value owner-op owner) (gnc-set-option options owner-page (owner-string owner-type) owner)
(when enddate (when enddate
(gnc:option-set-value date-op (cons 'absolute enddate))) (gnc-set-option options gnc:pagename-general optname-to-date
(cons 'absolute enddate)))
(gnc:make-report report-guid options))) (gnc:make-report report-guid options)))
(define (owner-report-create-with-enddate owner account enddate) (define (owner-report-create-with-enddate owner account enddate)

View File

@ -37,12 +37,7 @@
(define optname-zero-shares (N_ "Include accounts with no shares")) (define optname-zero-shares (N_ "Include accounts with no shares"))
(define (options-generator) (define (options-generator)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb)))
;; This is just a helper function for making options.
;; See libgnucash/scm/options.scm for details.
(add-option
(lambda (new-option)
(gnc:register-option options new-option))))
;; General Tab ;; General Tab
;; date at which to report balance ;; date at which to report balance
@ -57,31 +52,25 @@
options gnc:pagename-general options gnc:pagename-general
optname-price-source "d" 'pricedb-latest) optname-price-source "d" 'pricedb-latest)
(add-option (gnc-register-number-range-option options
(gnc:make-number-range-option
gnc:pagename-general optname-shares-digits gnc:pagename-general optname-shares-digits
"e" (N_ "The number of decimal places to use for share numbers.") 2 "e" (N_ "The number of decimal places to use for share numbers.") 2
0 9 0 1)) 0 9 1)
;; Account tab ;; Account tab
(add-option (gnc-register-account-list-limited-option options
(gnc:make-account-list-option
gnc:pagename-accounts (N_ "Accounts") gnc:pagename-accounts (N_ "Accounts")
"b" "b"
(N_ "Stock Accounts to report on.") (N_ "Stock Accounts to report on.")
(lambda () (filter gnc:account-is-stock? (gnc:filter-accountlist-type
(gnc-account-get-descendants-sorted (list ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL)
(gnc-get-current-root-account)))) (gnc-account-get-descendants-sorted (gnc-get-current-root-account)))
(lambda (accounts) (list #t (list ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL))
(filter gnc:account-is-stock? accounts)))
#t))
(gnc:register-option (gnc-register-simple-boolean-option options
options
(gnc:make-simple-boolean-option
gnc:pagename-accounts optname-zero-shares "e" gnc:pagename-accounts optname-zero-shares "e"
(N_ "Include accounts that have a zero share balances.") (N_ "Include accounts that have a zero share balances.")
#f)) #f)
(gnc:options-set-default-section options gnc:pagename-general) (gnc:options-set-default-section options gnc:pagename-general)
options)) options))
@ -98,11 +87,9 @@
(work-to-do 0)) (work-to-do 0))
;; These are some helper functions for looking up option values. ;; These are some helper functions for looking up option values.
(define (get-op section name)
(gnc:lookup-option (gnc:report-options report-obj) section name))
(define (get-option section name) (define (get-option section name)
(gnc:option-value (get-op section name))) (gnc-optiondb-lookup-value (gnc:report-options report-obj) section name))
(define (table-add-stock-rows table accounts to-date currency (define (table-add-stock-rows table accounts to-date currency
exchange-fn price-fn include-empty collector) exchange-fn price-fn include-empty collector)

View File

@ -49,11 +49,7 @@
(define optname-plot-height (N_ "Plot Height")) (define optname-plot-height (N_ "Plot Height"))
(define (options-generator) (define (options-generator)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb)))
;; This is just a helper function for making options.
(add-option
(lambda (new-option)
(gnc:register-option options new-option))))
(gnc:options-add-date-interval! (gnc:options-add-date-interval!
options gnc:pagename-general options gnc:pagename-general
@ -65,28 +61,25 @@
(gnc:options-add-currency! (gnc:options-add-currency!
options pagename-price optname-report-currency "d") options pagename-price optname-report-currency "d")
(add-option (gnc-register-commodity-option options
(gnc:make-commodity-option
pagename-price optname-price-commodity pagename-price optname-price-commodity
"e" "e"
(N_ "Calculate the price of this commodity.") (N_ "Calculate the price of this commodity.")
(gnc-locale-default-iso-currency-code))) (gnc-locale-default-iso-currency-code))
(add-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
pagename-price optname-price-source pagename-price optname-price-source
"f" (N_ "The source of price information.") "f" (N_ "The source of price information.")
'actual-transactions "actual-transactions"
(list (vector 'weighted-average (N_ "Weighted Average")) (list (vector 'weighted-average (N_ "Weighted Average"))
(vector 'actual-transactions (N_ "Actual Transactions")) (vector 'actual-transactions (N_ "Actual Transactions"))
(vector 'pricedb (N_ "Price Database"))))) (vector 'pricedb (N_ "Price Database"))))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-price optname-invert pagename-price optname-invert
"g" "g"
(N_ "Plot commodity per currency rather than currency per commodity.") (N_ "Plot commodity per currency rather than currency per commodity.")
#f)) #f)
(gnc:options-add-plot-size! (gnc:options-add-plot-size!
@ -97,13 +90,11 @@
options gnc:pagename-display options gnc:pagename-display
optname-marker "a" 'filledsquare) optname-marker "a" 'filledsquare)
(add-option (gnc-register-color-option options
(gnc:make-color-option
gnc:pagename-display optname-markercolor gnc:pagename-display optname-markercolor
"b" "b"
(N_ "Color of the marker.") (N_ "Color of the marker.")
(list #xb2 #x22 #x22 #xff) "b22222")
255 #f))
(gnc:options-set-default-section options gnc:pagename-general) (gnc:options-set-default-section options gnc:pagename-general)
@ -115,8 +106,7 @@
;; This is a helper function for looking up option values. ;; This is a helper function for looking up option values.
(define (get-option section name) (define (get-option section name)
(gnc:option-value (gnc-optiondb-lookup-value (gnc:report-options report-obj) section name))
(gnc:lookup-option (gnc:report-options report-obj) section name)))
(define intervals (define intervals
(list (list 'DayDelta (G_ "Days") 86400) (list (list 'DayDelta (G_ "Days") 86400)

View File

@ -66,88 +66,85 @@
(define (options-generator) (define (options-generator)
;; Options ;; Options
(define report-options (gnc:new-options)) (let ((options (gnc-new-optiondb)))
(define (add-option new-option)
(gnc:register-option report-options new-option))
(add-option (gnc-register-invoice-option
(gnc:make-invoice-option ; defined in gnucash/scm/business-options.scm options generalpage gnc:optname-invoice-number "a" "" '())
generalpage gnc:optname-invoice-number
"a" "" (lambda () '()) #f))
;; Display options ;; Display options
(add-option (gnc:make-string-option displaypage optname-template-file "a" (gnc-register-string-option
(N_ "The file name of the eguile template part of this report. This file should either be in your .gnucash directory, or else in its proper place within the GnuCash installation directories.") options displaypage optname-template-file "a"
"receipt.eguile.scm")) (N_ "The file name of the eguile template part of this report. This file should either be in your .gnucash directory, or else in its proper place within the GnuCash installation directories.")
(add-option (gnc:make-string-option displaypage optname-css-file "b" "receipt.eguile.scm")
(gnc-register-string-option options
displaypage optname-css-file "b"
(N_ "The file name of the CSS stylesheet to use with this report. This file should either be in your .gnucash directory, or else in its proper place within the GnuCash installation directories.") (N_ "The file name of the CSS stylesheet to use with this report. This file should either be in your .gnucash directory, or else in its proper place within the GnuCash installation directories.")
"receipt.css")) "receipt.css")
(add-option (gnc:make-font-option (gnc-register-font-option options
displaypage optname-heading-font "c" displaypage optname-heading-font "c"
(N_ "Font to use for the main heading.") "Sans Bold 14")) (N_ "Font to use for the main heading.") "Sans Bold 14")
(add-option (gnc:make-font-option (gnc-register-font-option options
displaypage optname-text-font "d" displaypage optname-text-font "d"
(N_ "Font to use for everything else.") "Sans 10")) (N_ "Font to use for everything else.") "Sans 10")
(add-option (gnc:make-pixmap-option (gnc-register-pixmap-option options
displaypage optname-logofile-header "e" displaypage optname-logofile-header "e"
(N_ "Name of a file containing a logo to be used on the header of the report") (N_ "Name of a file containing a logo to be used on the header of the report")
"Receipt_header.jpg")) "Receipt_header.jpg")
(add-option (gnc:make-string-option (gnc-register-string-option options
displaypage optname-logo-width-header "f" (N_ "Width of the header logo in CSS format, e.g. 10% or 32px. Leave blank to display the logo at its natural width. The height of the logo will be scaled accordingly.") "72mm")) displaypage optname-logo-width-header "f" (N_ "Width of the header logo in CSS format, e.g. 10% or 32px. Leave blank to display the logo at its natural width. The height of the logo will be scaled accordingly.") "72mm")
(add-option (gnc:make-pixmap-option (gnc-register-pixmap-option options
displaypage optname-logofile-footer "g" displaypage optname-logofile-footer "g"
(N_ "Name of a file containing a logo to be used on the footer of the report") (N_ "Name of a file containing a logo to be used on the footer of the report")
"Receipt_footer.jpg")) "Receipt_footer.jpg")
(add-option (gnc:make-string-option (gnc-register-string-option options
displaypage optname-logo-width-footer "h" (N_ "Width of the footer logo in CSS format, e.g. 10% or 32px. Leave blank to display the logo at its natural width. The height of the logo will be scaled accordingly.") "72mm")) displaypage optname-logo-width-footer "h" (N_ "Width of the footer logo in CSS format, e.g. 10% or 32px. Leave blank to display the logo at its natural width. The height of the logo will be scaled accordingly.") "72mm")
(add-option (gnc:make-string-option (gnc-register-string-option options
displaypage optname-date-format "i" displaypage optname-date-format "i"
(N_ "The format for the date->string conversion for today's date.") (N_ "The format for the date->string conversion for today's date.")
;; Translators: Boost::date_time format string ;; Translators: Boost::date_time format string
;; "%l:%M %P, %e %B %Y" means " 9:56 pm, 19 June 2019" ;; "%l:%M %P, %e %B %Y" means " 9:56 pm, 19 June 2019"
(G_ "%l:%M %P, %e %B %Y"))) (G_ "%l:%M %P, %e %B %Y"))
;; Heading options ;; Heading options
(add-option (gnc:make-string-option (gnc-register-string-option options
; page / name / orderkey / tooltip / default ; page / name / orderkey / tooltip / default
headingpage optname-report-title "a" "" (G_ "Invoice"))) headingpage optname-report-title "a" "" (G_ "Invoice"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage optname-units "b" "" (G_ "Units"))) headingpage optname-units "b" "" (G_ "Units"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage optname-qty "c" "" (G_ "Qty"))) headingpage optname-qty "c" "" (G_ "Qty"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage optname-unit-price "d" "" (G_ "Unit Price"))) headingpage optname-unit-price "d" "" (G_ "Unit Price"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage optname-disc-rate "e" "" (G_ "Discount Rate"))) headingpage optname-disc-rate "e" "" (G_ "Discount Rate"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage optname-disc-amount "f" "" (G_ "Discount Amount"))) headingpage optname-disc-amount "f" "" (G_ "Discount Amount"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage optname-net-price "g" "" (G_ "Net Price"))) headingpage optname-net-price "g" "" (G_ "Net Price"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage optname-tax-rate "h" "" (G_ "Tax Rate"))) headingpage optname-tax-rate "h" "" (G_ "Tax Rate"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage optname-tax-amount "i" "" (G_ "Tax Amount"))) headingpage optname-tax-amount "i" "" (G_ "Tax Amount"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage optname-total-price "j" "" (G_ "Total Price"))) headingpage optname-total-price "j" "" (G_ "Total Price"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage2 optname-subtotal "a" "" (G_ "Sub-total"))) headingpage2 optname-subtotal "a" "" (G_ "Sub-total"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage2 optname-amount-due "b" "" (G_ "Amount Due"))) headingpage2 optname-amount-due "b" "" (G_ "Amount Due"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage2 optname-payment-recd "c" "" headingpage2 optname-payment-recd "c" ""
(G_ "Payment received, thank you!"))) (G_ "Payment received, thank you!"))
(add-option (gnc:make-text-option (gnc-register-text-option options
notespage optname-extra-notes "a" notespage optname-extra-notes "a"
(N_ "Notes added at end of invoice -- may contain HTML markup") (N_ "Notes added at end of invoice -- may contain HTML markup")
"")) "")
;(N_ "(Development version -- don't rely on the numbers on this report without double-checking them.<br/>Change the 'Extra Notes' option to get rid of this message)"))) ;(N_ "(Development version -- don't rely on the numbers on this report without double-checking them.<br/>Change the 'Extra Notes' option to get rid of this message)")))
(gnc:options-set-default-section (gnc:options-set-default-section options generalpage)
report-options generalpage)
report-options) options))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Create the report ;;; Create the report
@ -156,10 +153,7 @@
;; Create and return the report as either an HTML string ;; Create and return the report as either an HTML string
;; or an <html-document> ;; or an <html-document>
(define (opt-value section name) (define (opt-value section name)
; wrapper for option routines (gnc-optiondb-lookup-value (gnc:report-options report-obj) section name))
(define (get-opt section name)
(gnc:lookup-option (gnc:report-options report-obj) section name))
(gnc:option-value (get-opt section name)))
; Get all the options ; Get all the options
(let* ((document (gnc:make-html-document)) (let* ((document (gnc:make-html-document))

View File

@ -72,8 +72,7 @@
(define (build-column-used options) (define (build-column-used options)
(define (opt-val section name) (define (opt-val section name)
(gnc:option-value (gnc-optiondb-lookup-value options section name))
(gnc:lookup-option options section name)))
(define (make-set-col col-vector) (define (make-set-col col-vector)
(let ((col 0)) (let ((col 0))
(lambda (used? index) (lambda (used? index)
@ -86,7 +85,7 @@
(let* ((col-vector (make-vector columns-used-size #f)) (let* ((col-vector (make-vector columns-used-size #f))
(set-col (make-set-col col-vector))) (set-col (make-set-col col-vector)))
(set-col (opt-val "Display" "Date") 0) (set-col (opt-val "Display" "Date") 0)
(set-col (if (gnc:lookup-option options "Display" "Num") (set-col (if (gnc-lookup-option options "Display" "Num")
(opt-val "Display" "Num") (opt-val "Display" "Num")
(opt-val "Display" "Num/Action")) 1) (opt-val "Display" "Num/Action")) 1)
(set-col (set-col
@ -323,104 +322,86 @@
(define (options-generator) (define (options-generator)
(let ((options (gnc-new-optiondb)))
(define gnc:*report-options* (gnc:new-options)) (gnc-register-query-option options
"__reg" "query" '())
(gnc-register-internal-option options
"__reg" "journal" #f)
(gnc-register-internal-option options
"__reg" "ledger-type" #f)
(gnc-register-internal-option options
"__reg" "double" #f)
(gnc-register-internal-option options
"__reg" "debit-string" (G_ "Debit"))
(gnc-register-internal-option options
"__reg" "credit-string" (G_ "Credit"))
(define (gnc:register-reg-option new-option) (gnc-register-string-option options
(gnc:register-option gnc:*report-options* new-option))
(gnc:register-reg-option
(gnc:make-query-option "__reg" "query" '()))
(gnc:register-reg-option
(gnc:make-internal-option "__reg" "journal" #f))
(gnc:register-reg-option
(gnc:make-internal-option "__reg" "ledger-type" #f))
(gnc:register-reg-option
(gnc:make-internal-option "__reg" "double" #f))
(gnc:register-reg-option
(gnc:make-internal-option "__reg" "debit-string" (G_ "Debit")))
(gnc:register-reg-option
(gnc:make-internal-option "__reg" "credit-string" (G_ "Credit")))
(gnc:register-reg-option
(gnc:make-string-option
(N_ "General") (N_ "Title") (N_ "General") (N_ "Title")
"a" (N_ "The title of the report.") "a" (N_ "The title of the report.")
(N_ "Register Report"))) (N_ "Register Report"))
(gnc:register-reg-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Date") (N_ "Display") (N_ "Date")
"b" (N_ "Display the date?") #t)) "b" (N_ "Display the date?") #t)
(if (qof-book-use-split-action-for-num-field (gnc-get-current-book)) (if (qof-book-use-split-action-for-num-field (gnc-get-current-book))
(gnc:register-reg-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Num/Action") (N_ "Display") (N_ "Num/Action")
"c" (N_ "Display the check number/action?") #t)) "c" (N_ "Display the check number/action?") #t)
(gnc:register-reg-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Num") (N_ "Display") (N_ "Num")
"c" (N_ "Display the check number?") #t))) "c" (N_ "Display the check number?") #t))
(gnc:register-reg-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Description") (N_ "Display") (N_ "Description")
"d" (N_ "Display the description?") #t)) "d" (N_ "Display the description?") #t)
(gnc:register-reg-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Memo") (N_ "Display") (N_ "Memo")
"e" (N_ "Display the memo?") #t)) "e" (N_ "Display the memo?") #t)
(gnc:register-reg-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Account") (N_ "Display") (N_ "Account")
"g" (N_ "Display the account?") #t)) "g" (N_ "Display the account?") #t)
(gnc:register-reg-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Shares") (N_ "Display") (N_ "Shares")
"ha" (N_ "Display the number of shares?") #f)) "ha" (N_ "Display the number of shares?") #f)
(gnc:register-reg-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Lot") (N_ "Display") (N_ "Lot")
"hb" (N_ "Display the name of lot the shares are in?") #f)) "hb" (N_ "Display the name of lot the shares are in?") #f)
(gnc:register-reg-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Price") (N_ "Display") (N_ "Price")
"hc" (N_ "Display the shares price?") #f)) "hc" (N_ "Display the shares price?") #f)
(gnc:register-reg-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
(N_ "Display") (N_ "Amount") (N_ "Display") (N_ "Amount")
"ia" (N_ "Display the amount?") "ia" (N_ "Display the amount?")
'double "double"
(list (list
(vector 'single (N_ "Single Column")) (vector 'single (N_ "Single Column"))
(vector 'double (N_ "Two Columns"))))) (vector 'double (N_ "Two Columns"))))
(gnc:register-reg-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Value") (N_ "Display") (N_ "Value")
"ib" (N_ "Display the value in transaction currency?") #f)) "ib" (N_ "Display the value in transaction currency?") #f)
(gnc:register-reg-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Running Balance") (N_ "Display") (N_ "Running Balance")
"k" (N_ "Display a running balance?") #t)) "k" (N_ "Display a running balance?") #t)
(gnc:register-reg-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Totals") (N_ "Display") (N_ "Totals")
"l" (N_ "Display the totals?") #t)) "l" (N_ "Display the totals?") #t)
(gnc:options-set-default-section gnc:*report-options* "General") (gnc:options-set-default-section options "General")
gnc:*report-options*) options))
;; ----------------------------------------------------------------- ;; -----------------------------------------------------------------
;; create the report result ;; create the report result
@ -432,7 +413,7 @@
;; local helper ;; local helper
;; ---------------------------------- ;; ----------------------------------
(define (opt-val section name) (define (opt-val section name)
(gnc:option-value (gnc:lookup-option options section name))) (gnc-optiondb-lookup-value options section name))
(define (reg-report-journal?) (define (reg-report-journal?)
(opt-val "__reg" "journal")) (opt-val "__reg" "journal"))
(define (reg-report-ledger-type?) (define (reg-report-ledger-type?)
@ -623,8 +604,7 @@
(define (reg-renderer report-obj) (define (reg-renderer report-obj)
(define (opt-val section name) (define (opt-val section name)
(gnc:option-value (gnc-optiondb-lookup-value (gnc:report-options report-obj) section name))
(gnc:lookup-option (gnc:report-options report-obj) section name)))
(let* ((document (gnc:make-html-document)) (let* ((document (gnc:make-html-document))
(query-scm (opt-val "__reg" "query")) (query-scm (opt-val "__reg" "query"))
@ -674,7 +654,7 @@
double? title debit-string credit-string) double? title debit-string credit-string)
(define options (gnc:make-report-options register-report-guid)) (define options (gnc:make-report-options register-report-guid))
(define (set-option section name val) (define (set-option section name val)
(gnc:option-set-value (gnc:lookup-option options section name) val)) (gnc-set-option options section name val))
(when invoice? (when invoice?
(issue-deprecation-warning "gnc:register-report-create-internal: invoice \ (issue-deprecation-warning "gnc:register-report-create-internal: invoice \

View File

@ -114,102 +114,120 @@
(define (options-generator) (define (options-generator)
;; Options ;; Options
(define report-options (gnc:new-options)) (let ((options (gnc-new-optiondb)))
(define (add-option new-option)
(gnc:register-option report-options new-option))
(add-option (gnc-register-invoice-option options
(gnc:make-invoice-option ; defined in gnucash/scm/business-options.scm gnc:pagename-general gnc:optname-invoice-number
gnc:pagename-general gnc:optname-invoice-number "a" "" '())
"a" "" (lambda () '()) #f))
;; Elements page options ;; Elements page options
(add-option (gnc:make-simple-boolean-option elementspage optname-col-date "a" (N_ "Display the date?") #t)) (gnc-register-simple-boolean-option options
(add-option (gnc:make-simple-boolean-option elementspage optname-col-taxrate "b" (N_ "Display the Tax Rate?") #t)) elementspage optname-col-date "a" (N_ "Display the date?") #t)
(add-option (gnc:make-simple-boolean-option elementspage optname-col-units "c" (N_ "Display the Units?") #t)) (gnc-register-simple-boolean-option options
(add-option (gnc:make-simple-boolean-option elementspage optname-row-contact "d" (N_ "Display the contact?") #t)) elementspage optname-col-taxrate "b" (N_ "Display the Tax Rate?") #t)
(add-option (gnc:make-simple-boolean-option elementspage optname-row-address "e" (N_ "Display the address?") #t)) (gnc-register-simple-boolean-option options
(add-option (gnc:make-simple-boolean-option elementspage optname-row-invoice-number "f" (N_ "Display the Invoice Number?") #t)) elementspage optname-col-units "c" (N_ "Display the Units?") #t)
(add-option (gnc:make-simple-boolean-option elementspage optname-row-company-name "g" (N_ "Display the Company Name?") #t)) (gnc-register-simple-boolean-option options
(add-option (gnc:make-simple-boolean-option elementspage optname-invnum-next-to-title "h" (N_ "Invoice Number next to title?") #f)) elementspage optname-row-contact "d" (N_ "Display the contact?") #t)
(add-option (gnc:make-simple-boolean-option elementspage optname-jobname-show "i" (N_ "Display Job name?") #t)) (gnc-register-simple-boolean-option options
(add-option (gnc:make-simple-boolean-option elementspage optname-jobnumber-show "j" (N_ "Invoice Job number?") #f)) elementspage optname-row-address "e" (N_ "Display the address?") #t)
(add-option (gnc:make-simple-boolean-option elementspage optname-netprice "k" (N_ "Show net price?") #f)) (gnc-register-simple-boolean-option options
elementspage optname-row-invoice-number "f" (N_ "Display the Invoice Number?") #t)
(gnc-register-simple-boolean-option options
elementspage optname-row-company-name "g" (N_ "Display the Company Name?") #t)
(gnc-register-simple-boolean-option options
elementspage optname-invnum-next-to-title "h" (N_ "Invoice Number next to title?") #f)
(gnc-register-simple-boolean-option options
elementspage optname-jobname-show "i" (N_ "Display Job name?") #t)
(gnc-register-simple-boolean-option options
elementspage optname-jobnumber-show "j" (N_ "Invoice Job number?") #f)
(gnc-register-simple-boolean-option options
elementspage optname-netprice "k" (N_ "Show net price?") #f)
;; Display options ;; Display options
(add-option (gnc:make-string-option displaypage optname-template-file "a" (gnc-register-string-option options
displaypage optname-template-file "a"
(N_ "The file name of the eguile template part of this report. This file should either be in your .gnucash directory, or else in its proper place within the GnuCash installation directories.") (N_ "The file name of the eguile template part of this report. This file should either be in your .gnucash directory, or else in its proper place within the GnuCash installation directories.")
"taxinvoice.eguile.scm")) "taxinvoice.eguile.scm")
(add-option (gnc:make-string-option displaypage optname-css-file "b" (gnc-register-string-option options
displaypage optname-css-file "b"
(N_ "The file name of the CSS stylesheet to use with this report. This file should either be in your .gnucash directory, or else in its proper place within the GnuCash installation directories.") (N_ "The file name of the CSS stylesheet to use with this report. This file should either be in your .gnucash directory, or else in its proper place within the GnuCash installation directories.")
"taxinvoice.css")) "taxinvoice.css")
(add-option (gnc:make-font-option (gnc-register-font-option options
displaypage optname-heading-font "c" displaypage optname-heading-font "c"
(N_ "Font to use for the main heading.") "Sans Bold 18")) (N_ "Font to use for the main heading.") "Sans Bold 18")
(add-option (gnc:make-font-option (gnc-register-font-option options
displaypage optname-text-font "d" displaypage optname-text-font "d"
(N_ "Font to use for everything else.") "Sans 10")) (N_ "Font to use for everything else.") "Sans 10")
(add-option (gnc:make-pixmap-option (gnc-register-pixmap-option options
displaypage optname-logofile "e" displaypage optname-logofile "e"
(N_ "Name of a file containing a logo to be used on the report.") (N_ "Name of a file containing a logo to be used on the report.")
"")) "")
(add-option (gnc:make-string-option (gnc-register-string-option options
displaypage optname-logo-width "f" (N_ "Width of the logo in CSS format, e.g. 10% or 32px. Leave blank to display the logo at its natural width. The height of the logo will be scaled accordingly.") "")) displaypage optname-logo-width "f" (N_ "Width of the logo in CSS format, e.g. 10% or 32px. Leave blank to display the logo at its natural width. The height of the logo will be scaled accordingly.") "")
(add-option (gnc:make-simple-boolean-option displaypage optname-border-collapse "g" (N_ "Border-collapse?") #f)) (gnc-register-simple-boolean-option options
(add-option (gnc:make-string-option displaypage optname-border-color-th "h" (N_ "CSS color.") "black")) displaypage optname-border-collapse "g" (N_ "Border-collapse?") #f)
(add-option (gnc:make-string-option displaypage optname-border-color-td "i" (N_ "CSS color.") "black")) (gnc-register-string-option options
displaypage optname-border-color-th "h" (N_ "CSS color.") "black")
(gnc-register-string-option options
displaypage optname-border-color-td "i" (N_ "CSS color.") "black")
;; Heading options ;; Heading options
(add-option (gnc:make-string-option (gnc-register-string-option options
; page / name / orderkey / tooltip / default ; page / name / orderkey / tooltip / default
headingpage optname-report-title "a" "" (G_ "Invoice"))) headingpage optname-report-title "a" "" (G_ "Invoice"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage optname-units "b" "" (G_ "Units"))) headingpage optname-units "b" "" (G_ "Units"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage optname-qty "c" "" (G_ "Qty"))) headingpage optname-qty "c" "" (G_ "Qty"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage optname-unit-price "d" "" (G_ "Unit Price"))) headingpage optname-unit-price "d" "" (G_ "Unit Price"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage optname-disc-rate "e" "" (G_ "Discount Rate"))) headingpage optname-disc-rate "e" "" (G_ "Discount Rate"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage optname-disc-amount "f" "" (G_ "Discount Amount"))) headingpage optname-disc-amount "f" "" (G_ "Discount Amount"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage optname-net-price "g" "" (G_ "Net Price"))) headingpage optname-net-price "g" "" (G_ "Net Price"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage optname-tax-rate "h" "" (G_ "Tax Rate"))) headingpage optname-tax-rate "h" "" (G_ "Tax Rate"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage optname-tax-amount "i" "" (G_ "Tax Amount"))) headingpage optname-tax-amount "i" "" (G_ "Tax Amount"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage optname-total-price "j" "" (G_ "Total Price"))) headingpage optname-total-price "j" "" (G_ "Total Price"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage2 optname-subtotal "a" "" (G_ "Sub-total"))) headingpage2 optname-subtotal "a" "" (G_ "Sub-total"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage2 optname-amount-due "b" "" (G_ "Amount Due"))) headingpage2 optname-amount-due "b" "" (G_ "Amount Due"))
(add-option (gnc:make-string-option (gnc-register-string-option options
headingpage2 optname-payment-recd "c" "" headingpage2 optname-payment-recd "c" ""
(G_ "Payment received, thank you!"))) (G_ "Payment received, thank you!"))
(add-option (gnc:make-string-option headingpage2 optname-invoice-number-text (gnc-register-string-option options
"d" "" (G_ "Invoice number:"))) headingpage2 optname-invoice-number-text
(add-option (gnc:make-string-option headingpage2 optname-to-text "d" "" (G_ "Invoice number:"))
"e" "" (G_ "To:"))) (gnc-register-string-option options
(add-option (gnc:make-string-option headingpage2 optname-ref-text headingpage2 optname-to-text
"f" "" (G_ "Your ref:"))) "e" "" (G_ "To:"))
(add-option (gnc:make-string-option headingpage2 optname-jobnumber-text (gnc-register-string-option options
"g" "" (G_ "Job number:"))) headingpage2 optname-ref-text
(add-option (gnc:make-string-option headingpage2 optname-jobname-text "f" "" (G_ "Your ref:"))
"h" "" (G_ "Job name:"))) (gnc-register-string-option options
headingpage2 optname-jobnumber-text
"g" "" (G_ "Job number:"))
(gnc-register-string-option options
headingpage2 optname-jobname-text
"h" "" (G_ "Job name:"))
(add-option (gnc:make-text-option (gnc-register-text-option options
notespage optname-extra-notes "a" notespage optname-extra-notes "a"
(G_ "Notes added at end of invoice -- may contain HTML markup.") (G_ "Notes added at end of invoice -- may contain HTML markup.")
(G_ "Thank you for your patronage!"))) (G_ "Thank you for your patronage!"))
(add-option (gnc:make-text-option notespage optname-extra-css "b" (gnc-register-text-option options
(N_ "Embedded CSS.") "h1.coyname { text-align: left; }")) notespage optname-extra-css "b"
(gnc:options-set-default-section (N_ "Embedded CSS.") "h1.coyname { text-align: left; }")
report-options gnc:pagename-general) (gnc:options-set-default-section options gnc:pagename-general)
report-options) options))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Create the report ;;; Create the report
@ -218,10 +236,7 @@
;; Create and return the report as either an HTML string ;; Create and return the report as either an HTML string
;; or an <html-document> ;; or an <html-document>
(define (opt-value section name) (define (opt-value section name)
; wrapper for option routines (gnc-optiondb-lookup-value (gnc:report-options report-obj) section name))
(define (get-opt section name)
(gnc:lookup-option (gnc:report-options report-obj) section name))
(gnc:option-value (get-opt section name)))
; Get all the options ; Get all the options
(let* ((document (gnc:make-html-document)) (let* ((document (gnc:make-html-document))
@ -294,8 +309,7 @@
(define (au-tax-options-generator) (define (au-tax-options-generator)
(define (set-opt options page name value) (define (set-opt options page name value)
(let ((option (gnc:lookup-option options page name))) (gnc-set-option options page name value))
(gnc:option-set-value option value)))
(let ((options (options-generator))) (let ((options (options-generator)))
(set-opt options headingpage optname-report-title (G_ "Tax Invoice")) (set-opt options headingpage optname-report-title (G_ "Tax Invoice"))

View File

@ -23,7 +23,7 @@
(test-end "test-average-balance")) (test-end "test-average-balance"))
(define (set-option! options page tag value) (define (set-option! options page tag value)
((gnc:option-setter (gnc:lookup-option options page tag)) value)) (gnc-set-option options page tag value))
(define (teardown) (define (teardown)
(gnc-clear-current-session)) (gnc-clear-current-session))

View File

@ -174,20 +174,15 @@
;; options generator ;; options generator
(define (trial-balance-options-generator) (define (trial-balance-options-generator)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb))
(book (gnc-get-current-book)) (book (gnc-get-current-book)))
(add-option
(lambda (new-option)
(gnc:register-option options new-option))))
(add-option (gnc-register-string-option options
(gnc:make-string-option
(N_ "General") optname-report-title (N_ "General") optname-report-title
"a" opthelp-report-title (G_ reportname))) "a" opthelp-report-title (G_ reportname))
(add-option (gnc-register-string-option options
(gnc:make-string-option
(N_ "General") optname-party-name (N_ "General") optname-party-name
"b" opthelp-party-name (or (gnc:company-info book gnc:*company-name*) ""))) "b" opthelp-party-name (or (gnc:company-info book gnc:*company-name*) ""))
;; the period over which to collect adjusting/closing entries and ;; the period over which to collect adjusting/closing entries and
;; date at which to report the balance ;; date at which to report the balance
@ -195,22 +190,19 @@
options gnc:pagename-general options gnc:pagename-general
optname-start-date optname-end-date "c") optname-start-date optname-end-date "c")
(add-option (gnc-register-multichoice-option options
(gnc:make-multichoice-option
gnc:pagename-general optname-report-variant gnc:pagename-general optname-report-variant
"d" opthelp-report-variant "d" opthelp-report-variant
'current "current"
(list (vector 'current (N_ "General journal exact balances")) (list (vector 'current (N_ "General journal exact balances"))
(vector 'pre-adj (N_ "No adjusting/closing entries")) (vector 'pre-adj (N_ "No adjusting/closing entries"))
(vector 'work-sheet (N_ "Full end-of-period work sheet"))))) (vector 'work-sheet (N_ "Full end-of-period work sheet"))))
;; accounts to work on ;; accounts to work on
(add-option (gnc-register-account-list-option options
(gnc:make-account-list-option
gnc:pagename-accounts optname-accounts gnc:pagename-accounts optname-accounts
"a" "a"
opthelp-accounts opthelp-accounts
(lambda ()
(gnc:filter-accountlist-type (gnc:filter-accountlist-type
(list ACCT-TYPE-BANK ACCT-TYPE-CASH ACCT-TYPE-CREDIT (list ACCT-TYPE-BANK ACCT-TYPE-CASH ACCT-TYPE-CREDIT
ACCT-TYPE-ASSET ACCT-TYPE-LIABILITY ACCT-TYPE-ASSET ACCT-TYPE-LIABILITY
@ -219,30 +211,24 @@
ACCT-TYPE-EQUITY ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE ACCT-TYPE-EQUITY ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE
ACCT-TYPE-TRADING) ACCT-TYPE-TRADING)
(gnc-account-get-descendants-sorted (gnc-get-current-root-account)))) (gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
#f #t))
(gnc:options-add-account-levels! (gnc:options-add-account-levels!
options gnc:pagename-accounts optname-depth-limit options gnc:pagename-accounts optname-depth-limit
"b" opthelp-depth-limit 1) "b" opthelp-depth-limit 1)
;; options for merchandising business work sheets ;; options for merchandising business work sheets
(add-option (gnc-register-account-list-option options
(gnc:make-account-list-option
pagename-merchandising optname-gross-adjustment-accounts pagename-merchandising optname-gross-adjustment-accounts
"c" "c"
opthelp-gross-adjustment-accounts opthelp-gross-adjustment-accounts
(lambda () ;; Here, it would be useful to have an inventory account type.
;; Here, it would be useful to have an inventory account type. ;; Lacking that, just select no accounts by default.
;; Lacking that, just select no accounts by default. '())
'())
#f #t)) (gnc-register-account-list-option options
(add-option
(gnc:make-account-list-option
pagename-merchandising optname-income-summary-accounts pagename-merchandising optname-income-summary-accounts
"d" "d"
opthelp-income-summary-accounts opthelp-income-summary-accounts
(lambda () '())
'())
#f #t))
;; all about currencies ;; all about currencies
(gnc:options-add-currency! (gnc:options-add-currency!
@ -253,56 +239,46 @@
options pagename-commodities options pagename-commodities
optname-price-source "b" 'average-cost) optname-price-source "b" 'average-cost)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-commodities optname-show-foreign pagename-commodities optname-show-foreign
"c" opthelp-show-foreign #f)) "c" opthelp-show-foreign #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-commodities optname-show-rates pagename-commodities optname-show-rates
"d" opthelp-show-rates #f)) "d" opthelp-show-rates #f)
;; adjusting/closing entry match criteria ;; adjusting/closing entry match criteria
;; ;;
;; N.B.: transactions really should have a field where we can put ;; N.B.: transactions really should have a field where we can put
;; transaction types like "Adjusting/Closing/Correcting Entries" ;; transaction types like "Adjusting/Closing/Correcting Entries"
(add-option (gnc-register-string-option options
(gnc:make-string-option
pagename-entries optname-adjusting-pattern pagename-entries optname-adjusting-pattern
"a" opthelp-adjusting-pattern (G_ "Adjusting Entries"))) "a" opthelp-adjusting-pattern (G_ "Adjusting Entries"))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-entries optname-adjusting-casing pagename-entries optname-adjusting-casing
"b" opthelp-adjusting-casing #f)) "b" opthelp-adjusting-casing #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-entries optname-adjusting-regexp pagename-entries optname-adjusting-regexp
"c" opthelp-adjusting-regexp #f)) "c" opthelp-adjusting-regexp #f)
(add-option (gnc-register-string-option options
(gnc:make-string-option
pagename-entries optname-closing-pattern pagename-entries optname-closing-pattern
"d" opthelp-closing-pattern (G_ "Closing Entries"))) "d" opthelp-closing-pattern (G_ "Closing Entries"))
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-entries optname-closing-casing pagename-entries optname-closing-casing
"e" opthelp-closing-casing #f)) "e" opthelp-closing-casing #f)
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
pagename-entries optname-closing-regexp pagename-entries optname-closing-regexp
"f" opthelp-closing-regexp #f)) "f" opthelp-closing-regexp #f)
;; what to show for zero-balance accounts ;; what to show for zero-balance accounts
;;(add-option ;;(gnc-register-simple-boolean-option options
;; (gnc:make-simple-boolean-option
;; gnc:pagename-display optname-show-zb-accts ;; gnc:pagename-display optname-show-zb-accts
;; "a" opthelp-show-zb-accts #t)) ;; "a" opthelp-show-zb-accts #t)
;; some detailed formatting options ;; some detailed formatting options
(add-option (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
gnc:pagename-display optname-account-links gnc:pagename-display optname-account-links
"e" opthelp-account-links #t)) "e" opthelp-account-links #t)
;; Set the accounts page as default option tab ;; Set the accounts page as default option tab
(gnc:options-set-default-section options gnc:pagename-display) (gnc:options-set-default-section options gnc:pagename-display)
@ -318,9 +294,8 @@
(define (trial-balance-renderer report-obj) (define (trial-balance-renderer report-obj)
(define (get-option pagename optname) (define (get-option pagename optname)
(gnc:option-value (gnc-optiondb-lookup-value
(gnc:lookup-option (gnc:report-options report-obj) pagename optname))
(gnc:report-options report-obj) pagename optname)))
(gnc:report-starting reportname) (gnc:report-starting reportname)

View File

@ -36,31 +36,24 @@
(use-modules (gnucash html)) (use-modules (gnucash html))
(define (make-options) (define (make-options)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb)))
(opt-register
(lambda (opt)
(gnc:register-option options opt))))
;; the report-list is edited by a special add-on page for the ;; the report-list is edited by a special add-on page for the
;; options editor. ;; options editor.
(gnc-register-report-placement-option (gnc:optiondb options) "__general" "report-list") (gnc-register-report-placement-option options "__general" "report-list")
(opt-register (gnc-register-number-range-option options
(gnc:make-number-range-option
(N_ "General") (N_ "Number of columns") "a" (N_ "General") (N_ "Number of columns") "a"
(N_ "Number of columns before wrapping to a new row.") (N_ "Number of columns before wrapping to a new row.")
1 0 20 0 1)) 1 0 20 1)
options)) options))
(define (render-view report) (define (render-view report)
(let* ((view-doc (gnc:make-html-document)) (let* ((view-doc (gnc:make-html-document))
(options (gnc:report-options report)) (options (gnc:report-options report))
(report-opt (gnc:lookup-option options "__general" "report-list")) (reports (gnc-optiondb-lookup-value options "__general" "report-list"))
(reports (gnc:option-value report-opt))
(table-width (table-width
(gnc:option-value (gnc-optiondb-lookup-value options (N_ "General") (N_ "Number of columns")))
(gnc:lookup-option
options (N_ "General") (N_ "Number of columns"))))
(column-allocs (make-hash-table 11)) (column-allocs (make-hash-table 11))
(column-tab (gnc:make-html-table)) (column-tab (gnc:make-html-table))
(current-row '()) (current-row '())
@ -168,8 +161,7 @@
(define (options-changed-cb report) (define (options-changed-cb report)
(let* ((options (gnc:report-options report)) (let* ((options (gnc:report-options report))
(reports (reports
(gnc:option-value (gnc-optiondb-lookup-value options "__general" "report-list")))
(gnc:lookup-option options "__general" "report-list"))))
(for-each (for-each
(lambda (child) (lambda (child)
(gnc:report-set-dirty?! (gnc-report-find (car child)) #t)) (gnc:report-set-dirty?! (gnc-report-find (car child)) #t))
@ -177,10 +169,10 @@
(define (cleanup-options report) (define (cleanup-options report)
(let* ((options (gnc:report-options report)) (let* ((options (gnc:report-options report))
(report-opt (gnc:lookup-option options "__general" "report-list"))) (report-opt (gnc-lookup-option options "__general" "report-list")))
(let loop ((reports (gnc:option-value report-opt)) (new-reports '())) (let loop ((reports (GncOption-get-value report-opt)) (new-reports '()))
(match reports (match reports
(() (gnc:option-set-value report-opt (reverse new-reports))) (() (GncOption-set-value report-opt (reverse new-reports)))
(((child rowspan colspan _) . rest) (((child rowspan colspan _) . rest)
(loop rest (cons (list child rowspan colspan #f) new-reports))))))) (loop rest (cons (list child rowspan colspan #f) new-reports)))))))