Skip to content

Commit

Permalink
Add progress bars for the last two reports.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7570 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
David Hampton committed Nov 30, 2002
1 parent a564daf commit 766d8e1
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 20 deletions.
11 changes: 10 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
2002-11-29 David Hampton <[email protected]>

* 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 <[email protected]>

* src/import-export/hbci/gnc-hbci-utils.c, gnc-hbci-*.c: Catch the
Expand Down Expand Up @@ -52,7 +61,7 @@
* src/report/report-system/report.scm:
* src/report/standard-reports/*.scm:
* 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
set_busy_cursor and unset_busy_cursor routines available from
Expand Down
24 changes: 23 additions & 1 deletion src/report/locale-specific/us/taxtxf.scm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
(gnc:module-load "gnucash/tax/us" 0)
(gnc:module-load "gnucash/report/report-system" 0)


(define reportname (N_ "Tax Report / TXF Export"))

(define (make-level-collector num-levels)
(let ((level-collector (make-vector num-levels)))
(do ((i 0 (+ i 1)))
Expand Down Expand Up @@ -425,6 +428,7 @@
(lambda (x) (num-generations x (+ 1 gen)))
children)))))

(gnc:report-starting reportname)
(let* ((from-value (gnc:date-option-absolute-time
(get-option gnc:pagename-general "From")))
(to-value (gnc:timepair-end-day-time
Expand All @@ -449,6 +453,8 @@
selected-accounts))
0))
(max-level (min MAX-LEVELS (max 1 generations)))
(work-to-do 0)
(work-done 0)

;; Alternate dates are relative to from-date
(from-date (gnc:timepair->date from-value))
Expand Down Expand Up @@ -595,10 +601,24 @@
#t fudge-date #t date))))
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)
(let ((type (gw:enum-<gnc:AccountType>-val->sym
(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)
(let* ((children (gnc:account-get-children account))
(to-special #f) ; clear special-splits-period
Expand Down Expand Up @@ -701,6 +721,7 @@

(set! txf-last-payer "")
(set! txf-l-count 0)
(set! work-to-do (count-accounts 1 selected-accounts))

(if (not tax-mode?) ; Do Txf mode
(begin
Expand Down Expand Up @@ -779,11 +800,12 @@
(_ "No Tax Related accounts were found. Go to the\
Edit->Tax Options dialog to set up tax-related accounts.")))))

(gnc:report-finished)
doc)))))

(gnc:define-report
'version 1
'name (N_ "Tax Report / TXF Export")
'name reportname
'menu-name (N_ "Tax Report & TXF Export")
;;'menu-path (list gnc:menuname-taxes)
'menu-tip (N_ "Taxable Income / Deductible Expenses / Export to .TXF file")
Expand Down
30 changes: 15 additions & 15 deletions src/report/report-system/report.scm
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@
(let ((template (hash-ref *gnc:_report-templates_*
(gnc:report-type report)))
(doc #f))
(gnc:set_busy_cursor #f #t)
(set! doc (if template
(let* ((renderer (gnc:report-template-renderer template))
(stylesheet (gnc:report-stylesheet report))
Expand All @@ -376,24 +375,25 @@
(gnc:report-set-dirty?! report #f)
html)
#f))
(gnc:unset_busy_cursor #f)
doc)))

(define (gnc:report-run id)
(gnc:backtrace-if-exception
(lambda ()
(let ((report (gnc:find-report id))
(start-time (gettimeofday))
(html #f))
(let ((report (gnc:find-report id))
(start-time (gettimeofday))
(html #f))
(gnc:set_busy_cursor #f #t)
(gnc:backtrace-if-exception
(lambda ()
(if report
(begin
(set! html (gnc:report-render-html report #t))
;; (display "total time to run report: ")
;; (display (gnc:time-elapsed start-time (gettimeofday)))
;; (newline)
;; (display html) (newline)
html)
#f)))))
(begin
(set! html (gnc:report-render-html report #t))
;; (display "total time to run report: ")
;; (display (gnc:time-elapsed start-time (gettimeofday)))
;; (newline)
;; (display html) (newline)
))))
(gnc:unset_busy_cursor #f)
html))

(define (gnc:report-templates-for-each thunk)
(hash-for-each (lambda (name template) (thunk name template))
Expand Down
12 changes: 9 additions & 3 deletions src/report/standard-reports/transaction.scm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

;; Define the strings here to avoid typos and make changes easier.

(define reportname (N_ "Transaction Report"))
(define pagename-sorting (N_ "Sorting"))
(define optname-prime-sortkey (N_ "Primary Key"))
(define optname-prime-subtotal (N_ "Primary Subtotal"))
Expand Down Expand Up @@ -775,7 +776,8 @@ Credit Card, and Income accounts")))))
primary-subtotal-renderer
secondary-subtotal-renderer)


(let ((work-to-do (length splits))
(work-done 0))
(define (get-account-types-to-reverse options)
(cdr (assq (gnc:option-value
(gnc:lookup-option options
Expand Down Expand Up @@ -821,6 +823,8 @@ Credit Card, and Income accounts")))))
primary-subtotal-collector
secondary-subtotal-collector
total-collector)
(set! work-done (+ 1 work-done))
(gnc:report-percent-done (* 100 (/ work-done work-to-do)))
(if (null? splits)
(begin
(gnc:html-table-append-row/markup!
Expand Down Expand Up @@ -961,7 +965,7 @@ Credit Card, and Income accounts")))))
(gnc:make-commodity-collector)
(gnc:make-commodity-collector))))

table))
table)))

;; ;;;;;;;;;;;;;;;;;;;;
;; Here comes the renderer function for this report.
Expand Down Expand Up @@ -1079,6 +1083,7 @@ Credit Card, and Income accounts")))))
(define (get-other-account-names account-list)
( map (lambda (acct) (gnc:account-get-full-name acct)) account-list))

(gnc:report-starting reportname)
(let ((document (gnc:make-html-document))
(c_account_1 (opt-val gnc:pagename-accounts "Report Accounts"))
(c_account_2 (opt-val gnc:pagename-accounts "Filter Accounts"))
Expand Down Expand Up @@ -1208,14 +1213,15 @@ match the given time interval and account selection.")))
(gnc:html-make-no-account-warning
report-title (gnc:report-id report-obj))))

(gnc:report-finished)
document))

;; Define the report.
(gnc:define-report

'version 2

'name (N_ "Transaction Report")
'name reportname

'options-generator trep-options-generator

Expand Down

0 comments on commit 766d8e1

Please sign in to comment.