mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
For bug 123312: This QIF importer patch provides a somewhat smarter default
namespace for the commodities druid pages if a ticker symbol is included in the QIF data: -NYSE for symbols of 1-3 characters with an optional .X or .XX suffix -NASDAQ for symbols of 4 characters -FUND for symbols of 5 or more characters BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16950 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
f7ece28796
commit
7644d8fd2e
@ -577,6 +577,38 @@
|
|||||||
fullname)))
|
fullname)))
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; qif-dialog:default-namespace
|
||||||
|
;;
|
||||||
|
;; For a given commodity symbol, return a default namespace.
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
(define (qif-dialog:default-namespace s)
|
||||||
|
(if (string? s)
|
||||||
|
(let ((l (string-length s))
|
||||||
|
(d (string-index s #\.)))
|
||||||
|
(cond
|
||||||
|
;; Guess NYSE for symbols of 1-3 characters.
|
||||||
|
((< l 4)
|
||||||
|
GNC_COMMODITY_NS_NYSE)
|
||||||
|
|
||||||
|
;; Guess NYSE for symbols of 1-3 characters
|
||||||
|
;; followed by a dot and 1-2 characters.
|
||||||
|
((and d
|
||||||
|
(< l 7)
|
||||||
|
(< 0 d 4)
|
||||||
|
(<= 2 (- l d) 3))
|
||||||
|
GNC_COMMODITY_NS_NYSE)
|
||||||
|
|
||||||
|
;; Guess NASDAQ for symbols of 4 characters.
|
||||||
|
((= l 4)
|
||||||
|
GNC_COMMODITY_NS_NASDAQ)
|
||||||
|
|
||||||
|
;; Otherwise it's probably a fund.
|
||||||
|
(else
|
||||||
|
GNC_COMMODITY_NS_MUTUAL)))
|
||||||
|
GNC_COMMODITY_NS_MUTUAL))
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; qif-import:update-stock-hash
|
;; qif-import:update-stock-hash
|
||||||
;;
|
;;
|
||||||
@ -619,15 +651,21 @@
|
|||||||
|
|
||||||
;; we know nothing about this security.. we need to
|
;; we know nothing about this security.. we need to
|
||||||
;; ask about it
|
;; ask about it
|
||||||
(let ((ticker-symbol (qif-ticker-map:lookup-ticker ticker-map stock-name)))
|
(let ((ticker-symbol
|
||||||
|
(qif-ticker-map:lookup-ticker ticker-map
|
||||||
|
stock-name))
|
||||||
|
(namespace GNC_COMMODITY_NS_MUTUAL))
|
||||||
|
|
||||||
(if (not ticker-symbol)
|
(if (not ticker-symbol)
|
||||||
(set! ticker-symbol stock-name))
|
(set! ticker-symbol stock-name)
|
||||||
|
(set! namespace
|
||||||
|
(qif-dialog:default-namespace ticker-symbol)))
|
||||||
(set! names (cons stock-name names))
|
(set! names (cons stock-name names))
|
||||||
(hash-set!
|
(hash-set!
|
||||||
stock-hash stock-name
|
stock-hash stock-name
|
||||||
(gnc-commodity-new book
|
(gnc-commodity-new book
|
||||||
stock-name
|
stock-name
|
||||||
GNC_COMMODITY_NS_NYSE
|
namespace
|
||||||
ticker-symbol
|
ticker-symbol
|
||||||
""
|
""
|
||||||
100000))))))
|
100000))))))
|
||||||
|
Loading…
Reference in New Issue
Block a user