Suggestion to transaction.scm

Christopher Lam christopher.lck at
Sun Aug 13 00:57:59 EDT 2017

I'd like to suggest an addition to transaction.scm. I enjoy using it - I
think it's the most versatile reporting engine.

However the account selector is, to say the least, very fiddly.

This diff will enable 'substring matcher' so that I can search for "^1" for
all of my accountant-related accounts, which matches
Income:Chris^1:Freelance, Expenses:Business^1:* and
Expenses:Household:Electricity^1. So I'd click "Select All" accounts, input
the substring matcher, and it'll filter relevant accounts. It could select
":Auto" which would match "Assets:Fixed:Auto" and "Expenses:Auto:Gas".

I wish to generate some discussion here prior to creating a PR. Or shall I
add into the beefed up transaction.scm that I will prepare a bigger PR next

See screenshot as attachment, and the small diff below

------------------------------- transaction.scm
index 85bb537..d1a1e72 100644
@@ -33,6 +33,7 @@

 (use-modules (gnucash main)) ;; FIXME: delete after we finish modularizing.
 (use-modules (srfi srfi-1))
+(use-modules (srfi srfi-13))   ;; needed for string-contains
 (use-modules (gnucash gnc-module))
 (use-modules (gnucash gettext))

@@ -661,6 +662,12 @@
     #f #t))

+   (gnc:make-string-option
+    gnc:pagename-accounts (N_ "Account Matcher")
+    "a5" (N_ "Match only above accounts whose fullname constains substring
eg :Travel:")
+    ""))
+  (gnc:register-trep-option
     gnc:pagename-accounts (N_ "Filter By...")
     "b" (N_ "Filter on these accounts.")
@@ -1422,6 +1429,7 @@ Credit Card, and Income accounts.")))))
   (gnc:report-starting reportname)
   (let ((document (gnc:make-html-document))
     (c_account_1 (opt-val gnc:pagename-accounts "Accounts"))
+        (c_account_matcher (opt-val gnc:pagename-accounts "Account
     (c_account_2 (opt-val gnc:pagename-accounts "Filter By..."))
     (filter-mode (opt-val gnc:pagename-accounts "Filter Type"))
         (begindate (gnc:timepair-start-day-time
@@ -1444,6 +1452,11 @@ Credit Card, and Income accounts.")))))
     ;;(gnc:warn "accts in trep-renderer:" c_account_1)
     ;;(gnc:warn "Report Account names:" (get-other-account-names

+    (set! c_account_1
+          (filter (lambda (acc)
+                    (string-contains (gnc-account-get-full-name acc)
+                  c_account_1))
     (if (not (or (null? c_account_1) (and-map not c_account_1)))
           (qof-query-set-book query (gnc-get-current-book))

On 30 June 2017 at 08:15, Christopher Lam <christopher.lck at> wrote:

> Hi Doug
> I'd be keen to hack scheme to modify the source "Accounts" tree which is
> common to several report types.
> Right now you select your originating accounts, and when you 'save' the
> report options, the account guid are hardcoded into the options. This
> causes issues if we modify the chart of accounts. Wouldn't it be nice to
> choose any of the following account ie name/description/notes:
> 1. "Income:Chris:"
> 2. "Expenses:Business:"
> 3. ":Travel" which captures splits from both Expenses:Business:Travel and
> Expenses:Holiday:Travel
> 4. "^1" my favorite, will capture splits from accounts such as
> Expenses:Business^1:etc and Expenses:Household:Electric^1, perfect for the
> accountant. The wife gets to use ^2 :)
> Next step could be to search account types (eg INCOME only)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: matcher.png
Type: image/png
Size: 18380 bytes
Desc: not available
URL: <>

More information about the gnucash-devel mailing list