From fa0e7590b6c39fbf217b7348699241b82a64689a Mon Sep 17 00:00:00 2001
From: Dave Peticolas \n" )
+ (set! tempstruct
+ (build-mystruct-instance
+ (define-mystruct
+ (gnc:acctnames-from-list accounts))))
+
+ (set! acctcurrency (gnc:account-get-currency (car accounts)))
+
+ (set! report-lines
+ (gnc:convert-split-list (gnc:query-get-splits gncq)))
+
+ (gnc:free-query gncq)
+
+ (display (length report-lines))
+ (display " Splits\n")
+
+ ; Set initial balances to zero
+ (map (lambda(an) (tempstruct 'put an 0))
+ (gnc:acctnames-from-list accounts))
+
+ (dateloop begindate
+ enddate
+ (eval stepsize))
+ (set! rept-data
+ (reduce-split-list
+ (dateloop begindate
+ enddate
+ (eval stepsize))
+ report-lines zdate tempstruct))
+
+ (set! sum-data (get-averages rept-data))
+
+ ;; Create HTML
+ (set! rept-text
+ (html-table
+ collist
+ (append rept-data
+ (list " \n"))
(list rept-text) suffix)))
)
diff --git a/src/scm/report/hello-world.scm b/src/scm/report/hello-world.scm
index 98cff8a252..9793778ceb 100644
--- a/src/scm/report/hello-world.scm
+++ b/src/scm/report/hello-world.scm
@@ -14,12 +14,12 @@
(define (options-generator)
;; This will be the new set of options.
- (define gnc:*dummy-options* (gnc:new-options))
+ (define gnc:*hello-world-options* (gnc:new-options))
;; This is just a helper function for making options.
;; See gnucash/src/scm/options.scm for details.
- (define (gnc:register-dummy-option new-option)
- (gnc:register-option gnc:*dummy-options* new-option))
+ (define (gnc:register-hello-world-option new-option)
+ (gnc:register-option gnc:*hello-world-options* new-option))
;; This is a boolean option. It is in Section 'Hello, World!'
;; and is named 'Boolean Option'. Its sorting key is 'a',
@@ -28,7 +28,7 @@
;; is #t (true). The phrase 'This is a boolean option'
;; will be displayed as help text when the user puts
;; the mouse pointer over the option.
- (gnc:register-dummy-option
+ (gnc:register-hello-world-option
(gnc:make-simple-boolean-option
"Hello, World!" "Boolean Option"
"a" "This is a boolean option." #t))
@@ -38,13 +38,13 @@
;; symbols. The value 'first will be displayed as "First Option"
;; and have a help string of "Help for first option.". The default
;; value is 'third.
- (gnc:register-dummy-option
+ (gnc:register-hello-world-option
(gnc:make-multichoice-option
"Hello, World!" "Multi Choice Option"
"b" "This is a multi choice option." 'third
- (list #(first "First Option" "Help for first option.")
- #(second "Second Option" "Help for second option.")
- #(third "Third Option" "Help for third option.")
+ (list #(first "First Option" "Help for first option")
+ #(second "Second Option" "Help for second option")
+ #(third "Third Option" "Help for third option")
#(fourth "Fourth Options" "The fourth option rules!"))))
;; This is a string option. Users can type anything they want
@@ -52,7 +52,7 @@
;; in the same section as the option above. It will be shown
;; after the option above because its key is 'b' while the
;; other key is 'a'.
- (gnc:register-dummy-option
+ (gnc:register-hello-world-option
(gnc:make-string-option
"Hello, World!" "String Option"
"c" "This is a string option" "Hello, World"))
@@ -63,7 +63,7 @@
;; Unix time. The last option is false, so the user can only
;; select a date, not a time. The default value is the current
;; time.
- (gnc:register-dummy-option
+ (gnc:register-hello-world-option
(gnc:make-date-option
"Hello, World!" "Just a Date Option"
"d" "This is a date option"
@@ -72,7 +72,7 @@
;; This is another date option, but the user can also select
;; the time.
- (gnc:register-dummy-option
+ (gnc:register-hello-world-option
(gnc:make-date-option
"Hello, World!" "Time and Date Option"
"e" "This is a date option with time"
@@ -86,7 +86,7 @@
;; (#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.
- (gnc:register-dummy-option
+ (gnc:register-hello-world-option
(gnc:make-color-option
"Hello, World!" "Background Color"
"f" "This is a color option"
@@ -109,23 +109,36 @@
;; 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.
- (gnc:register-dummy-option
+ (gnc:register-hello-world-option
(gnc:make-account-list-option
- "Hello, World!" "An account list option"
+ "Hello Again" "An account list option"
"g" "This is an account list option"
(lambda () (gnc:get-current-accounts))
#f #t))
+ ;; This is a list option. The user can select one or (possibly)
+ ;; more values from a list. The list of acceptable values is
+ ;; the same format as a multichoice option. The value of the
+ ;; option is a list of symbols.
+ (gnc:register-hello-world-option
+ (gnc:make-list-option
+ "Hello Again" "A list option"
+ "h" "This is a list option"
+ (list 'good)
+ (list #(good "The Good" "Good option")
+ #(bad "The Bad" "Bad option")
+ #(ugly "The Ugly" "Ugly option"))))
+
;; This option is for testing. When true, the report generates
;; an exception.
- (gnc:register-dummy-option
+ (gnc:register-hello-world-option
(gnc:make-simple-boolean-option
"Testing" "Crash the report"
"a" (string-append "This is for testing. "
"Your reports probably shouldn't have an "
"option like this.") #f))
- gnc:*dummy-options*)
+ gnc:*hello-world-options*)
;; This is a helper function to generate an html list of account names
;; given an account list option.
@@ -141,6 +154,19 @@
(map (lambda (name) (list " You have selected no values in the list option. "
+ "The items selected in the list option are:"
+ " "))
(begin
; Grab account names
@@ -557,65 +557,66 @@
(map (lambda(acct) (gnc:query-add-account gncq acct)) accounts)
- (set! tempstruct
- (build-mystruct-instance
- (define-mystruct
- (gnc:acctnames-from-list accounts))))
-
- (set! acctcurrency (gnc:account-get-currency (car accounts)))
-
- (set! report-lines
- (gnc:convert-split-list (gnc:query-get-splits gncq)))))
-
- (gnc:free-query gncq)
-
- (display (length report-lines))
- (display " Splits\n")
-
- ; Set initial balances to zero
- (map (lambda(an) (tempstruct 'put an 0))
- (gnc:acctnames-from-list accounts))
-
- (dateloop begindate
- enddate
- (eval stepsize))
- (set! rept-data
- (reduce-split-list
- (dateloop begindate
- enddate
- (eval stepsize))
- report-lines zdate tempstruct))
-
- (set! sum-data (get-averages rept-data))
-
-
- ;; Create HTML
- (set! rept-text
- (html-table
- collist
- (append rept-data
- (list "You have not selected an account. " sum-data))))
-
-
- ;; Do a plot
- (if (not (equal? NoPlot (eval plotstr)))
- (let* ((fn "/tmp/gncplot.dat")
- (preplot (string-append
- "set xdata time\n"
- "set timefmt '%m/%d/%Y'\n"
- "set pointsize 2\n"
- "set title '" acctname "'\n"
- "set ylabel '" acctcurrency "'\n"
- "set xlabel 'Period Ending'\n"
- )
- )
- )
-
- (data-to-gpfile collist rept-data fn (eval plotstr))
- (system
- (string-append "echo \"" preplot "plot '" fn "'" (eval plotstr)
- "\"|gnuplot -persist " )))
- )
- (append prefix (list "Report for " acctname " " sum-data))))
+
+ ;; Do a plot
+ (if (not (equal? NoPlot (eval plotstr)))
+ (let* ((fn "/tmp/gncplot.dat")
+ (preplot (string-append
+ "set xdata time\n"
+ "set timefmt '%m/%d/%Y'\n"
+ "set pointsize 2\n"
+ "set title '" acctname "'\n"
+ "set ylabel '" acctcurrency "'\n"
+ "set xlabel 'Period Ending'\n"
+ )))
+
+ (data-to-gpfile collist rept-data fn (eval plotstr))
+ (system
+ (string-append "echo \"" preplot "plot '"
+ fn "'" (eval plotstr)
+ "\"|gnuplot -persist " ))))
+ ))
+
+ (append prefix
+ (if (null? accounts)
+ ()
+ (list "Report for " acctname ""
+ (map (lambda (name) (list "
"))))
+
;; Here's another helper function. You can guess what it does.
(define (bold string)
(string-append "" string ""))
@@ -175,8 +201,10 @@
(colorop (gnc:lookup-option options
"Hello, World!" "Background Color"))
(account-list-op (gnc:lookup-option options
- "Hello, World!"
+ "Hello Again"
"An account list option"))
+ (list-op (gnc:lookup-option options
+ "Hello Again" "A list option"))
(crash-op (gnc:lookup-option options "Testing" "Crash the report")))
(let ((time-string (strftime "%X" (localtime (current-time))))
@@ -245,6 +273,8 @@
"The date and time option is " (bold date-string2) "."
"
" diff --git a/src/scm/report/transaction-report.scm b/src/scm/report/transaction-report.scm index dba8a1ab6a..00e6fa9b02 100644 --- a/src/scm/report/transaction-report.scm +++ b/src/scm/report/transaction-report.scm @@ -491,6 +491,8 @@ trep-options-generator ;; renderer (lambda (options) + (gnc:set-total-inflow! 0) + (gnc:set-total-outflow! 0) (let* ((begindate (gnc:lookup-option options "Report Options" "From")) (enddate (gnc:lookup-option options "Report Options" "To")) (tr-report-account-op (gnc:lookup-option options