[GNC] Configurable Year Start Day/Month

john jralls at ceridwen.us
Sat Apr 22 01:00:41 EDT 2023


Flywire,

Have you looked at https://code.gnucash.org/docs/MASTER/group__Options.html?

I guess by "set and use" you mean add a date option to your report. The basic function is documented at https://code.gnucash.org/docs/MASTER/group__Options.html#gae207538b13cb19bb68f9b9300743b709 and it has an overloaded version https://code.gnucash.org/docs/MASTER/group__Options.html#ga5dafb8587af06977a7ee03b73b852a68 that takes a std::vector of the RelativeDatePeriods to include. That's used by 
 gnc-register-start-date-option https://code.gnucash.org/docs/MASTER/group__Options.html#ga4a03e7ac556ea7774046121555df9f51, and gnc-register-end-date-option https://code.gnucash.org/docs/MASTER/group__Options.html#gaf48579ed1d96c1e7b9fbdc16b589995a to generate pre-filtered  controls with the obvious relative date offerings. There's also  gnc::options-make-date-interval that quickly adds one of each. Most reports use either gnc-register-end-date-option to set the date for a single-date report like a Balance Sheet or gnc:options-make-date-interval for reports like an Income Statement that cover a period.

Changing the way options work isn't supported, nor has it ever been. If you change the way an existing option works you'll break some built-in report. That might not matter to you because you'll be able to run your custom report. That's fine, it's what Free software is all about, but you own the change and its consequences, and you can't expect that your changes will apply cleanly after the next commit never mind the next release, as you've just discovered.

Even with the 4.x and earlier option system you couldn't create new option classes entirely in Scheme. The old option system was a horrid mix of Scheme and C because it had to support both report options and book options, plus the UI part was always pure C that had to use the Guile C API to get option values. I don' t think you're really interested in adding an option class so I'll spare you the details of what you'd need to write in C++ to do it.

Yes, you can turn on Github actions in your fork and it will run the CI for you just like it does in the GnuCash mirror, see https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository. But we don't have a Windows CI action, the nightly builds are done with the https://github.com/gnucash/GnuCash-on-windows powershell scripts on a Windows VM in Derek's basement. 

Adding new RelativeDatePeriods for 2 years ago is fairly straightforward, just add the two values to the enum and the logic to gnc_relative_date_to_time64() and set up the various strings and the swig conversions in bindings/guile/gnc-options.i.

Adding actual Fiscal Year support is another matter entirely. It's been discussed on and off for 20 years, but it requires substantial changes throughout GnuCash and so far nobody has wanted to invest the effort.

Regards,
John Ralls




> On Apr 21, 2023, at 6:23 PM, flywire <flywire0 at gmail.com> wrote:
> 
> John,
> 
> Seems like an X-Y response. The meaning of a hack is clear, although this is more of a tweak, and where it occurs hardly matters if it's not part of a PR. A response in terms of using existing report/module code in a new report would be fine. https://github.com/Gnucash/gnucash/blob/5.0/gnucash/report/reports/example/sample-report.scm#L64-L77 demonstrates creating a list of options, so it follows, changing it changes the options. I'll take it consult the list is used to mean seek advice or information, and understand some code in the repo is depreciated. None of this is core to the question.
> 
> To elaborate:
> I'm seeking guidance on the processes involved in setting and using the date option, and how to change it. There seems to be more to the changed approach in V5 https://github.com/Gnucash/gnucash/tree/5.0/libgnucash/engine than covered in the documentation. Apologies in advance if terms are used incorrectly.
> I imagine there are two approaches:
> Override the value of year in scheme so it starts 1 July in the previous year. I understand the options and lists are defined in C++ but I'm only focused on scheme reports. Are these option values in scheme mutable or can they easily be changed to mutable? Existing textual descriptions of the options are fine. Can start/end year just be registered again in a scheme report with a new definition or redefined in scheme using the date-utilities.scm process in V4?
> Redefine option values in C++. This is more problematic for me because I haven't been able to compile GnuCash in Windows. Nevertheless, every commit goes through a recompile as part of a CI process. Would it be feasible, and if so how, to use that process in a private fork and grab a windows executable from it to use on my PC? I expect I could work my way through the C++ code and change value definitions and lists.
> I'd actually like to add a new date symbol for start/end of 2 years prior period.
> Your response previously linked from 2021 shows you have considered it. Maybe you have a better approach in mind, possibly something this year. It could be relevant.
> 
> Regards



More information about the gnucash-user mailing list