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:
Chris Shoemaker 2006-02-11 05:14:21 +00:00
parent 6ab484e319
commit 71625058fa
5 changed files with 41 additions and 131 deletions

View File

@ -209,10 +209,6 @@
(export gnc:get-end-cal-year)
(export gnc:get-start-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-end-this-month)
(export gnc:get-start-prev-month)

View File

@ -20,14 +20,6 @@
;; 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
;; 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:timepair->secs tp)
@ -461,80 +453,11 @@
(set-tm:isdst now -1)
(gnc:date->timepair now)))
;; FIXME:: Replace with option when it becomes available
(define (gnc:get-start-cur-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: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-accounting-period)
(gnc:secs->timepair (gnc:accounting-period-start)))
(define (gnc:get-start-prev-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: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-end-accounting-period)
(gnc:secs->timepair (gnc:accounting-period-end)))
(define (gnc:get-start-this-month)
(let ((now (localtime (current-time))))
@ -734,32 +657,18 @@
(N_ "End of the Previous Year"))
(gnc:reldate-string-db
'store 'start-cur-fin-year-string
(N_ "Current Financial Year Start"))
'store 'start-accounting-period-string
(N_ "Start of Financial Period"))
(gnc:reldate-string-db
'store 'start-cur-fin-year-desc
(N_ "Start of the current financial year/accounting period"))
'store 'start-accounting-period-desc
(N_ "Start of the accounting period, as set in the global preferences"))
(gnc:reldate-string-db
'store 'start-prev-fin-year-string
(N_ "Previous Financial Year Start"))
'store 'end-accounting-period-string
(N_ "End of Financial Period"))
(gnc:reldate-string-db
'store 'start-prev-fin-year-desc
(N_ "The start of the previous financial year/accounting period"))
(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"))
'store 'end-accounting-period-desc
(N_ "End of the accounting period, as set in the global preferences"))
(gnc:reldate-string-db
'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-desc)
gnc:get-end-prev-year)
(vector 'start-cur-fin-year
(gnc:reldate-string-db 'lookup 'start-cur-fin-year-string)
(gnc:reldate-string-db 'lookup 'start-cur-fin-year-desc)
gnc:get-start-cur-fin-year)
(vector 'start-prev-fin-year
(gnc:reldate-string-db 'lookup 'start-prev-fin-year-string)
(gnc:reldate-string-db 'lookup 'start-prev-fin-year-desc)
gnc:get-start-prev-fin-year)
(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-accounting-period
(gnc:reldate-string-db 'lookup 'start-accounting-period-string)
(gnc:reldate-string-db 'lookup 'start-accounting-period-desc)
gnc:get-start-accounting-period)
(vector 'end-accounting-period
(gnc:reldate-string-db 'lookup 'end-accounting-period-string)
(gnc:reldate-string-db 'lookup 'end-accounting-period-desc)
gnc:get-end-accounting-period)
(vector 'start-this-month
(gnc:reldate-string-db 'lookup 'start-this-month-string)
(gnc:reldate-string-db 'lookup 'start-this-month-desc)

View File

@ -167,9 +167,8 @@ time_t gnc_accounting_period_end_timet (GncAccountingPeriod which,
const GDate *contains);
/* Convenience routines that take care of getting the fiscal
accounting period from the preferences and returning the start and
end times. */
/* Get the fiscal accounting period from the preferences and return
the start and end times. */
time_t gnc_accounting_period_fiscal_start(void);
time_t gnc_accounting_period_fiscal_end(void);

View File

@ -32,6 +32,7 @@
"#include <gnc-ui-util.h>\n"
"#include <gnc-gettext-util.h>\n"
"#include <gnc-helpers.h>\n"
"#include <gnc-accounting-period.h>\n"
"#include <gnc-component-manager.h>\n")))
(gw:wrap-simple-type ws '<gnc:print-amount-info-scm> "GNCPrintAmountInfo"
@ -398,6 +399,21 @@ determines formatting details.")
'((<gnc:commodity-table*> 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
ws

View File

@ -1534,8 +1534,7 @@
end-prev-quarter
end-cal-year
end-prev-year
end-cur-fin-year
end-prev-fin-year
end-accounting-period
))))
(define (gnc:options-make-date-interval! options pagename name-from info-from
@ -1555,8 +1554,7 @@
start-prev-quarter
start-cal-year
start-prev-year
start-cur-fin-year
start-prev-fin-year
start-accounting-period
)))
(gnc:options-make-end-date! options pagename name-to
(string-append sort-tag "b") info-to))