fixes for balance sheet in 1.6.0
Daniel Hagerty
Daniel Hagerty <hag@linnaean.org>
Fri, 22 Jun 2001 17:07:27 -0400
--WtC1EzJiBv
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Nice work on gnucash 1.6.0! It's nice to have a balance sheet
that balances (most of the time).
I got annoyed that the balance sheet only balances using weighted
average prices, so I generated the following patch that adds an
Unrealized Gain/Loss line item.
--WtC1EzJiBv
Content-Type: text/plain
Content-Disposition: inline;
filename="balance.patch"
Content-Transfer-Encoding: 7bit
# This is a patch for gnucash-1.6.0 to update it to gnucash-1.6.0.hacked
#
# To apply this patch:
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'applypatch' program with this patch file as input.
#
# If you do not have 'applypatch', it is part of the 'makepatch' package
# that you can fetch from the Comprehensive Perl Archive Network:
# http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz
# In the above URL, 'x' should be 2 or higher.
#
# To apply this patch without the use of 'applypatch':
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'patch' program with this file as input.
#
#### End of Preamble ####
#### Patch data follows ####
diff -upwB 'gnucash-1.6.0/src/scm/report/balance-sheet.scm' 'gnucash-1.6.0.hacked/src/scm/report/balance-sheet.scm'
Index: ./src/scm/report/balance-sheet.scm
--- ./src/scm/report/balance-sheet.scm Fri May 25 02:33:09 2001
+++ ./src/scm/report/balance-sheet.scm Fri Jun 22 17:03:30 2001
@@ -225,6 +225,7 @@
(retained-profit-balance (gnc:make-commodity-collector))
(total-equity-balance (gnc:make-commodity-collector))
(equity-plus-liability (gnc:make-commodity-collector))
+ (unrealized-gain-collector (gnc:make-commodity-collector))
;; Create the account tables here.
(asset-table
@@ -298,6 +300,36 @@
(add-subtotal-line
asset-table (_ "Liabilities") sign-reversed-liability-balance)
+ (let* ((weighted-fn
+ (gnc:case-exchange-fn 'weighted-average
+ report-currency to-date-tp))
+ (value-numeric
+ (gnc:gnc-monetary-amount
+ (gnc:sum-collector-commodity asset-balance
+ report-currency
+ exchange-fn)))
+ ;; XXX is it safe to assume a constant denom?
+ (denom (gnc:gnc-numeric-denom value-numeric))
+ (value (gnc:gnc-numeric-num value-numeric))
+ (cost-numeric
+ (gnc:gnc-monetary-amount
+ (gnc:sum-collector-commodity asset-balance
+ report-currency
+ weighted-fn)))
+ (cost (gnc:gnc-numeric-num cost-numeric))
+ (unrealized-gain (- value cost))
+ (unrealized-gain-numeric
+ (gnc:make-gnc-numeric unrealized-gain denom)))
+
+ (unrealized-gain-collector 'add report-currency
+ unrealized-gain-numeric)
+ (equity-plus-liability 'add report-currency
+ unrealized-gain-numeric)
+
+ (add-subtotal-line
+ asset-table (_ "Unrealized Gains(Losses)")
+ unrealized-gain-collector))
+
(gnc:html-table-append-ruler!
asset-table (* (if show-fcur? 3 2) tree-depth))
(add-subtotal-line
#### End of Patch data ####
#### ApplyPatch data follows ####
# Data version : 1.0
# Date generated : Fri Jun 22 17:04:54 2001
# Generated by : makepatch 2.00
# Recurse directories : Yes
# Excluded files : (\A|.*/)CVS(/.*|\Z)
# (\A|.*/)RCS(/.*|\Z)
# ,v\Z
# (\A|.*/)SCCS(/.*|\Z)
# (\A|.*/)[sp]\..+\Z
# p 'src/scm/report/balance-sheet.scm' 11807 993243810 0100644
#### End of ApplyPatch data ####
#### End of Patch kit [created: Fri Jun 22 17:04:54 2001] ####
#### Checksum: 83 3120 45960 ####
--WtC1EzJiBv--