mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Change the reports from using a hard-coded fiscal year to using the global
accounting period set in the preferences. Both the start date and the end date are used, so the user is free to choose any arbitrary period. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13199 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
6ab484e319
commit
71625058fa
@ -209,10 +209,6 @@
|
|||||||
(export gnc:get-end-cal-year)
|
(export gnc:get-end-cal-year)
|
||||||
(export gnc:get-start-prev-year)
|
(export gnc:get-start-prev-year)
|
||||||
(export gnc:get-end-prev-year)
|
(export gnc:get-end-prev-year)
|
||||||
(export gnc:get-start-cur-fin-year)
|
|
||||||
(export gnc:get-start-prev-fin-year)
|
|
||||||
(export gnc:get-end-prev-fin-year)
|
|
||||||
(export gnc:get-end-cur-fin-year)
|
|
||||||
(export gnc:get-start-this-month)
|
(export gnc:get-start-this-month)
|
||||||
(export gnc:get-end-this-month)
|
(export gnc:get-end-this-month)
|
||||||
(export gnc:get-start-prev-month)
|
(export gnc:get-start-prev-month)
|
||||||
|
@ -20,14 +20,6 @@
|
|||||||
;; 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
;; 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||||
;; Boston, MA 02110-1301, USA gnu@gnu.org
|
;; Boston, MA 02110-1301, USA gnu@gnu.org
|
||||||
|
|
||||||
|
|
||||||
;; fin-year-start format: mm dd
|
|
||||||
(define fin-year-start '(07 01))
|
|
||||||
|
|
||||||
|
|
||||||
(define fin-year-start-month (- (car fin-year-start) 1)) ;; jan == 0
|
|
||||||
(define fin-year-start-day (cadr fin-year-start))
|
|
||||||
|
|
||||||
(define gnc:reldate-list '())
|
(define gnc:reldate-list '())
|
||||||
|
|
||||||
(define (gnc:timepair->secs tp)
|
(define (gnc:timepair->secs tp)
|
||||||
@ -461,80 +453,11 @@
|
|||||||
(set-tm:isdst now -1)
|
(set-tm:isdst now -1)
|
||||||
(gnc:date->timepair now)))
|
(gnc:date->timepair now)))
|
||||||
|
|
||||||
;; FIXME:: Replace with option when it becomes available
|
(define (gnc:get-start-accounting-period)
|
||||||
(define (gnc:get-start-cur-fin-year)
|
(gnc:secs->timepair (gnc:accounting-period-start)))
|
||||||
(let ((now (localtime (current-time))))
|
|
||||||
(if (or (< (tm:mon now) fin-year-start-month) (and (= (tm:mon now) fin-year-start-month) (< (tm:mday now) fin-year-start-day) ))
|
|
||||||
(begin
|
|
||||||
(set-tm:sec now 0)
|
|
||||||
(set-tm:min now 0)
|
|
||||||
(set-tm:hour now 0)
|
|
||||||
(set-tm:mday now fin-year-start-day)
|
|
||||||
(set-tm:mon now fin-year-start-month)
|
|
||||||
(set-tm:year now (- (tm:year now) 1))
|
|
||||||
(set-tm:isdst now -1)
|
|
||||||
(gnc:date->timepair now))
|
|
||||||
(begin
|
|
||||||
(set-tm:sec now 0)
|
|
||||||
(set-tm:min now 0)
|
|
||||||
(set-tm:hour now 0)
|
|
||||||
(set-tm:mday now fin-year-start-day)
|
|
||||||
(set-tm:mon now fin-year-start-month)
|
|
||||||
(set-tm:isdst now -1)
|
|
||||||
(gnc:date->timepair now)))))
|
|
||||||
|
|
||||||
(define (gnc:get-start-prev-fin-year)
|
(define (gnc:get-end-accounting-period)
|
||||||
(let ((now (localtime (current-time))))
|
(gnc:secs->timepair (gnc:accounting-period-end)))
|
||||||
(if (or (< (tm:mon now) fin-year-start-month) (and (= (tm:mon now) fin-year-start-month) (< (tm:mday now) fin-year-start-day) ))
|
|
||||||
(begin
|
|
||||||
(set-tm:sec now 0)
|
|
||||||
(set-tm:min now 0)
|
|
||||||
(set-tm:hour now 0)
|
|
||||||
(set-tm:mday now fin-year-start-day)
|
|
||||||
(set-tm:mon now fin-year-start-month)
|
|
||||||
(set-tm:year now (- (tm:year now) 2))
|
|
||||||
(set-tm:isdst now -1)
|
|
||||||
(gnc:date->timepair now))
|
|
||||||
(begin
|
|
||||||
(set-tm:sec now 0)
|
|
||||||
(set-tm:min now 0)
|
|
||||||
(set-tm:hour now 0)
|
|
||||||
(set-tm:mday now fin-year-start-day)
|
|
||||||
(set-tm:mon now fin-year-start-month)
|
|
||||||
(set-tm:year now (- (tm:year now) 1))
|
|
||||||
(set-tm:isdst now -1)
|
|
||||||
(gnc:date->timepair now)))))
|
|
||||||
|
|
||||||
(define (gnc:get-start-next-fin-year)
|
|
||||||
(let ((now (localtime (current-time))))
|
|
||||||
(if (or (< (tm:mon now) fin-year-start-month) (and (= (tm:mon now) fin-year-start-month) (< (tm:mday now) fin-year-start-day) ))
|
|
||||||
(begin
|
|
||||||
(set-tm:sec now 0)
|
|
||||||
(set-tm:min now 0)
|
|
||||||
(set-tm:hour now 0)
|
|
||||||
(set-tm:mday now fin-year-start-day)
|
|
||||||
(set-tm:mon now fin-year-start-month)
|
|
||||||
(set-tm:isdst now -1)
|
|
||||||
(gnc:date->timepair now))
|
|
||||||
(begin
|
|
||||||
(set-tm:sec now 0)
|
|
||||||
(set-tm:min now 0)
|
|
||||||
(set-tm:hour now 0)
|
|
||||||
(set-tm:mday now fin-year-start-day)
|
|
||||||
(set-tm:mon now fin-year-start-month)
|
|
||||||
(set-tm:year now (+ (tm:year now) 1))
|
|
||||||
(set-tm:isdst now -1)
|
|
||||||
(gnc:date->timepair now)))))
|
|
||||||
|
|
||||||
(define (gnc:get-end-prev-fin-year)
|
|
||||||
(let ((now (gnc:get-start-cur-fin-year)))
|
|
||||||
(gnc:secs->timepair (- (gnc:timepair->secs now) 1))
|
|
||||||
))
|
|
||||||
|
|
||||||
(define (gnc:get-end-cur-fin-year)
|
|
||||||
(let ((now (gnc:get-start-next-fin-year)))
|
|
||||||
(gnc:secs->timepair (- (gnc:timepair->secs now) 1))
|
|
||||||
))
|
|
||||||
|
|
||||||
(define (gnc:get-start-this-month)
|
(define (gnc:get-start-this-month)
|
||||||
(let ((now (localtime (current-time))))
|
(let ((now (localtime (current-time))))
|
||||||
@ -734,32 +657,18 @@
|
|||||||
(N_ "End of the Previous Year"))
|
(N_ "End of the Previous Year"))
|
||||||
|
|
||||||
(gnc:reldate-string-db
|
(gnc:reldate-string-db
|
||||||
'store 'start-cur-fin-year-string
|
'store 'start-accounting-period-string
|
||||||
(N_ "Current Financial Year Start"))
|
(N_ "Start of Financial Period"))
|
||||||
(gnc:reldate-string-db
|
(gnc:reldate-string-db
|
||||||
'store 'start-cur-fin-year-desc
|
'store 'start-accounting-period-desc
|
||||||
(N_ "Start of the current financial year/accounting period"))
|
(N_ "Start of the accounting period, as set in the global preferences"))
|
||||||
|
|
||||||
(gnc:reldate-string-db
|
(gnc:reldate-string-db
|
||||||
'store 'start-prev-fin-year-string
|
'store 'end-accounting-period-string
|
||||||
(N_ "Previous Financial Year Start"))
|
(N_ "End of Financial Period"))
|
||||||
(gnc:reldate-string-db
|
(gnc:reldate-string-db
|
||||||
'store 'start-prev-fin-year-desc
|
'store 'end-accounting-period-desc
|
||||||
(N_ "The start of the previous financial year/accounting period"))
|
(N_ "End of the accounting period, as set in the global preferences"))
|
||||||
|
|
||||||
(gnc:reldate-string-db
|
|
||||||
'store 'end-prev-fin-year-string
|
|
||||||
(N_ "End Previous Financial Year"))
|
|
||||||
(gnc:reldate-string-db
|
|
||||||
'store 'end-prev-fin-year-desc
|
|
||||||
(N_ "End of the previous Financial year/Accounting Period"))
|
|
||||||
|
|
||||||
(gnc:reldate-string-db
|
|
||||||
'store 'end-cur-fin-year-string
|
|
||||||
(N_ "End Current Financial Year"))
|
|
||||||
(gnc:reldate-string-db
|
|
||||||
'store 'end-cur-fin-year-desc
|
|
||||||
(N_ "End of the current Financial year/Accounting Period"))
|
|
||||||
|
|
||||||
(gnc:reldate-string-db
|
(gnc:reldate-string-db
|
||||||
'store 'start-this-month-string
|
'store 'start-this-month-string
|
||||||
@ -870,22 +779,14 @@
|
|||||||
(gnc:reldate-string-db 'lookup 'end-prev-year-string)
|
(gnc:reldate-string-db 'lookup 'end-prev-year-string)
|
||||||
(gnc:reldate-string-db 'lookup 'end-prev-year-desc)
|
(gnc:reldate-string-db 'lookup 'end-prev-year-desc)
|
||||||
gnc:get-end-prev-year)
|
gnc:get-end-prev-year)
|
||||||
(vector 'start-cur-fin-year
|
(vector 'start-accounting-period
|
||||||
(gnc:reldate-string-db 'lookup 'start-cur-fin-year-string)
|
(gnc:reldate-string-db 'lookup 'start-accounting-period-string)
|
||||||
(gnc:reldate-string-db 'lookup 'start-cur-fin-year-desc)
|
(gnc:reldate-string-db 'lookup 'start-accounting-period-desc)
|
||||||
gnc:get-start-cur-fin-year)
|
gnc:get-start-accounting-period)
|
||||||
(vector 'start-prev-fin-year
|
(vector 'end-accounting-period
|
||||||
(gnc:reldate-string-db 'lookup 'start-prev-fin-year-string)
|
(gnc:reldate-string-db 'lookup 'end-accounting-period-string)
|
||||||
(gnc:reldate-string-db 'lookup 'start-prev-fin-year-desc)
|
(gnc:reldate-string-db 'lookup 'end-accounting-period-desc)
|
||||||
gnc:get-start-prev-fin-year)
|
gnc:get-end-accounting-period)
|
||||||
(vector 'end-prev-fin-year
|
|
||||||
(gnc:reldate-string-db 'lookup 'end-prev-fin-year-string)
|
|
||||||
(gnc:reldate-string-db 'lookup 'end-prev-fin-year-desc)
|
|
||||||
gnc:get-end-prev-fin-year)
|
|
||||||
(vector 'end-cur-fin-year
|
|
||||||
(gnc:reldate-string-db 'lookup 'end-cur-fin-year-string)
|
|
||||||
(gnc:reldate-string-db 'lookup 'end-cur-fin-year-desc)
|
|
||||||
gnc:get-end-cur-fin-year)
|
|
||||||
(vector 'start-this-month
|
(vector 'start-this-month
|
||||||
(gnc:reldate-string-db 'lookup 'start-this-month-string)
|
(gnc:reldate-string-db 'lookup 'start-this-month-string)
|
||||||
(gnc:reldate-string-db 'lookup 'start-this-month-desc)
|
(gnc:reldate-string-db 'lookup 'start-this-month-desc)
|
||||||
|
@ -167,9 +167,8 @@ time_t gnc_accounting_period_end_timet (GncAccountingPeriod which,
|
|||||||
const GDate *contains);
|
const GDate *contains);
|
||||||
|
|
||||||
|
|
||||||
/* Convenience routines that take care of getting the fiscal
|
/* Get the fiscal accounting period from the preferences and return
|
||||||
accounting period from the preferences and returning the start and
|
the start and end times. */
|
||||||
end times. */
|
|
||||||
time_t gnc_accounting_period_fiscal_start(void);
|
time_t gnc_accounting_period_fiscal_start(void);
|
||||||
time_t gnc_accounting_period_fiscal_end(void);
|
time_t gnc_accounting_period_fiscal_end(void);
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
"#include <gnc-ui-util.h>\n"
|
"#include <gnc-ui-util.h>\n"
|
||||||
"#include <gnc-gettext-util.h>\n"
|
"#include <gnc-gettext-util.h>\n"
|
||||||
"#include <gnc-helpers.h>\n"
|
"#include <gnc-helpers.h>\n"
|
||||||
|
"#include <gnc-accounting-period.h>\n"
|
||||||
"#include <gnc-component-manager.h>\n")))
|
"#include <gnc-component-manager.h>\n")))
|
||||||
|
|
||||||
(gw:wrap-simple-type ws '<gnc:print-amount-info-scm> "GNCPrintAmountInfo"
|
(gw:wrap-simple-type ws '<gnc:print-amount-info-scm> "GNCPrintAmountInfo"
|
||||||
@ -398,6 +399,21 @@ determines formatting details.")
|
|||||||
'((<gnc:commodity-table*> table))
|
'((<gnc:commodity-table*> table))
|
||||||
"Return a list of all the quotable commodities in a given namespace in the table.")
|
"Return a list of all the quotable commodities in a given namespace in the table.")
|
||||||
|
|
||||||
|
(gw:wrap-function
|
||||||
|
ws
|
||||||
|
'gnc:accounting-period-start
|
||||||
|
'<gw:int>
|
||||||
|
"gnc_accounting_period_fiscal_start"
|
||||||
|
'()
|
||||||
|
"Returns the beginning of the preferred accounting period")
|
||||||
|
|
||||||
|
(gw:wrap-function
|
||||||
|
ws
|
||||||
|
'gnc:accounting-period-end
|
||||||
|
'<gw:int>
|
||||||
|
"gnc_accounting_period_fiscal_end"
|
||||||
|
'()
|
||||||
|
"Returns the end of the preferred accounting period")
|
||||||
|
|
||||||
(gw:wrap-function
|
(gw:wrap-function
|
||||||
ws
|
ws
|
||||||
|
@ -1533,9 +1533,8 @@
|
|||||||
end-current-quarter
|
end-current-quarter
|
||||||
end-prev-quarter
|
end-prev-quarter
|
||||||
end-cal-year
|
end-cal-year
|
||||||
end-prev-year
|
end-prev-year
|
||||||
end-cur-fin-year
|
end-accounting-period
|
||||||
end-prev-fin-year
|
|
||||||
))))
|
))))
|
||||||
|
|
||||||
(define (gnc:options-make-date-interval! options pagename name-from info-from
|
(define (gnc:options-make-date-interval! options pagename name-from info-from
|
||||||
@ -1555,8 +1554,7 @@
|
|||||||
start-prev-quarter
|
start-prev-quarter
|
||||||
start-cal-year
|
start-cal-year
|
||||||
start-prev-year
|
start-prev-year
|
||||||
start-cur-fin-year
|
start-accounting-period
|
||||||
start-prev-fin-year
|
|
||||||
)))
|
)))
|
||||||
(gnc:options-make-end-date! options pagename name-to
|
(gnc:options-make-end-date! options pagename name-to
|
||||||
(string-append sort-tag "b") info-to))
|
(string-append sort-tag "b") info-to))
|
||||||
|
Loading…
Reference in New Issue
Block a user