gnucash master: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Tue May 12 10:06:05 EDT 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/57fe0515 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b4d7386d (commit)
	from  https://github.com/Gnucash/gnucash/commit/ebd9db89 (commit)



commit 57fe05156535bc67960b2497393cf8eee3525a73
Merge: ebd9db892 b4d7386d4
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue May 12 21:47:36 2020 +0800

    Merge branch 'maint-trep-case-insensitive' PR #719


commit b4d7386d44122384c036ae68c1a090bc36210389
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon May 11 20:51:21 2020 +0800

    [trep-engine] "Transaction Filter is case insensitive"
    
    add Filter option to make Transaction Filter case insensitive.

diff --git a/gnucash/report/reports/standard/test/test-transaction.scm b/gnucash/report/reports/standard/test/test-transaction.scm
index a32a28012..5af64492f 100644
--- a/gnucash/report/reports/standard/test/test-transaction.scm
+++ b/gnucash/report/reports/standard/test/test-transaction.scm
@@ -355,6 +355,22 @@
           '("$24.00")
           (get-row-col sxml -1 -1)))
 
+      (set-option! options "Filter" "Transaction Filter excludes matched strings" #f)
+      (set-option! options "Filter" "Use regular expressions for transaction filter" #f)
+      (set-option! options "Filter" "Transaction Filter is case insensitive" #t)
+      (set-option! options "Filter" "Transaction Filter" "dEsC-3")
+      (let ((sxml (options->sxml options "transaction filter insensitive")))
+        (test-equal "transaction filter case insensitive"
+          '("$29.00")
+          (get-row-col sxml -1 -1)))
+
+      (set-option! options "Filter" "Use regular expressions for transaction filter" #t)
+      (set-option! options "Filter" "Transaction Filter" "NoT.S?")
+      (let ((sxml (options->sxml options "transaction filter regex case insensitive")))
+        (test-equal "transaction filter regex case insensitive"
+          '("-$23.00")
+          (get-row-col sxml -1 -1)))
+
       ;; Test Reconcile Status Filters
       (set! options (default-testing-options))
       (set-option! options "General" "Start Date" (cons 'absolute (gnc-dmy2time64 01 01 1969)))
diff --git a/gnucash/report/trep-engine.scm b/gnucash/report/trep-engine.scm
index 64708d99b..264c4cb7e 100644
--- a/gnucash/report/trep-engine.scm
+++ b/gnucash/report/trep-engine.scm
@@ -92,6 +92,8 @@
   (N_ "Use regular expressions for transaction filter"))
 (define optname-transaction-matcher-exclude
   (N_ "Transaction Filter excludes matched strings"))
+(define optname-transaction-matcher-caseinsensitive
+  (N_ "Transaction Filter is case insensitive"))
 (define optname-reconcile-status (N_ "Reconcile Status"))
 (define optname-void-transactions (N_ "Void Transactions"))
 (define optname-closing-transactions (N_ "Closing transactions"))
@@ -614,6 +616,13 @@ tags within description, notes or memo. ")
     (_ "If this option is selected, transactions matching filter are excluded.")
     #f))
 
+  (gnc:register-trep-option
+   (gnc:make-simple-boolean-option
+    pagename-filter optname-transaction-matcher-caseinsensitive
+    "i4"
+    (_ "If this option is selected, transactions matching filter is not case sensitive.")
+    #f))
+
   (gnc:register-trep-option
    (gnc:make-multichoice-option
     pagename-filter optname-reconcile-status
@@ -1985,11 +1994,16 @@ be excluded from periodic reporting.")
                    (gnc:date-option-absolute-time
                     (opt-val gnc:pagename-general optname-enddate))))
          (transaction-matcher (opt-val pagename-filter optname-transaction-matcher))
+         (transaction-filter-case-insensitive?
+          (opt-val pagename-filter optname-transaction-matcher-caseinsensitive))
          (transaction-matcher-regexp
           (and (opt-val pagename-filter optname-transaction-matcher-regex)
                (if (defined? 'make-regexp)
                    (catch 'regular-expression-syntax
-                     (lambda () (make-regexp transaction-matcher))
+                     (lambda ()
+                       (if transaction-filter-case-insensitive?
+                           (make-regexp transaction-matcher regexp/icase)
+                           (make-regexp transaction-matcher)))
                      (const 'invalid-transaction-regex))
                    'no-guile-regex-support)))
          (transaction-filter-exclude?
@@ -2025,12 +2039,17 @@ be excluded from periodic reporting.")
                                (eq? (opt-val gnc:pagename-display (N_ "Amount"))
                                     'single)))
          (infobox-display (opt-val gnc:pagename-general optname-infobox-display))
-         (match? (lambda (str)
-                   (if transaction-matcher-regexp
-                       (regexp-exec transaction-matcher-regexp str)
-                       (string-contains str transaction-matcher))))
          (query (qof-query-create-for-splits)))
 
+    (define (match? str)
+      (cond
+       (transaction-matcher-regexp
+        (regexp-exec transaction-matcher-regexp str))
+       (transaction-filter-case-insensitive?
+        (string-contains-ci str transaction-matcher))
+       (else
+        (string-contains str transaction-matcher))))
+
     (define (generic-less? split-X split-Y sortkey date-subtotal-key ascend?)
       ;; compare splits X and Y, whereby
       ;; sortkey and date-subtotal-key specify the options used



Summary of changes:
 .../reports/standard/test/test-transaction.scm     | 16 ++++++++++++
 gnucash/report/trep-engine.scm                     | 29 ++++++++++++++++++----
 2 files changed, 40 insertions(+), 5 deletions(-)



More information about the gnucash-changes mailing list