r16894 - gnucash/branches/2.2/src/import-export/qif-import - [r16874] Fix the rounding of security transactions in the QIF Importer (#373584).
Andreas Köhler
andi5 at cvs.gnucash.org
Wed Jan 30 15:24:58 EST 2008
Author: andi5
Date: 2008-01-30 15:24:58 -0500 (Wed, 30 Jan 2008)
New Revision: 16894
Trac: http://svn.gnucash.org/trac/changeset/16894
Modified:
gnucash/branches/2.2/src/import-export/qif-import/qif-to-gnc.scm
Log:
[r16874] Fix the rounding of security transactions in the QIF Importer (#373584).
The QIF file does not provide the total amount paid for the
shares. What appears in the "T" line is the price paid for the
shares *plus* commission ("O" line, if any).
Patch by Charles Day.
Modified: gnucash/branches/2.2/src/import-export/qif-import/qif-to-gnc.scm
===================================================================
--- gnucash/branches/2.2/src/import-export/qif-import/qif-to-gnc.scm 2008-01-30 20:24:48 UTC (rev 16893)
+++ gnucash/branches/2.2/src/import-export/qif-import/qif-to-gnc.scm 2008-01-30 20:24:58 UTC (rev 16894)
@@ -542,8 +542,32 @@
(gnc-far-split (xaccMallocSplit (gnc-get-current-book))))
(if (not num-shares) (set! num-shares (gnc-numeric-zero)))
- (if (not share-price) (set! share-price (gnc-numeric-zero)))
- (if (not split-amt) (set! split-amt (n* num-shares share-price)))
+
+ ;; Determine the extended price of all shares without commission.
+ (if xtn-amt
+ ;; Adjust for commission (if any).
+ (if commission-amt
+ (case qif-action
+ ((sell sellx shrsout)
+ (set! split-amt (n+ xtn-amt commission-amt)))
+ (else
+ (set! split-amt (nsub xtn-amt commission-amt))))
+ (set! split-amt xtn-amt))
+ ;; There's no grand total available.
+ (if share-price
+ ;; Use the given share price, despite possible rounding.
+ (set! split-amt (n* num-shares share-price))
+ (set! split-amt (gnc-numeric-zero))))
+
+ ;; Determine the share price.
+ (if (not share-price)
+ (set! share-price (gnc-numeric-zero))
+ (if (and xtn-amt (not (gnc-numeric-zero-p num-shares)))
+ ;; There's a share price but it could be imprecise
+ ;; enough to cause rounding. We can compute a better
+ ;; share price ourselves. For more information, see
+ ;; bug 373584.
+ (set! share-price (n/ split-amt num-shares))))
;; I don't think this should ever happen, but I want
;; to keep this check just in case.
More information about the gnucash-changes
mailing list