gnucash maint: [register] simplify gnc:register-report-create-internal

Christopher Lam clam at code.gnucash.org
Sat Jan 1 07:34:01 EST 2022


Updated	 via  https://github.com/Gnucash/gnucash/commit/286dc50d (commit)
	from  https://github.com/Gnucash/gnucash/commit/d2e01320 (commit)



commit 286dc50ddc74c435ed351ef60b1d64590a5c3531
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Jan 1 09:06:39 2022 +0800

    [register] simplify gnc:register-report-create-internal
    
    and deprecate the currently unused invoice? option.

diff --git a/gnucash/report/reports/standard/register.scm b/gnucash/report/reports/standard/register.scm
index 4453bf666..62e24c8e3 100644
--- a/gnucash/report/reports/standard/register.scm
+++ b/gnucash/report/reports/standard/register.scm
@@ -672,28 +672,23 @@
 
 (define (gnc:register-report-create-internal invoice? query journal? ledger-type?
                                              double? title debit-string credit-string)
-  (let* ((options (gnc:make-report-options register-report-guid))
-         (query-op (gnc:lookup-option options "__reg" "query"))
-         (journal-op (gnc:lookup-option options "__reg" "journal"))
-         (ledger-type-op (gnc:lookup-option options "__reg" "ledger-type"))
-         (double-op (gnc:lookup-option options "__reg" "double"))
-         (title-op (gnc:lookup-option options "General" "Title"))
-         (debit-op (gnc:lookup-option options "__reg" "debit-string"))
-         (credit-op (gnc:lookup-option options "__reg" "credit-string"))
-         (account-op (gnc:lookup-option options "Display" "Account")))
-
-    (if invoice?
-        (begin
-          (set! journal? #f)
-          (gnc:option-set-value account-op #f)))
-
-    (gnc:option-set-value query-op query)
-    (gnc:option-set-value journal-op journal?)
-    (gnc:option-set-value ledger-type-op ledger-type?)
-    (gnc:option-set-value double-op double?)
-    (gnc:option-set-value title-op title)
-    (gnc:option-set-value debit-op debit-string)
-    (gnc:option-set-value credit-op credit-string)
-    (gnc:make-report register-report-guid options)))
+  (define options (gnc:make-report-options register-report-guid))
+  (define (set-option section name val)
+    (gnc:option-set-value (gnc:lookup-option options section name) val))
+
+  (when invoice?
+    (issue-deprecation-warning "gnc:register-report-create-internal: invoice \
+option is obsolete")
+    (set! journal? #f)
+    (set-option "Display" "Account" #f))
+
+  (set-option "General" "Title" title)
+  (set-option "__reg" "query" query)
+  (set-option "__reg" "journal" journal?)
+  (set-option "__reg" "ledger-type" ledger-type?)
+  (set-option "__reg" "double" double?)
+  (set-option "__reg" "debit-string" debit-string)
+  (set-option "__reg" "credit-string" credit-string)
+  (gnc:make-report register-report-guid options))
 
 (export gnc:register-report-create-internal)



Summary of changes:
 gnucash/report/reports/standard/register.scm | 41 ++++++++++++----------------
 1 file changed, 18 insertions(+), 23 deletions(-)



More information about the gnucash-changes mailing list