Gnucash report amendments

Geert Janssens geert.gnucash at kobaltwit.be
Thu Sep 25 11:13:06 EDT 2014


Dear Christopher,

On Sunday 21 September 2014 23:21:53 Christopher Lam wrote:
> Dear devs
> 
> First and foremost I am very grateful for the ongoing work on gnucash
> development.
> 
> I am most grateful for the "Saved report configuration" UI in 2.6
> release.
> 
I'm happy you like the improvements.

> For my workflow I'd like to generate a report, and export HTML to be
> annotated and sent to accountant. And I have tried hacking the Scheme
> reports but I find them far too esoteric.
> 
Heh, it's true that scheme follows a totally different programming 
paradigm than say C, or python or perl.

It takes some time to get used to. After that is actually a relatively 
simple language with powerful features.

> Yet I'd like to request some pointers to hacking scheme. My request
> relates to making small changes with the default transaction report,
> illustrated thus or in attachment
> http://imgur.com/JDbdQGq
> 
> I feel this is a relatively small change; can anyone show me how?
There are several aspects of your change request.

I'll take the account part as an example.
The account header is generated in transaction.scm ,line 156.
This function uses gnc:html-markup-anchor to create the hyperlink.
gnc:html-markup-anchor is a function that takes two arguments - the 
address of the hyperlink and the descriptive text.
The first of these arguments is generated with gnc:account-anchor-text, 
which generates a virtual address for an account. This virtual address 
only works inside gnucash and is what you want to eliminate.
The second parameter, the descriptive text is provided by the account-
namestring function.

So what you want to achieve here is to replace the complete gnc:html-
markup-anchor function with only the account-namestring function and 
then the hyperlink is gone.

Next you will have to figure out how to add another column to the 
account line in which you re-add the gnc:html-markup-anchor (and even 
its wrapper gnc:make-html-text) line in full, except for the account-
namestring function. Based on your mockup, the descriptive text would be 
the literal string "[Open]".

Adding another column is more tricky. In the same function you see that 
the result of function gnc:make-html-text is passed to add-subheading-
row.

That function takes the integral data generated by gnc:make-html-text 
and wraps it in a table cell (line 130 in the file). So this function 
effectively expects to get data for only one cell, while you want it to 
accept data for two cells. So that needs extending in some way. One way 
to do it would be to pass it a list of output from gnc:make-html-text 
values and create a cell for each object on the list. Then you can put 
these generated cells on a list together to pass to gnc:html-table-
append-row/markup!. As you can see in line 135, this function already 
expects a list of cells albeit the current code only passes a list of 
one cell.

With this you will also have to keep in mind that a parameter "width" is 
passed to add-subheading-row. This parameter is used to indicate the 
total amount of columns there are in the final table. Since the row 
cells only have one cell so far, width is used to specify the proper 
col-span (line 131). The moment you add a column with your hyperlinks 
the number of columns will change which you probably have to correct in 
multiple spots in the code.

That's a first descriptive explanation of changes that should happen. 
Will that allow you to make the changes you need ?

On the other hand, if scheme is to esoteric you may consider using 
something like perl to process the generated html before opening the 
file in Excel. It should be fairly easy to write a regular expression 
that strips all html anchors.

Regards,

Geert


More information about the gnucash-user mailing list