mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Improve function names and comments to reduce ambibuity
This commit is contained in:
@@ -745,7 +745,7 @@ gnc_plugin_page_report_save_page (GncPluginPage *plugin_page,
|
||||
return;
|
||||
}
|
||||
|
||||
gen_save_text = scm_c_eval_string("gnc:report-generate-restore-forms");
|
||||
gen_save_text = scm_c_eval_string("gnc:report-serialize");
|
||||
get_embedded_list = scm_c_eval_string("gnc:report-embedded-list");
|
||||
get_options = scm_c_eval_string("gnc:report-options");
|
||||
embedded = scm_call_1(get_embedded_list, scm_call_1(get_options, priv->cur_report));
|
||||
|
||||
@@ -164,8 +164,7 @@
|
||||
(export gnc:delete-report)
|
||||
(export gnc:rename-report)
|
||||
(export gnc:find-report-template)
|
||||
(export gnc:report-generate-restore-forms)
|
||||
(export gnc:report-generate-saved-forms)
|
||||
(export gnc:report-serialize)
|
||||
(export gnc:report-to-template-new)
|
||||
(export gnc:report-to-template-update)
|
||||
(export gnc:report-render-html)
|
||||
|
||||
@@ -508,7 +508,9 @@
|
||||
|
||||
;; Load and save functions
|
||||
|
||||
(define (gnc:report-generate-restore-forms report)
|
||||
|
||||
;; Generate guile code required to recreate an instatiated report
|
||||
(define (gnc:report-serialize report)
|
||||
;; clean up the options if necessary. this is only needed
|
||||
;; in special cases.
|
||||
(let* ((report-type (gnc:report-type report))
|
||||
@@ -544,8 +546,8 @@
|
||||
")"
|
||||
))
|
||||
|
||||
;; Loop over embedded reports and concat result of each gnc:report-generate-restore-forms
|
||||
(define (gnc:report-generate-options-embedded options)
|
||||
;; Generate guile code required to recreate embedded report instances
|
||||
(define (gnc:report-serialize-embedded options)
|
||||
(let*
|
||||
((embedded-reports (gnc:report-embedded-list options))
|
||||
(result-string ""))
|
||||
@@ -554,7 +556,7 @@
|
||||
(lambda (subreport-id)
|
||||
(let*
|
||||
((subreport (gnc-report-find subreport-id))
|
||||
(subreport-options-text (gnc:report-generate-restore-forms subreport)))
|
||||
(subreport-options-text (gnc:report-serialize subreport)))
|
||||
(set! result-string (string-append
|
||||
result-string
|
||||
";;;; Options for embedded report\n"
|
||||
@@ -562,7 +564,7 @@
|
||||
embedded-reports))
|
||||
result-string))
|
||||
|
||||
(define (gnc:report-generate-saved-forms-string name type templ-name options embedded-options guid)
|
||||
(define (gnc:report-template-serialize-internal name type templ-name options embedded-serialized guid)
|
||||
(let ((result (string-append
|
||||
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n"
|
||||
(format #f ";; Options for saved report ~S, based on template ~S\n"
|
||||
@@ -571,8 +573,8 @@
|
||||
#f "(let ()\n (define (options-gen)\n (let ((options (gnc:report-template-new-options/report-guid ~S ~S)))\n"
|
||||
type templ-name)
|
||||
(gnc:generate-restore-forms options "options")
|
||||
(if embedded-options
|
||||
embedded-options
|
||||
(if embedded-serialized
|
||||
embedded-serialized
|
||||
"")
|
||||
" options))\n"
|
||||
(format
|
||||
@@ -589,7 +591,7 @@
|
||||
|
||||
;; Convert an instantiated report into a report template
|
||||
;; and generate the guile code required to recreate this template
|
||||
(define (gnc:report-generate-saved-forms report)
|
||||
(define (gnc:report-template-serialize-from-report report)
|
||||
;; clean up the options if necessary. this is only needed
|
||||
;; in special cases.
|
||||
(let* ((template
|
||||
@@ -604,22 +606,22 @@
|
||||
(type (gnc:report-type report))
|
||||
(templ-name (gnc:report-template-name (hash-ref *gnc:_report-templates_* (gnc:report-type report))))
|
||||
(options (gnc:report-options report))
|
||||
(embedded-options (gnc:report-generate-options-embedded options)))
|
||||
(gnc:report-generate-saved-forms-string name type templ-name options embedded-options #f)))
|
||||
(embedded-serialized (gnc:report-serialize-embedded options)))
|
||||
(gnc:report-template-serialize-internal name type templ-name options embedded-serialized #f)))
|
||||
|
||||
;; Generate guile code required to recreate a report template
|
||||
;; Note: multi column report templates encapsulate instantiated reports, not other report templates
|
||||
;; this means that the template recreation code must also contain the code to instantiate
|
||||
;; these embedded report instances. This results in a mix of template and instatiated reports
|
||||
;; in the saved reports file...
|
||||
(define (gnc:report-template-generate-saved-forms report-template)
|
||||
(define (gnc:report-template-serialize report-template)
|
||||
(let* ((name (gnc:report-template-name report-template))
|
||||
(type (gnc:report-template-parent-type report-template))
|
||||
(templ-name (gnc:report-template-name (hash-ref *gnc:_report-templates_* type)))
|
||||
(options (gnc:report-template-new-options report-template))
|
||||
(embedded-options (gnc:report-generate-options-embedded options))
|
||||
(embedded-serialized (gnc:report-serialize-embedded options))
|
||||
(guid (gnc:report-template-report-guid report-template)))
|
||||
(gnc:report-generate-saved-forms-string name type templ-name options embedded-options guid)))
|
||||
(gnc:report-template-serialize-internal name type templ-name options embedded-serialized guid)))
|
||||
|
||||
(define gnc:current-saved-reports
|
||||
(gnc-build-dotgnucash-path "saved-reports-2.4"))
|
||||
@@ -648,7 +650,7 @@
|
||||
(let* ((custom-template-id (gnc:report-custom-template report))
|
||||
(overwrite-ok? (and (gnc:report-template-is-custom/template-guid? custom-template-id) overwrite?))
|
||||
;; Generate a serialized report-template with a random guid
|
||||
(saved-form (gnc:report-generate-saved-forms report))
|
||||
(saved-form (gnc:report-template-serialize-from-report report))
|
||||
;; Immediatly evaluate the serialized report template to
|
||||
;; - check if it's error free and can be deserialized
|
||||
;; - load it into the runtime for immediate use by the user
|
||||
@@ -695,7 +697,7 @@
|
||||
(define (gnc:report-template-save-to-savefile report-template)
|
||||
(let* ((report-port (gnc:open-saved-reports "a")))
|
||||
(if report-port
|
||||
(let ((saved-form (gnc:report-template-generate-saved-forms report-template)))
|
||||
(let ((saved-form (gnc:report-template-serialize report-template)))
|
||||
(display saved-form report-port)
|
||||
(close report-port)
|
||||
#t)
|
||||
|
||||
Reference in New Issue
Block a user