Add progress bars for the last two reports.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7570 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton 2002-11-30 06:48:05 +00:00
parent a564daf71c
commit 766d8e1dae
4 changed files with 57 additions and 20 deletions

View File

@ -1,3 +1,12 @@
2002-11-29 David Hampton <hampton@employees.org>
* src/report/report-system/report.scm: Move the busy cursor logic
so that it removes the busy cursor even after a report error.
* src/report/locale-specific/us/taxtxf.scm:
* src/report/standard-reports/transaction.scm: Provide progress updates
while creating reports. #94280
2002-11-29 Christian Stimming <stimming@tuhh.de> 2002-11-29 Christian Stimming <stimming@tuhh.de>
* src/import-export/hbci/gnc-hbci-utils.c, gnc-hbci-*.c: Catch the * src/import-export/hbci/gnc-hbci-utils.c, gnc-hbci-*.c: Catch the
@ -52,7 +61,7 @@
* src/report/report-system/report.scm: * src/report/report-system/report.scm:
* src/report/standard-reports/*.scm: * src/report/standard-reports/*.scm:
* src/business/business-reports/*.scm: Provide progress updates * src/business/business-reports/*.scm: Provide progress updates
while creating reports. while creating reports. #94280
* src/gnome-utils/gw-gnome-utils-spec.scm: Make the * src/gnome-utils/gw-gnome-utils-spec.scm: Make the
set_busy_cursor and unset_busy_cursor routines available from set_busy_cursor and unset_busy_cursor routines available from

View File

@ -38,6 +38,9 @@
(gnc:module-load "gnucash/tax/us" 0) (gnc:module-load "gnucash/tax/us" 0)
(gnc:module-load "gnucash/report/report-system" 0) (gnc:module-load "gnucash/report/report-system" 0)
(define reportname (N_ "Tax Report / TXF Export"))
(define (make-level-collector num-levels) (define (make-level-collector num-levels)
(let ((level-collector (make-vector num-levels))) (let ((level-collector (make-vector num-levels)))
(do ((i 0 (+ i 1))) (do ((i 0 (+ i 1)))
@ -425,6 +428,7 @@
(lambda (x) (num-generations x (+ 1 gen))) (lambda (x) (num-generations x (+ 1 gen)))
children))))) children)))))
(gnc:report-starting reportname)
(let* ((from-value (gnc:date-option-absolute-time (let* ((from-value (gnc:date-option-absolute-time
(get-option gnc:pagename-general "From"))) (get-option gnc:pagename-general "From")))
(to-value (gnc:timepair-end-day-time (to-value (gnc:timepair-end-day-time
@ -449,6 +453,8 @@
selected-accounts)) selected-accounts))
0)) 0))
(max-level (min MAX-LEVELS (max 1 generations))) (max-level (min MAX-LEVELS (max 1 generations)))
(work-to-do 0)
(work-done 0)
;; Alternate dates are relative to from-date ;; Alternate dates are relative to from-date
(from-date (gnc:timepair->date from-value)) (from-date (gnc:timepair->date from-value))
@ -595,10 +601,24 @@
#t fudge-date #t date)))) #t fudge-date #t date))))
split-list))) split-list)))
(define (count-accounts level accounts)
(if (< level max-level)
(let ((sum 0))
(for-each (lambda (x)
(if (gnc:account-is-inc-exp? x)
(set! sum (+ sum (+ 1 (count-accounts (+ 1 level)
(gnc:account-get-immediate-subaccounts x)))))
0))
accounts)
sum)
(length accounts)))
(define (handle-level-x-account level account) (define (handle-level-x-account level account)
(let ((type (gw:enum-<gnc:AccountType>-val->sym (let ((type (gw:enum-<gnc:AccountType>-val->sym
(gnc:account-get-type account) #f))) (gnc:account-get-type account) #f)))
(set! work-done (+ 1 work-done))
(gnc:report-percent-done (* 100 (/ work-done work-to-do)))
(if (gnc:account-is-inc-exp? account) (if (gnc:account-is-inc-exp? account)
(let* ((children (gnc:account-get-children account)) (let* ((children (gnc:account-get-children account))
(to-special #f) ; clear special-splits-period (to-special #f) ; clear special-splits-period
@ -701,6 +721,7 @@
(set! txf-last-payer "") (set! txf-last-payer "")
(set! txf-l-count 0) (set! txf-l-count 0)
(set! work-to-do (count-accounts 1 selected-accounts))
(if (not tax-mode?) ; Do Txf mode (if (not tax-mode?) ; Do Txf mode
(begin (begin
@ -779,11 +800,12 @@
(_ "No Tax Related accounts were found. Go to the\ (_ "No Tax Related accounts were found. Go to the\
Edit->Tax Options dialog to set up tax-related accounts."))))) Edit->Tax Options dialog to set up tax-related accounts.")))))
(gnc:report-finished)
doc))))) doc)))))
(gnc:define-report (gnc:define-report
'version 1 'version 1
'name (N_ "Tax Report / TXF Export") 'name reportname
'menu-name (N_ "Tax Report & TXF Export") 'menu-name (N_ "Tax Report & TXF Export")
;;'menu-path (list gnc:menuname-taxes) ;;'menu-path (list gnc:menuname-taxes)
'menu-tip (N_ "Taxable Income / Deductible Expenses / Export to .TXF file") 'menu-tip (N_ "Taxable Income / Deductible Expenses / Export to .TXF file")

View File

@ -364,7 +364,6 @@
(let ((template (hash-ref *gnc:_report-templates_* (let ((template (hash-ref *gnc:_report-templates_*
(gnc:report-type report))) (gnc:report-type report)))
(doc #f)) (doc #f))
(gnc:set_busy_cursor #f #t)
(set! doc (if template (set! doc (if template
(let* ((renderer (gnc:report-template-renderer template)) (let* ((renderer (gnc:report-template-renderer template))
(stylesheet (gnc:report-stylesheet report)) (stylesheet (gnc:report-stylesheet report))
@ -376,24 +375,25 @@
(gnc:report-set-dirty?! report #f) (gnc:report-set-dirty?! report #f)
html) html)
#f)) #f))
(gnc:unset_busy_cursor #f)
doc))) doc)))
(define (gnc:report-run id) (define (gnc:report-run id)
(gnc:backtrace-if-exception (let ((report (gnc:find-report id))
(lambda () (start-time (gettimeofday))
(let ((report (gnc:find-report id)) (html #f))
(start-time (gettimeofday)) (gnc:set_busy_cursor #f #t)
(html #f)) (gnc:backtrace-if-exception
(lambda ()
(if report (if report
(begin (begin
(set! html (gnc:report-render-html report #t)) (set! html (gnc:report-render-html report #t))
;; (display "total time to run report: ") ;; (display "total time to run report: ")
;; (display (gnc:time-elapsed start-time (gettimeofday))) ;; (display (gnc:time-elapsed start-time (gettimeofday)))
;; (newline) ;; (newline)
;; (display html) (newline) ;; (display html) (newline)
html) ))))
#f))))) (gnc:unset_busy_cursor #f)
html))
(define (gnc:report-templates-for-each thunk) (define (gnc:report-templates-for-each thunk)
(hash-for-each (lambda (name template) (thunk name template)) (hash-for-each (lambda (name template) (thunk name template))

View File

@ -44,6 +44,7 @@
;; Define the strings here to avoid typos and make changes easier. ;; Define the strings here to avoid typos and make changes easier.
(define reportname (N_ "Transaction Report"))
(define pagename-sorting (N_ "Sorting")) (define pagename-sorting (N_ "Sorting"))
(define optname-prime-sortkey (N_ "Primary Key")) (define optname-prime-sortkey (N_ "Primary Key"))
(define optname-prime-subtotal (N_ "Primary Subtotal")) (define optname-prime-subtotal (N_ "Primary Subtotal"))
@ -775,7 +776,8 @@ Credit Card, and Income accounts")))))
primary-subtotal-renderer primary-subtotal-renderer
secondary-subtotal-renderer) secondary-subtotal-renderer)
(let ((work-to-do (length splits))
(work-done 0))
(define (get-account-types-to-reverse options) (define (get-account-types-to-reverse options)
(cdr (assq (gnc:option-value (cdr (assq (gnc:option-value
(gnc:lookup-option options (gnc:lookup-option options
@ -821,6 +823,8 @@ Credit Card, and Income accounts")))))
primary-subtotal-collector primary-subtotal-collector
secondary-subtotal-collector secondary-subtotal-collector
total-collector) total-collector)
(set! work-done (+ 1 work-done))
(gnc:report-percent-done (* 100 (/ work-done work-to-do)))
(if (null? splits) (if (null? splits)
(begin (begin
(gnc:html-table-append-row/markup! (gnc:html-table-append-row/markup!
@ -961,7 +965,7 @@ Credit Card, and Income accounts")))))
(gnc:make-commodity-collector) (gnc:make-commodity-collector)
(gnc:make-commodity-collector)))) (gnc:make-commodity-collector))))
table)) table)))
;; ;;;;;;;;;;;;;;;;;;;; ;; ;;;;;;;;;;;;;;;;;;;;
;; Here comes the renderer function for this report. ;; Here comes the renderer function for this report.
@ -1079,6 +1083,7 @@ Credit Card, and Income accounts")))))
(define (get-other-account-names account-list) (define (get-other-account-names account-list)
( map (lambda (acct) (gnc:account-get-full-name acct)) account-list)) ( map (lambda (acct) (gnc:account-get-full-name acct)) account-list))
(gnc:report-starting reportname)
(let ((document (gnc:make-html-document)) (let ((document (gnc:make-html-document))
(c_account_1 (opt-val gnc:pagename-accounts "Report Accounts")) (c_account_1 (opt-val gnc:pagename-accounts "Report Accounts"))
(c_account_2 (opt-val gnc:pagename-accounts "Filter Accounts")) (c_account_2 (opt-val gnc:pagename-accounts "Filter Accounts"))
@ -1208,6 +1213,7 @@ match the given time interval and account selection.")))
(gnc:html-make-no-account-warning (gnc:html-make-no-account-warning
report-title (gnc:report-id report-obj)))) report-title (gnc:report-id report-obj))))
(gnc:report-finished)
document)) document))
;; Define the report. ;; Define the report.
@ -1215,7 +1221,7 @@ match the given time interval and account selection.")))
'version 2 'version 2
'name (N_ "Transaction Report") 'name reportname
'options-generator trep-options-generator 'options-generator trep-options-generator