Dynamically adding reports

Phil Longstaff plongstaff at rogers.com
Thu Jun 11 10:08:18 EDT 2009

I played around last night with how reports are loaded in the system.  I basically replaced:

(use-module (gnucash report report-A))
(use-module (gnucash report report-B))

which appears in standard-reports.scm, with

(define (get-report-list) (list
(for-each (lambda (x) (resolve-module (append '(gnucash report) x))) (get-report-list))

which does nothing new, but does allow me to replace (get-report-list) with a function which returns the names of all .scm files.  This will then allow a user/developer to just drop a new report file into the reports directory, restart gnucash, and it will be picked up.  Or, (get-report-list) could read the list of report file names from a standard-report-names.txt file, which would allow the user/developer to drop a report file into the reports directory, add the file name to the standard-report-names.txt, then restart.  My preference is for the former (fewer steps), but a little more difficult.

The reports directory currently holds all of the report files (both standard and business) as well as some support files.  I think what I will do is create a 'standard-reports' subdirectory to the reports directory, and put the standard reports (or symlinks) there.  get-report-list will then have a single directory from which to get all of the file names.



More information about the gnucash-devel mailing list