Skip to content

Commit

Permalink
Account fullname filter for transaction.scm
Browse files Browse the repository at this point in the history
This small change will introduce an account full-name filter. Only accounts whose fullname containing substring will be selected e.g. ":Travel" will match Expenses:Travel:Holiday and Expenses:Business:Travel. This can be left blank, which will mimic previous behavior. This will ease accounts selection tremendously.
  • Loading branch information
christopherlam committed Aug 16, 2017
1 parent 1559d26 commit 6eee9ce
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/report/standard-reports/transaction.scm
Expand Up @@ -33,6 +33,7 @@

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

Expand Down Expand Up @@ -660,6 +661,14 @@
'())
#f #t))

(gnc:register-trep-option
(gnc:make-string-option
gnc:pagename-accounts (N_ "Account Substring")
"a5" (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.")
""))

(gnc:register-trep-option
(gnc:make-account-list-option
gnc:pagename-accounts (N_ "Filter By...")
Expand Down Expand Up @@ -1422,6 +1431,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_substring (opt-val gnc:pagename-accounts "Account Substring"))
(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
Expand All @@ -1444,6 +1454,11 @@ Credit Card, and Income accounts.")))))
;;(gnc:warn "accts in trep-renderer:" c_account_1)
;;(gnc:warn "Report Account names:" (get-other-account-names c_account_1))

(set! c_account_1
(filter (lambda (acc)
(string-contains (gnc-account-get-full-name acc) c_account_substring))
c_account_1))

(if (not (or (null? c_account_1) (and-map not c_account_1)))
(begin
(qof-query-set-book query (gnc-get-current-book))
Expand Down

0 comments on commit 6eee9ce

Please sign in to comment.