[GNC] Hack Financial / Fiscal Year in all Reports
flywire
flywire0 at gmail.com
Sat Oct 2 20:32:42 EDT 2021
I've been using this hack which changes the definition of current and
previous year in reports to start 1 July. It will be overwritten each time
a new version of GnuCash is installed and it's unlikely to work with the
next major release.
Find date-utilities.scm eg C:\Program Files
(x86)\gnucash\share\guile\site\2.2\gnucash\app-utils\date-utilities.scm
Update code block (around line 540) with a text editor to that shown below:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; end relative-date functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define* (gnc:get-start-cal-year #:key (start-month-fy 6))
;; Jan is 0
(let ((now (gnc-localtime (current-time))))
(set-tm:sec now 0)
(set-tm:min now 0)
(set-tm:hour now 0)
(set-tm:mday now 1)
(set-tm:mon now start-month-fy)
(if (< (tm:mon now) start-month-fy)
(set-tm:year now (- (tm:year now) 1))
(set-tm:year now (tm:year now)))
(set-tm:isdst now -1)
(gnc-mktime now)))
(define* (gnc:get-end-cal-year #:key (start-month-fy 6))
(let ((now (gnc-localtime (current-time))))
(set-tm:sec now 59)
(set-tm:min now 59)
(set-tm:hour now 23)
(set-tm:mday now 30) ; set for month before start-month-fy
(if (< (tm:mon now) start-month-fy)
(set-tm:year now (tm:year now))
(set-tm:year now (+ (tm:year now) 1)))
(set-tm:mon now (- start-month-fy 1)) ; move line and it works
(set-tm:isdst now -1)
(gnc-mktime now)))
(define* (gnc:get-start-prev-year #:key (start-month-fy 6))
(let ((now (gnc-localtime (current-time))))
(set-tm:sec now 0)
(set-tm:min now 0)
(set-tm:hour now 0)
(set-tm:mday now 1)
(set-tm:mon now start-month-fy)
(if (< (tm:mon now) start-month-fy)
(set-tm:year now (- (tm:year now) 2))
(set-tm:year now (- (tm:year now) 1)))
(set-tm:isdst now -1)
(gnc-mktime now)))
(define* (gnc:get-end-prev-year #:key (start-month-fy 6))
(let ((now (gnc-localtime (current-time))))
(set-tm:sec now 59)
(set-tm:min now 59)
(set-tm:hour now 23)
(set-tm:mday now 30) ; set for month before start-month-fy
(if (< (tm:mon now) start-month-fy)
(set-tm:year now (- (tm:year now) 1))
(set-tm:year now (tm:year now)))
(set-tm:mon now (- start-month-fy 1)) ; move line and it works
(set-tm:isdst now -1)
(gnc-mktime now)))
More information about the gnucash-user
mailing list