From a0168110484f801e8d757da55e7435c79c58ea7a Mon Sep 17 00:00:00 2001 From: Dave Peticolas Date: Thu, 8 Feb 2001 22:10:16 +0000 Subject: [PATCH] Christian Stimming's report patch. * src/scm/date-utilities.scm Added (gnc:timepair-previous-day). * src/scm/report-utilities.scm (gnc:account-get-balance-interval) Fix bug with start date. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3624 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 5 +++++ src/scm/date-utilities.scm | 3 +++ src/scm/html-utilities.scm | 4 ---- src/scm/report-utilities.scm | 19 ++++++++++++------- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index c40dc3b23d..76ae844fc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2001-02-08 Christian Stimming + * src/scm/date-utilities.scm Added (gnc:timepair-previous-day). + + * src/scm/report-utilities.scm (gnc:account-get-balance-interval) + Fix bug with start date. + * src/scm/html-style-info.scm: Fix bug. * src/scm/gnc-numeric.scm: Add more functions on gnc-monetary. diff --git a/src/scm/date-utilities.scm b/src/scm/date-utilities.scm index 3986b12ff2..4fe7c1cd49 100644 --- a/src/scm/date-utilities.scm +++ b/src/scm/date-utilities.scm @@ -297,6 +297,9 @@ (let ((newtime (car (mktime bdt)))) (cons newtime 0)))) +(define (gnc:timepair-previous-day tp) + (decdate tp DayDelta)) + (define (gnc:reldate-get-symbol x) (vector-ref x 0)) (define (gnc:reldate-get-string x) (vector-ref x 1)) (define (gnc:reldate-get-desc x) (vector-ref x 2)) diff --git a/src/scm/html-utilities.scm b/src/scm/html-utilities.scm index 5c8158dcea..299afc008c 100644 --- a/src/scm/html-utilities.scm +++ b/src/scm/html-utilities.scm @@ -58,10 +58,6 @@ ;; loss reports). Returns a commodity-collector. (define (my-get-balance account) (if start-date - ;; FIXME: the get-balance-interval function uses this date - ;; rightaway, but since it calculates a difference it should - ;; rather take the end-day-time of one day before that. This - ;; needs to be fixed in report-utilities.scm. (gnc:account-get-comm-balance-interval account start-date end-date do-subtot?) (gnc:account-get-comm-balance-at-date diff --git a/src/scm/report-utilities.scm b/src/scm/report-utilities.scm index 803274892e..c6f4de2d4e 100644 --- a/src/scm/report-utilities.scm +++ b/src/scm/report-utilities.scm @@ -500,20 +500,25 @@ ;; this isn't quite as efficient as it could be, but it's a whole lot ;; simpler :) (define (gnc:account-get-balance-interval account from to include-children?) - ;; FIXME: the get-balance-interval function uses this date - ;; rightaway, but since it calculates a difference it should - ;; rather take the end-day-time of one day before that. This - ;; needs to be fixed in report-utilities.scm. + ;; Since this function calculates a balance difference it has to + ;; subtract the balance of the previous day's end (from-date) + ;; instead of the plain date. (- (gnc:account-get-balance-at-date account to include-children?) - (gnc:account-get-balance-at-date account from include-children?))) + (gnc:account-get-balance-at-date + account + (gnc:timepair-end-day-time (gnc:timepair-previous-day from)) + include-children?))) ;; the version which returns a commodity-collector (define (gnc:account-get-comm-balance-interval account from to include-children?) (let ((this-collector (gnc:account-get-comm-balance-at-date account to include-children?))) - (this-collector 'minusmerge (gnc:account-get-comm-balance-at-date - account from include-children?) #f) + (this-collector + 'minusmerge (gnc:account-get-comm-balance-at-date + account + (gnc:timepair-end-day-time (gnc:timepair-previous-day from)) + include-children?) #f) this-collector)) (define (gnc:group-get-balance-interval group from to)