From 324838c6946f4e28a287a57018e2c8fe4783ac02 Mon Sep 17 00:00:00 2001 From: Joshua Sled Date: Fri, 1 Feb 2008 00:47:10 +0000 Subject: [PATCH] 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 . BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16909 57a11ea4-9604-0410-9ed3-97b8803252fd --- .../qif-import/qif-guess-map.scm | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/import-export/qif-import/qif-guess-map.scm b/src/import-export/qif-import/qif-guess-map.scm index 95c97d8116..aa8fe8c521 100644 --- a/src/import-export/qif-import/qif-guess-map.scm +++ b/src/import-export/qif-import/qif-guess-map.scm @@ -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))