[Gnucash-changes] r13266 - gnucash/trunk/src/report - Changed
balance calculations in three reports from using local
Chris Shoemaker
chris at cvs.gnucash.org
Tue Feb 14 20:52:16 EST 2006
Author: chris
Date: 2006-02-14 20:52:15 -0500 (Tue, 14 Feb 2006)
New Revision: 13266
Trac: http://svn.gnucash.org/trac/changeset/13266
Modified:
gnucash/trunk/src/report/report-system/report-system.scm
gnucash/trunk/src/report/report-system/report-utilities.scm
gnucash/trunk/src/report/standard-reports/balance-sheet.scm
gnucash/trunk/src/report/standard-reports/equity-statement.scm
gnucash/trunk/src/report/standard-reports/income-statement.scm
Log:
Changed balance calculations in three reports from using local
copies of buggy accountlist-get-comm-balance-at-date to using a new
gnc:accountlist-get-comm-balance-interval provided by
report-utilities.scm. For the affected calculations, the balances no
longer exclude transactions on the first day of the reporting period.
This fixes http://bugzilla.gnome.org/show_bug.cgi?id=331005.
Changed calculations:
Income Statement: Total Expenses, Total Revenues
Balance Sheet: Retained Earnings (*)
Equity Statement: Retained Earnings (*), Net Income
(*) The Retained Earning calculations use a start-date of "forever-ago"
so they are not affected, but still converted to the new function.
Modified: gnucash/trunk/src/report/report-system/report-system.scm
===================================================================
--- gnucash/trunk/src/report/report-system/report-system.scm 2006-02-15 01:33:07 UTC (rev 13265)
+++ gnucash/trunk/src/report/report-system/report-system.scm 2006-02-15 01:52:15 UTC (rev 13266)
@@ -583,6 +583,7 @@
(export gnc:account-get-balance-interval)
(export gnc:account-get-comm-balance-interval)
(export gnc:group-get-comm-balance-interval)
+(export gnc:accountlist-get-comm-balance-interval)
(export gnc:query-set-match-non-voids-only!)
(export gnc:query-set-match-voids-only!)
(export gnc:split-voided?)
Modified: gnucash/trunk/src/report/report-system/report-utilities.scm
===================================================================
--- gnucash/trunk/src/report/report-system/report-utilities.scm 2006-02-15 01:33:07 UTC (rev 13265)
+++ gnucash/trunk/src/report/report-system/report-utilities.scm 2006-02-15 01:52:15 UTC (rev 13266)
@@ -644,6 +644,18 @@
account from to #t)) group))
this-collector))
+;; This calculates the increase in the balance(s) of all accounts in
+;; <accountlist> over the period from <from-date> to <to-date>.
+;; Returns a commodity collector.
+(define (gnc:accountlist-get-comm-balance-interval accountlist from to)
+ (let ((collector (gnc:make-commodity-collector)))
+ (for-each (lambda (account)
+ (gnc:commodity-collector-merge
+ collector (gnc:account-get-comm-balance-interval
+ account from to #f)))
+ accountlist)
+ collector))
+
;; utility function - ensure that a query matches only non-voids. Destructive.
(define (gnc:query-set-match-non-voids-only! query book)
(let ((temp-query (gnc:malloc-query)))
Modified: gnucash/trunk/src/report/standard-reports/balance-sheet.scm
===================================================================
--- gnucash/trunk/src/report/standard-reports/balance-sheet.scm 2006-02-15 01:33:07 UTC (rev 13265)
+++ gnucash/trunk/src/report/standard-reports/balance-sheet.scm 2006-02-15 01:52:15 UTC (rev 13266)
@@ -147,45 +147,6 @@
(define optname-show-rates (N_ "Show Exchange Rates"))
(define opthelp-show-rates (N_ "Show the exchange rates used"))
-;; This calculates the increase in the balance(s) of all accounts in
-;; <accountlist> over the period from <from-date> to <to-date>.
-;; Returns a commodity collector.
-;;
-;; Note: There is both a gnc:account-get-comm-balance-interval and
-;; gnc:group-get-comm-balance-interval which could replace this
-;; function....
-;;
-(define (accountlist-get-comm-balance-at-date accountlist from-date to-date)
-;; (for-each (lambda (x) (display x))
-;; (list "computing from: " (gnc:print-date from-date) " to "
-;; (gnc:print-date to-date) "\n"))
- (let ((collector (gnc:make-commodity-collector)))
- (for-each (lambda (account)
- (let* (
- (start-balance
- (gnc:account-get-comm-balance-at-date
- account from-date #f))
- (sb (cadr (start-balance
- 'getpair
- (gnc:account-get-commodity account)
- #f)))
- (end-balance
- (gnc:account-get-comm-balance-at-date
- account to-date #f))
- (eb (cadr (end-balance
- 'getpair
- (gnc:account-get-commodity account)
- #f)))
- )
-;; (for-each (lambda (x) (display x))
-;; (list "Start balance: " sb " : "
-;; (gnc:account-get-name account) " : end balance: "
-;; eb "\n"))
- (collector 'merge end-balance #f)
- (collector 'minusmerge start-balance #f)
- ))
- accountlist)
- collector))
;; options generator
(define (balance-sheet-options-generator)
@@ -556,7 +517,7 @@
(gnc:report-percent-done 12)
;; sum any retained earnings
(set! neg-retained-earnings
- (accountlist-get-comm-balance-at-date
+ (gnc:accountlist-get-comm-balance-interval
income-expense-accounts
forever-ago date-tp))
(set! retained-earnings (gnc:make-commodity-collector))
Modified: gnucash/trunk/src/report/standard-reports/equity-statement.scm
===================================================================
--- gnucash/trunk/src/report/standard-reports/equity-statement.scm 2006-02-15 01:33:07 UTC (rev 13265)
+++ gnucash/trunk/src/report/standard-reports/equity-statement.scm 2006-02-15 01:52:15 UTC (rev 13266)
@@ -101,46 +101,6 @@
(define opthelp-closing-regexp
(N_ "Causes the Closing Entries Pattern to be treated as a regular expression"))
-;; This calculates the increase in the balance(s) of all accounts in
-;; <accountlist> over the period from <start-date> to <end-date>.
-;; Returns a commodity collector.
-;;
-;; Note: There is both a gnc:account-get-comm-balance-interval and
-;; gnc:group-get-comm-balance-interval which could replace this
-;; function....
-;;
-(define (accountlist-get-comm-balance-at-date accountlist start-date end-date)
-;; (for-each (lambda (x) (display x))
-;; (list "computing from: " (gnc:print-date start-date) " to "
-;; (gnc:print-date end-date) "\n"))
- (let ((collector (gnc:make-commodity-collector)))
- (for-each (lambda (account)
- (let* (
- (start-balance
- (gnc:account-get-comm-balance-at-date
- account start-date #f))
- (sb (cadr (start-balance
- 'getpair
- (gnc:account-get-commodity account)
- #f)))
- (end-balance
- (gnc:account-get-comm-balance-at-date
- account end-date #f))
- (eb (cadr (end-balance
- 'getpair
- (gnc:account-get-commodity account)
- #f)))
- )
-;; (for-each (lambda (x) (display x))
-;; (list "Start balance: " sb " : "
-;; (gnc:account-get-name account) " : end balance: "
-;; eb "\n"))
- (collector 'merge end-balance #f)
- (collector 'minusmerge start-balance #f)
- ))
- accountlist)
- collector))
-
;; options generator
(define (equity-statement-options-generator)
(let* ((options (gnc:new-options))
@@ -484,11 +444,11 @@
;; start and end retained earnings (income - expenses)
(set! neg-pre-start-retained-earnings
- (accountlist-get-comm-balance-at-date
+ (gnc:accountlist-get-comm-balance-interval
income-expense-accounts
forever-ago start-date-tp)) ; OK
(set! neg-pre-end-retained-earnings
- (accountlist-get-comm-balance-at-date
+ (gnc:accountlist-get-comm-balance-interval
income-expense-accounts
forever-ago end-date-tp)) ; OK
;; neg-pre-end-retained-earnings is not used to calculate
@@ -503,7 +463,7 @@
)
;; find retained earnings for the period
(set! neg-net-income
- (accountlist-get-comm-balance-at-date
+ (gnc:accountlist-get-comm-balance-interval
income-expense-accounts
start-date-tp end-date-tp)) ; OK
;; revert the income/expense to its pre-closing balance
Modified: gnucash/trunk/src/report/standard-reports/income-statement.scm
===================================================================
--- gnucash/trunk/src/report/standard-reports/income-statement.scm 2006-02-15 01:33:07 UTC (rev 13265)
+++ gnucash/trunk/src/report/standard-reports/income-statement.scm 2006-02-15 01:52:15 UTC (rev 13266)
@@ -132,46 +132,6 @@
(define opthelp-closing-regexp
(N_ "Causes the Closing Entries Pattern to be treated as a regular expression"))
-;; This calculates the increase in the balance(s) of all accounts in
-;; <accountlist> over the period from <from-date> to <to-date>.
-;; Returns a commodity collector.
-;;
-;; Note: There is both a gnc:account-get-comm-balance-interval and
-;; gnc:group-get-comm-balance-interval which could replace this
-;; function....
-;;
-(define (accountlist-get-comm-balance-at-date accountlist from-date to-date)
-;; (for-each (lambda (x) (display x))
-;; (list "computing from: " (gnc:print-date from-date) " to "
-;; (gnc:print-date to-date) "\n"))
- (let ((collector (gnc:make-commodity-collector)))
- (for-each (lambda (account)
- (let* (
- (start-balance
- (gnc:account-get-comm-balance-at-date
- account from-date #f))
- (sb (cadr (start-balance
- 'getpair
- (gnc:account-get-commodity account)
- #f)))
- (end-balance
- (gnc:account-get-comm-balance-at-date
- account to-date #f))
- (eb (cadr (end-balance
- 'getpair
- (gnc:account-get-commodity account)
- #f)))
- )
-;; (for-each (lambda (x) (display x))
-;; (list "Start balance: " sb " : "
-;; (gnc:account-get-name account) " : end balance: "
-;; eb "\n"))
- (collector 'merge end-balance #f)
- (collector 'minusmerge start-balance #f)
- ))
- accountlist)
- collector))
-
;; options generator
(define (income-statement-options-generator)
(let* ((options (gnc:new-options))
@@ -557,12 +517,12 @@
start-date-tp end-date-tp)
) ;; this is norm negative (credit)
(set! expense-total
- (accountlist-get-comm-balance-at-date
+ (gnc:accountlist-get-comm-balance-interval
expense-accounts
start-date-tp end-date-tp))
(expense-total 'minusmerge expense-closing #f)
(set! neg-revenue-total
- (accountlist-get-comm-balance-at-date
+ (gnc:accountlist-get-comm-balance-interval
revenue-accounts
start-date-tp end-date-tp))
(neg-revenue-total 'minusmerge revenue-closing #f)
More information about the gnucash-changes
mailing list