gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Fri Aug 23 08:01:55 EDT 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/3d608efc (commit)
	 via  https://github.com/Gnucash/gnucash/commit/67751665 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/123033e5 (commit)
	from  https://github.com/Gnucash/gnucash/commit/53b7cba1 (commit)



commit 3d608efc2211127f88b028988fe102425046759d
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Aug 23 19:51:13 2019 +0800

    [test-options] add to CMakeLists.txt
    
    forgto to add to dist_list.

diff --git a/libgnucash/app-utils/test/CMakeLists.txt b/libgnucash/app-utils/test/CMakeLists.txt
index dd9e259a1..435250c60 100644
--- a/libgnucash/app-utils/test/CMakeLists.txt
+++ b/libgnucash/app-utils/test/CMakeLists.txt
@@ -84,6 +84,7 @@ set_dist_list(test_app_utils_DIST
   test-sx.cpp
   test-c-interface.scm
   test-date-utilities.scm
+  test-options.scm
   ${test_app_utils_scheme_SOURCES}
   ${test_app_utils_SOURCES}
 )

commit 67751665b3011b2049d0aa6bf2b8a2556cec334b
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Aug 23 18:55:55 2019 +0800

    [taxtxf(-de_DE)] compact functions, use srfi-2
    
    srfi-2 and-let* allows concise code and returns #f if any intermediate
    var is #f.

diff --git a/libgnucash/tax/us/txf-de_DE.scm b/libgnucash/tax/us/txf-de_DE.scm
index c3df5342b..c93cdc3f6 100644
--- a/libgnucash/tax/us/txf-de_DE.scm
+++ b/libgnucash/tax/us/txf-de_DE.scm
@@ -46,6 +46,7 @@
 
 
 (use-modules (gnucash app-utils))
+(use-modules (srfi srfi-2))
 
 (define txf-tax-entity-types
   (list
@@ -53,11 +54,8 @@
    (cons 'Other #("None" "Keine Steuerberichtsoptionen vorhanden"))))
 
 (define (gnc:tax-type-txf-get-code-info tax-entity-types type-code index)
-  (if (assv type-code tax-entity-types)
-      (let ((tax-entity-type (assv type-code tax-entity-types)))
-           (and tax-entity-type
-                (vector-ref (cdr tax-entity-type) index)))
-      #f))
+  (and-let* ((tax-entity-type (assv-ref tax-entity-types type-code)))
+    (vector-ref tax-entity-type index)))
 
 (define (gnc:txf-get-tax-entity-type type-code)
   (gnc:tax-type-txf-get-code-info txf-tax-entity-types type-code 0))
@@ -81,64 +79,41 @@
 (define (gnc:txf-get-category-key categories code tax-entity-type)
   (gnc:txf-get-code-info categories code 5 tax-entity-type))
 (define (gnc:txf-get-line-data categories code tax-entity-type)
-  (if (assv (string->symbol tax-entity-type) categories)
-      (let* ((tax-entity-codes (cdr (assv (string->symbol tax-entity-type)
-                                          categories)))
-             (category (if (assv code tax-entity-codes)
-                           (assv code tax-entity-codes)
-                           #f)))
-            (if (or (not category) (< (vector-length (cdr category)) 7))
-                #f
-                (gnc:txf-get-code-info categories code 6 tax-entity-type)))
-      #f))
+  (and-let* ((sym (string->symbol tax-entity-type))
+             (tax-entity-codes (assv-ref categories sym))
+             (category (assv-ref tax-entity-codes code))
+             ((>= (vector-length category) 7)))
+    (gnc:txf-get-code-info categories code 6 tax-entity-type)))
 (define (gnc:txf-get-last-year categories code tax-entity-type)
-  (if (assv (string->symbol tax-entity-type) categories)
-      (let* ((tax-entity-codes (cdr (assv (string->symbol tax-entity-type)
-                                          categories)))
-             (category (if (assv code tax-entity-codes)
-                           (assv code tax-entity-codes)
-                           #f)))
-            (if (or (not category) (< (vector-length (cdr category)) 8))
-                #f
-                (gnc:txf-get-code-info categories code 7 tax-entity-type)))
-      #f))
+  (and-let* ((sym (string->symbol tax-entity-type))
+             (tax-entity-codes (assv-ref categories sym))
+             (category (assv-ref tax-entity-codes code))
+             ((>= (vector-length category) 8)))
+    (gnc:txf-get-code-info categories code 7 tax-entity-type)))
 
 (define (gnc:txf-get-help categories code)
-  (let ((pair (assv code txf-help-strings)))
-    (if pair
-        (cdr pair)
-        "Keine Hilfe verfügbar, da nur Gruppenüberschrift.
+  (or (assv-ref txf-help-strings code)
+      "Keine Hilfe verfügbar, da nur Gruppenüberschrift.
 Diese Kategorie ohne Nummer ==>> N I C H T   V E R W E N D E N !
 USt-Kategorien 2011 für GnuCash Vers. 2.4.0 entwickelt und erstellt von: FJSW
-Fehlermeldungen + Dankschreiben an: stoll at bomhardt.de")))
+Fehlermeldungen + Dankschreiben an: stoll at bomhardt.de"))
 
 (define (gnc:txf-get-codes categories tax-entity-type)
-  (if (assv (string->symbol tax-entity-type) categories)
-      (let* ((tax-entity-code-list-pair (assv (if (eqv? tax-entity-type "")
-                                               'Ind
-                                               (string->symbol tax-entity-type))
-                                              categories))
-             (tax-entity-codes (if tax-entity-code-list-pair
-                                   (cdr tax-entity-code-list-pair)
-                                   '())))
-            (map car tax-entity-codes))
-      #f))
+  (and-let* ((sym (if (string-null? tax-entity-type)
+                      'Ind
+                      (string->symbol tax-entity-type)))
+             (tax-entity-codes (assv-ref categories sym)))
+    (map car tax-entity-codes)))
 
 ;;;; Private
 
 (define (gnc:txf-get-code-info categories code index tax-entity-type)
-  (let* ((tax-entity-code-list-pair (assv (if (eqv? tax-entity-type "")
-                                              'Ind
-                                              (string->symbol tax-entity-type))
-                                          categories))
-         (tax-entity-codes (if tax-entity-code-list-pair
-                               (cdr tax-entity-code-list-pair)
-                               '()))
-         (category (assv code tax-entity-codes)))
-        (if category
-            (and category
-                 (vector-ref (cdr category) index))
-            #f)))
+  (and-let* ((sym (if (string-null? tax-entity-type)
+                      'Ind
+                      (string->symbol tax-entity-type)))
+             (tax-entity-codes (assv-ref categories sym))
+             (category (assv-ref tax-entity-codes code)))
+    (vector-ref category index)))
 
 (define txf-help-categories
   (list
diff --git a/libgnucash/tax/us/txf.scm b/libgnucash/tax/us/txf.scm
index ffdb6f78d..ef551bea3 100644
--- a/libgnucash/tax/us/txf.scm
+++ b/libgnucash/tax/us/txf.scm
@@ -41,6 +41,7 @@
 
 
 (use-modules (gnucash app-utils))
+(use-modules (srfi srfi-2))
 
 (define txf-tax-entity-types
   (list
@@ -51,11 +52,8 @@
    (cons 'Other #("None" "No Income Tax Options Provided"))))
 
 (define (gnc:tax-type-txf-get-code-info tax-entity-types type-code index)
-  (if (assv type-code tax-entity-types)
-      (let ((tax-entity-type (assv type-code tax-entity-types)))
-           (and tax-entity-type
-                (vector-ref (cdr tax-entity-type) index)))
-      #f))
+  (and-let* ((tax-entity-type (assv-ref tax-entity-types type-code)))
+    (vector-ref tax-entity-type index)))
 
 (define (gnc:txf-get-tax-entity-type type-code)
   (gnc:tax-type-txf-get-code-info txf-tax-entity-types type-code 0))
@@ -78,57 +76,37 @@
   (gnc:txf-get-code-info categories code 4 tax-entity-type))
 (define (gnc:txf-get-category-key categories code tax-entity-type)
   (gnc:txf-get-code-info categories code 5 tax-entity-type))
+
 (define (gnc:txf-get-line-data categories code tax-entity-type)
-  (if (assv (string->symbol tax-entity-type) categories)
-      (let* ((tax-entity-codes (cdr (assv (string->symbol tax-entity-type)
-                                          categories)))
-             (category (if (assv code tax-entity-codes)
-                           (assv code tax-entity-codes)
-                           #f)))
-            (if (or (not category) (< (vector-length (cdr category)) 7))
-                #f
-                (gnc:txf-get-code-info categories code 6 tax-entity-type)))
-      #f))
+  (and-let* ((sym (string->symbol tax-entity-type))
+             (tax-entity-codes (assv-ref categories sym))
+             (category (assv-ref tax-entity-codes code))
+             ((>= (vector-length category) 7)))
+    (gnc:txf-get-code-info categories code 6 tax-entity-type)))
+
 (define (gnc:txf-get-last-year categories code tax-entity-type)
-  (if (assv (string->symbol tax-entity-type) categories)
-      (let* ((tax-entity-codes (cdr (assv (string->symbol tax-entity-type)
-                                          categories)))
-             (category (if (assv code tax-entity-codes)
-                           (assv code tax-entity-codes)
-                           #f)))
-            (if (or (not category) (< (vector-length (cdr category)) 8))
-                #f
-                (gnc:txf-get-code-info categories code 7 tax-entity-type)))
-      #f))
+  (and-let* ((sym (string->symbol tax-entity-type))
+             (tax-entity-codes (assv-ref categories sym))
+             (category (assv-ref tax-entity-codes code))
+             ((>= (vector-length category) 8)))
+    (gnc:txf-get-code-info categories code 7 tax-entity-type)))
 
 (define (gnc:txf-get-help categories code)
-  (let ((pair (assv code txf-help-strings)))
-    (if pair
-        (cdr pair)
-        (_ "No help available.") )))
+  (or (assv-ref txf-help-strings code)
+      (_ "No help available.")))
 
 (define (gnc:txf-get-codes categories tax-entity-type)
-  (if (assv (string->symbol tax-entity-type) categories)
-      (let ((tax-entity-codes (cdr (assv (string->symbol tax-entity-type)
-                                                                 categories))))
-           (map car tax-entity-codes))
-      #f))
+  (and-let* ((sym (string->symbol tax-entity-type))
+             (tax-entity-codes (assv-ref categories sym)))
+    (map car tax-entity-codes)))
 
 (define (gnc:txf-get-code-info categories code index tax-entity-type)
-  (if (or (assv (string->symbol tax-entity-type) categories)
-          (eqv? tax-entity-type ""))
-      (let* ((tax-entity-codes (cdr (assv (if (eqv? tax-entity-type "")
-                                              'F1040
-                                              (string->symbol tax-entity-type))
-                                          categories)))
-             (category (if (assv code tax-entity-codes)
-                           (assv code tax-entity-codes)
-                           #f)))
-            (if category
-                (and category
-                     (vector-ref (cdr category) index))
-                #f))
-      #f))
+  (and-let* ((sym (if (string-null? tax-entity-type)
+                      'F1040
+                      (string->symbol tax-entity-type)))
+             (tax-entity-codes (assv-ref categories sym))
+             (category (assv-ref tax-entity-codes code)))
+    (vector-ref category index)))
 
 (define txf-help-categories
   (list

commit 123033e5ea31beb21dc1e75cb50c9cf5432cc34a
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Aug 22 18:54:59 2019 +0800

    [standard-reports] modernise to srfi-9 records

diff --git a/gnucash/report/standard-reports/standard-reports.scm b/gnucash/report/standard-reports/standard-reports.scm
index 235f763c8..321f0997d 100644
--- a/gnucash/report/standard-reports/standard-reports.scm
+++ b/gnucash/report/standard-reports/standard-reports.scm
@@ -25,6 +25,7 @@
 
 
 (define-module (gnucash report standard-reports))
+(use-modules (srfi srfi-9))
 (use-modules (srfi srfi-13))
 (use-modules (gnucash utilities))
 (use-modules (gnucash core-utils))
@@ -39,26 +40,15 @@
 ;; or without split.  If no function is found, then run the 'default'
 ;; function
 
-(define acct-type-info (make-record-type "AcctTypeInfo" '(split non-split)))
-
-(define make-acct-type-private
-  (record-constructor acct-type-info '(split non-split)))
+(define-record-type :acct-type-info
+  (make-acct-type-private split non-split)
+  acct-type-info?
+  (split get-split set-split)
+  (non-split get-non-split set-non-split))
 
 (define (make-acct-type)
   (make-acct-type-private #f #f))
 
-(define get-split
-  (record-accessor acct-type-info 'split))
-
-(define set-split
-  (record-modifier acct-type-info 'split))
-
-(define get-non-split
-  (record-accessor acct-type-info 'non-split))
-
-(define set-non-split
-  (record-modifier acct-type-info 'non-split))
-
 (define (gnc:register-report-hook acct-type split? create-fcn)
   (let ((type-info (hash-ref gnc:*register-report-hash* acct-type (make-acct-type))))
     (if split?



Summary of changes:
 .../report/standard-reports/standard-reports.scm   | 22 ++----
 libgnucash/app-utils/test/CMakeLists.txt           |  1 +
 libgnucash/tax/us/txf-de_DE.scm                    | 79 ++++++++--------------
 libgnucash/tax/us/txf.scm                          | 74 +++++++-------------
 4 files changed, 60 insertions(+), 116 deletions(-)



More information about the gnucash-changes mailing list