diff --git a/gnucash/report/report-core.scm b/gnucash/report/report-core.scm index 3dce45f056..fa0d9ecd11 100644 --- a/gnucash/report/report-core.scm +++ b/gnucash/report/report-core.scm @@ -29,6 +29,7 @@ (use-modules (sw_report)) (use-modules (ice-9 match)) +(use-modules (srfi srfi-9)) ; Export the swig-wrapped symbols in the public interface of this module (let ((i (module-public-interface (current-module)))) @@ -82,14 +83,46 @@ (define gnc:optname-invoice-number (N_ "Invoice Number")) ;; A represents one of the available report types. -(define - (make-record-type - "" - ;; The data items in a report record - '(version name report-guid parent-type options-generator - options-cleanup-cb options-changed-cb - renderer in-menu? menu-path menu-name - menu-tip export-types export-thunk))) +(define-record-type + (make-new-record-template version name report-guid parent-type options-generator + options-cleanup-cb options-changed-cb + renderer in-menu? menu-path menu-name + menu-tip export-types export-thunk) + report-template? + (version report-template-version) + (report-guid report-template-report-guid report-template-set-report-guid!) + (name report-template-name report-template-set-name) + (parent-type report-template-parent-type report-template-set-parent-type!) + (options-generator report-template-options-generator) + (options-cleanup-cb report-template-options-cleanup-cb) + (options-changed-cb report-template-options-changed-cb) + (renderer report-template-renderer) + (in-menu? report-template-in-menu?) + (menu-path report-template-menu-path) + (menu-name report-template-menu-name) + (menu-tip report-template-menu-tip) + (export-types report-template-export-types) + (export-thunk report-template-export-thunk)) + +(define (make-report-template) + (make-new-record-template #f #f #f #f #f #f #f #f #t #f #f #f #f #f)) +(define gnc:report-template-version report-template-version) +(define gnc:report-template-report-guid report-template-report-guid) +(define gnc:report-template-set-report-guid! report-template-set-report-guid!) +(define gnc:report-template-name report-template-name) +(define gnc:report-template-set-name report-template-set-name) +(define gnc:report-template-parent-type report-template-parent-type) +(define gnc:report-template-set-parent-type! report-template-set-parent-type!) +(define gnc:report-template-options-generator report-template-options-generator) +(define gnc:report-template-options-cleanup-cb report-template-options-cleanup-cb) +(define gnc:report-template-options-changed-cb report-template-options-changed-cb) +(define gnc:report-template-renderer report-template-renderer) +(define gnc:report-template-in-menu? report-template-in-menu?) +(define gnc:report-template-menu-path report-template-menu-path) +(define gnc:report-template-menu-name report-template-menu-name) +(define gnc:report-template-menu-tip report-template-menu-tip) +(define gnc:report-template-export-types report-template-export-types) +(define gnc:report-template-export-thunk report-template-export-thunk) ;; define strings centrally to ease code clarity (define rpterr-dupe @@ -121,14 +154,16 @@ not found."))) ;; The renderer should be a function that accepts one argument, a ;; set of options, and generates the report. the renderer must ;; return as its final value an object. + (define report-rec (make-report-template)) - (let* ((report-rec (let loop ((report-rec (make-report-template)) (args args)) - (match args - (() report-rec) - ((field val . rest) - ((record-modifier field) report-rec val) - (loop report-rec rest))))) - (report-guid (gnc:report-template-report-guid report-rec)) + (let loop ((args args)) + (match args + (() #f) + ((field val . rest) + ((record-modifier field) report-rec val) + (loop rest)))) + + (let* ((report-guid (gnc:report-template-report-guid report-rec)) (report-name (gnc:report-template-name report-rec))) (cond @@ -144,60 +179,6 @@ not found."))) (else (hash-set! *gnc:_report-templates_* report-guid report-rec))))) -(define gnc:report-template-version - (record-accessor 'version)) -(define gnc:report-template-report-guid - (record-accessor 'report-guid)) -(define gnc:report-template-set-report-guid! - (record-modifier 'report-guid)) -(define gnc:report-template-name - (record-accessor 'name)) -(define gnc:report-template-set-name - (record-modifier 'name)) -(define gnc:report-template-parent-type - (record-accessor 'parent-type)) -(define gnc:report-template-set-parent-type! - (record-modifier 'parent-type)) -(define gnc:report-template-options-generator - (record-accessor 'options-generator)) -(define gnc:report-template-options-cleanup-cb - (record-accessor 'options-cleanup-cb)) -(define gnc:report-template-options-changed-cb - (record-accessor 'options-changed-cb)) -(define gnc:report-template-renderer - (record-accessor 'renderer)) -(define gnc:report-template-in-menu? - (record-accessor 'in-menu?)) -(define gnc:report-template-menu-path - (record-accessor 'menu-path)) -(define gnc:report-template-menu-name - (record-accessor 'menu-name)) -(define gnc:report-template-menu-tip - (record-accessor 'menu-tip)) -(define gnc:report-template-export-types - (record-accessor 'export-types)) -(define gnc:report-template-export-thunk - (record-accessor 'export-thunk)) -(define (make-report-template) - ((record-constructor ) - #f ;; version - #f ;; name - #f ;; report-guid - #f ;; parent-type (meaning guid of - ;; report-template this template is - ;; based on) - #f ;; options-generator - #f ;; options-cleanup-cb - #f ;; options-changed-cb - #f ;; renderer - #t ;; in-menu? - #f ;; menu-path - #f ;; menu-name - #f ;; menu-tip - #f ;; export-types - #f ;; export-thunk - )) - (define (gnc:report-template-new-options/report-guid template-id template-name) (let ((templ (hash-ref *gnc:_report-templates_* template-id))) (and templ