Suggestion to transaction.scm

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Suggestion to transaction.scm

Christopher Lam
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
week?

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:register-trep-option
+   (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:make-account-list-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
Matcher"))
     (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
c_account_1))

+    (set! c_account_1
+          (filter (lambda (acc)
+                    (string-contains (gnc-account-get-full-name acc)
c_account_matcher))
+                  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))

On 30 June 2017 at 08:15, Christopher Lam <[hidden email]> 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)
>

_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

matcher.png (24K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Suggestion to transaction.scm

Christopher Lam
Btw this works for win10 with old guile so I'd wager OSX and Linux should
be fine

On 13 Aug 2017 12:57, "Christopher Lam" <[hidden email]> wrote:

> 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
> week?
>
> 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:register-trep-option
> +   (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:make-account-list-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
> Matcher"))
>      (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
> c_account_1))
>
> +    (set! c_account_1
> +          (filter (lambda (acc)
> +                    (string-contains (gnc-account-get-full-name acc)
> c_account_matcher))
> +                  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))
>
> On 30 June 2017 at 08:15, Christopher Lam <[hidden email]>
> 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)
>>
>
>
_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Loading...