Report development without the need to restart GnuCash

Torsten Edeler torsten at edeler.org
Thu May 22 14:09:34 EDT 2008


Hi everybody.

I'm quite new to GnuCash. Recently I felt the need to make my own report
adapted to my needs, since the existing reports were not suitable. After
taking a look to this obscure language Scheme - which I will probably never
like :-) - the question rised how to develop reports without having the need
to restart the whole application after a little bit of the report had to be
changed. I searched the mailing list, but hadn't found anything usefull.

I would like to present my solution to that problem to you. Perhaps it has
already been solved (probably more elegant) by some of you or I missed it in
the ml. Anyway this is what I use at the moment for development.

I have the report file which is load by GnuCash on Startup:

(define pagename-general "General")
(define (options-generator)
    (load "/home/torsten/.gnucash/reports/myoptions.scm")
    (myoptions)
)


(define (renderer options)
    (load "/home/torsten/.gnucash/reports/renderer.scm")
    (myrenderer options)
)


(let ()
  (gnc:define-report
   'version 1
   'name (N_ "Trivial Example")
   'options-generator options-generator
   'renderer renderer)
)

As you can see the renderer and the options-generator include a file load.
So everytime GnuCash executes one of the functions, a fresh version of the
file is loaded and executet. The files itself defines a function "myoption"
and "myrenderer" respectively. Note that the option-generator is only
executed after loading the report from the menu (or on startup), whereas the
renderer is also executet after reloading or modification of the options.

Unfortunatly GnuCash is very sensible to errors in the option-generator,
since it simple terminates the whole application. The renderer behaves more
nicely: Only an error message is displayed in the report window and one has
the chance to modify the file and reload the report.


I hope this little texts helps some of you. At least it would have helped me
:-)

regards,
Torsten


More information about the gnucash-user mailing list