mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Remove investment-type namespaces.
Leave it to users to categorize their non-currency commodities. In the QIF importer default non-classifiable commodities to GNC_COMMODITY_NS_NONCURRENCY.
This commit is contained in:
parent
09296dfb96
commit
9ad24321b4
@ -21,12 +21,12 @@ class TestCommodityNamespace(CommoditySession):
|
||||
#print(self.table.__class__)
|
||||
namespace_names = self.table.get_namespaces()
|
||||
#print(namespace_names)
|
||||
self.assertEqual(namespace_names, ['BOND', 'SHARE', 'FUND', 'OPTION', 'template', 'CURRENCY'])
|
||||
self.assertEqual(namespace_names, ['All non-currency', 'template', 'CURRENCY'])
|
||||
|
||||
def test_namespaces_list(self):
|
||||
namespaces = self.table.get_namespaces_list()
|
||||
namespace_names = [ns.get_name() for ns in namespaces]
|
||||
self.assertEqual(namespace_names, ['BOND', 'SHARE', 'FUND', 'OPTION', 'template', 'CURRENCY'])
|
||||
self.assertEqual(namespace_names, ['All non-currency', 'template', 'CURRENCY'])
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -736,46 +736,29 @@
|
||||
;; compatible with the QIF type?
|
||||
(and (string=? s (caddr elt))
|
||||
(not (and (string? qif-type)
|
||||
(string=? (GNC-COMMODITY-NS-MUTUAL)
|
||||
(string=? (GNC-COMMODITY-NS-NONCURRENCY)
|
||||
(cadr elt))
|
||||
(or (string-ci=? qif-type "stock")
|
||||
(string-ci=? qif-type "etf"))))))
|
||||
prefs)
|
||||
#f)))
|
||||
(cond
|
||||
;; If a preferences match was found, use its namespace.
|
||||
(pref-match
|
||||
(cadr pref-match))
|
||||
|
||||
;; Guess SHARE for symbols of 1-4 characters.
|
||||
((<= l 4)
|
||||
(GNC-COMMODITY-NS-SHARE))
|
||||
|
||||
;; Otherwise it's probably a fund.
|
||||
(else
|
||||
(GNC-COMMODITY-NS-MUTUAL))))
|
||||
;; If a preferences match was found, use its namespace.
|
||||
(if pref-match (cadr pref-match))
|
||||
;; There's no symbol. Default to a fund.
|
||||
(GNC-COMMODITY-NS-MUTUAL)))
|
||||
(GNC-COMMODITY-NS-NONCURRENCY))))
|
||||
|
||||
;; Was a QIF type given?
|
||||
(if (string? qif-type)
|
||||
;; Yes. We might be able to definitely determine the namespace.
|
||||
(cond
|
||||
;; Mutual fund
|
||||
((string-ci=? qif-type "mutual fund")
|
||||
(GNC-COMMODITY-NS-MUTUAL))
|
||||
|
||||
;; Index
|
||||
((string-ci=? qif-type "index")
|
||||
;; This QIF type must be wrong; indexes aren't tradable!
|
||||
(GNC-COMMODITY-NS-MUTUAL))
|
||||
|
||||
(else
|
||||
(guess-by-symbol qif-symbol)))
|
||||
(if (or
|
||||
(string-ci=? qif-type "mutual fund")
|
||||
(string-ci=? qif-type "index"))
|
||||
(GNC-COMMODITY-NS-NONCURRENCY)
|
||||
(guess-by-symbol qif-symbol)))
|
||||
|
||||
;; No QIF type was given, so guess a
|
||||
;; default namespace by symbol alone.
|
||||
(guess-by-symbol qif-symbol)))
|
||||
(guess-by-symbol qif-symbol))
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
@ -2510,10 +2510,7 @@ gnc_commodity_table_add_default_data(gnc_commodity_table *table, QofBook *book)
|
||||
gnc_commodity* c;
|
||||
|
||||
ENTER ("table=%p", table);
|
||||
gnc_commodity_table_add_namespace(table, GNC_COMMODITY_NS_BOND, book);
|
||||
gnc_commodity_table_add_namespace(table, GNC_COMMODITY_NS_SHARE, book);
|
||||
gnc_commodity_table_add_namespace(table, GNC_COMMODITY_NS_MUTUAL, book);
|
||||
gnc_commodity_table_add_namespace(table, GNC_COMMODITY_NS_OPTION, book);
|
||||
gnc_commodity_table_add_namespace(table, GNC_COMMODITY_NS_NONCURRENCY, book);
|
||||
gnc_commodity_table_add_namespace(table, GNC_COMMODITY_NS_TEMPLATE, book);
|
||||
c = gnc_commodity_new(book, "template", GNC_COMMODITY_NS_TEMPLATE, "template", "template", 1);
|
||||
gnc_commodity_table_insert(table, c);
|
||||
|
@ -109,14 +109,8 @@ GType gnc_commodity_namespace_get_type(void);
|
||||
/* The ISO define is deprecated in favor of CURRENCY */
|
||||
#define GNC_COMMODITY_NS_ISO "ISO4217"
|
||||
#define GNC_COMMODITY_NS_CURRENCY "CURRENCY"
|
||||
#define GNC_COMMODITY_NS_BOND N_("BOND")
|
||||
#define GNC_COMMODITY_NS_SHARE N_("SHARE")
|
||||
#define GNC_COMMODITY_NS_MUTUAL N_("FUND")
|
||||
#define GNC_COMMODITY_NS_OPTION N_("OPTION")
|
||||
#define GNC_COMMODITY_NS_NONCURRENCY _("All non-currency")
|
||||
/* Delay translation of this one, we use it in both translated and untranslated form
|
||||
when presenting the currency related namespace to the user */
|
||||
#define GNC_COMMODITY_NS_ISO_GUI N_("Currencies")
|
||||
#define GNC_COMMODITY_NS_NONCURRENCY NC_("Commodity Type", "All non-currency")
|
||||
#define GNC_COMMODITY_NS_ISO_GUI NC_("Commodity Type", "Currencies")
|
||||
|
||||
/** Max fraction is 10^9 because 10^10 would require changing it to an
|
||||
* int64_t.
|
||||
|
Loading…
Reference in New Issue
Block a user