[GNC] Dipping my toes into Scheme
Michael Hendry
hendry.michael at gmail.com
Mon Mar 23 07:27:58 EDT 2020
Rather than dive into Scheme programming with a completely new report, I’d like to try editing an existing report to provide a little customisation.
I’m looking at the experimental report balsheet-pnl.scm by Christopher Lam, which I found here on my Mac…
/Applications/Gnucash 3.8.app/Contents/Resources/share/gnucash/scm/gnucash/report/standard-reports
…and I would make a start by replacing the Footer text defined at line 47 et seqq:
(define FOOTER-TEXT
(gnc:make-html-text
(_ "WARNING: Foreign currency conversions, and unrealized gains
calculations are not confirmed correct. This report may be modified
without notice. Bug reports are very welcome at
https://bugs.gnucash.org/")))
First off, I plan to make a copy of the existing file, naming it MH_balsheet-pnl.scm (“MH” being my initials).
Now I’ll edit the text of the Footer - let’s say I replace the existing text as follows:
(define FOOTER-TEXT
(gnc:make-html-text
(_ “MH - experimental report 2020-03-23")))
[In the longer run, I’d plan to modify the text of the report to use “Revenue & Expenditure” in place of “Income and Expense”]
In other programming environments I would simply save the edited file and run it, but I can see a few pitfalls!
Line 28 reads:
(define-module (gnucash report standard-reports balsheet-pnl))
which should presumably be changed, e.g. to:
(define-module (gnucash report standard-reports MH_balsheet-pnl))
After that, I think it should be plain sailing until line 1340:
(define balsheet-reportname (_ "Balance Sheet (Multicolumn)"))
(define pnl-reportname (_ "Income Statement (Multicolumn)"))
(gnc:define-report
'version 1
'name balsheet-reportname
'report-guid "065d5d5a77ba11e8b31e83ada73c5eea"
'menu-path (list gnc:menuname-experimental)
'options-generator (lambda () (multicol-report-options-generator 'balsheet))
'renderer (lambda (rpt) (multicol-report-renderer rpt 'balsheet)))
(gnc:define-report
'version 1
'name pnl-reportname
'report-guid "0e94fd0277ba11e8825d43e27232c9d4"
'menu-path (list gnc:menuname-experimental)
'options-generator (lambda () (multicol-report-options-generator 'pnl))
'renderer (lambda (rpt) (multicol-report-renderer rpt 'pnl)))
I expect there would be scope for confusion if I didn’t change lines 1340-1 - say prefixing “MH_” to the definitions, but I’m not sure about the options-generator and renderer lines.
uuidgen on my Mac issues 36-character uuids, with hyphens and uppercase, like this:
47170C69-F87E-4A3B-9A97-8B97F56F5DFD
Would I need to edit them to give 32-character lowercase uuids, lacking hyphens?
Obviously, I have to take responsibility for my own programming experiments (and errors), but I’d appreciate a quick steer from someone with Scheme experience.
Regards,
Michael
More information about the gnucash-user
mailing list