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


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16909 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Joshua Sled
2008-02-01 00:47:10 +00:00
parent c2b0a2844a
commit 324838c694

View File

@@ -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))