From d077400ba87b44af75c1c3b97661d035028e9aca Mon Sep 17 00:00:00 2001 From: christopherlam Date: Tue, 24 Oct 2017 12:59:25 +0800 Subject: [PATCH] Enhance account filter to a regex This commit will enhance the account fullname filter to full regex matching capabilities. Will allow complex account fullname queries e.g. "Car|Flights|Travel" --- .../standard-reports/income-gst-statement.scm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gnucash/report/standard-reports/income-gst-statement.scm b/gnucash/report/standard-reports/income-gst-statement.scm index 92d047695b..20885eb73f 100644 --- a/gnucash/report/standard-reports/income-gst-statement.scm +++ b/gnucash/report/standard-reports/income-gst-statement.scm @@ -37,6 +37,7 @@ (use-modules (gnucash main)) ;; FIXME: delete after we finish modularizing. (use-modules (srfi srfi-1)) (use-modules (srfi srfi-13)) +(use-modules (ice-9 regex)) (use-modules (gnucash gnc-module)) (use-modules (gnucash gettext)) (use-modules (gnucash printf)) @@ -695,10 +696,10 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo (gnc:register-trep-option (gnc:make-string-option - gnc:pagename-accounts (N_ "Account Substring") - "b15" (N_ "Match only above accounts whose fullname contains substring e.g. ':Travel' will \ -match Expenses:Travel:Holiday and Expenses:Business:Travel. Can be left blank, which will \ -disable the substring filter. This filter is case-sensitive.") + gnc:pagename-accounts (N_ "Account Matcher") + "b15" (N_ "Match only above accounts whose fullname matches regex e.g. ':Travel' will \ +match Expenses:Travel:Holiday and Expenses:Business:Travel. 'Car|Flights' will match both \ +Expenses:Car and Expenses:Flights. It can be left blank, which will disable the matcher.") "")) (gnc:register-trep-option @@ -1587,10 +1588,10 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.") (let* ((document (gnc:make-html-document)) (c_account_0 (opt-val gnc:pagename-accounts "Accounts")) - (c_account_substring (opt-val gnc:pagename-accounts "Account Substring")) + (c_account_matcher (opt-val gnc:pagename-accounts "Account Matcher")) (c_account_1 (filter (lambda (acc) - (string-contains (gnc-account-get-full-name acc) c_account_substring)) + (string-match c_account_matcher (gnc-account-get-full-name acc))) c_account_0)) (c_account_2 (opt-val gnc:pagename-accounts "Filter By...")) (tax-accounts (opt-val gnc:pagename-accounts "Tax Accounts"))