AUDIT: r16909 - gnucash/trunk/src/import-export/qif-import - Bug#511006: Check the GnuCash file for the relevant commodity during QIF security import, rather than assuming it's there because it's in the map file, since the user might be importing against a different book. Patch from <cedayiv gmail com>.

Josh Sled jsled at cvs.gnucash.org
Thu Jan 31 19:47:10 EST 2008


Author: jsled
Date: 2008-01-31 19:47:10 -0500 (Thu, 31 Jan 2008)
New Revision: 16909
Trac: http://svn.gnucash.org/trac/changeset/16909

Modified:
   gnucash/trunk/src/import-export/qif-import/qif-guess-map.scm
Log:
Bug#511006: Check the GnuCash file for the relevant commodity during QIF security import, rather than assuming it's there because it's in the map file, since the user might be importing against a different book.  Patch from <cedayiv gmail com>.
BP


Modified: gnucash/trunk/src/import-export/qif-import/qif-guess-map.scm
===================================================================
--- gnucash/trunk/src/import-export/qif-import/qif-guess-map.scm	2008-02-01 00:46:16 UTC (rev 16908)
+++ gnucash/trunk/src/import-export/qif-import/qif-guess-map.scm	2008-02-01 00:47:10 UTC (rev 16909)
@@ -143,19 +143,29 @@
      tablist)
     table))
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-import:read-commodities
+;;
+;;  This procedure examines a list of previously seen commodities
+;;  and returns a hash table of them, if they still exist.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (define (qif-import:read-commodities commlist)
   (let ((table (make-hash-table 20)))
     (for-each 
      (lambda (entry)
        (if (and (list? entry) 
                 (= 3 (length entry)))
-           (let ((name (car entry))
-                 (namespace (cadr entry))
-                 (mnemonic (caddr entry)))
-             (hash-set! table name
-                        (gnc-commodity-table-lookup
-                         (gnc-commodity-table-get-table (gnc-get-current-book))
-                         namespace mnemonic)))))
+           ;; The saved information about each commodity is a
+           ;; list of three items: name, namespace, and mnemonic.
+           ;; Example: ("McDonald's" "NYSE" "MCD")
+           (let ((commodity (gnc-commodity-table-lookup
+                              (gnc-commodity-table-get-table
+                                (gnc-get-current-book))
+                              (cadr entry)
+                              (caddr entry))))
+             (if (and commodity (not (null? commodity)))
+                 ;; The commodity is defined in GnuCash.
+                 (hash-set! table (car entry) commodity)))))
      commlist)
     table))
                               



More information about the gnucash-changes mailing list