Skip to content

Commit

Permalink
Merge Frank Ellenberger's 'Bug684507' into maint.
Browse files Browse the repository at this point in the history
  • Loading branch information
jralls committed Mar 8, 2022
2 parents cde8f91 + 6f28d49 commit d841b32
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 111 deletions.
1 change: 0 additions & 1 deletion bindings/guile/CMakeLists.txt
Expand Up @@ -85,7 +85,6 @@ gnc_add_scheme_targets(scm-core-utils
DEPENDS "${GUILE_DEPENDS}")

set (engine_SCHEME_0
commodity-table.scm
gnc-numeric.scm
business-core.scm
)
Expand Down
44 changes: 0 additions & 44 deletions bindings/guile/commodity-table.scm

This file was deleted.

1 change: 0 additions & 1 deletion bindings/guile/engine.scm
Expand Up @@ -28,7 +28,6 @@

(load-and-reexport (sw_engine)
(gnucash engine business-core)
(gnucash engine commodity-table)
(gnucash engine gnc-numeric))

(export gnc-pricedb-lookup-latest-before-t64)
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/tests/test_commodity.py
Expand Up @@ -21,12 +21,12 @@ def test_namespaces(self):
#print(self.table.__class__)
namespace_names = self.table.get_namespaces()
#print(namespace_names)
self.assertEqual(namespace_names, ['AMEX', 'NYSE', 'NASDAQ', 'EUREX', 'FUND', '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, ['AMEX', 'NYSE', 'NASDAQ', 'EUREX', 'FUND', 'template', 'CURRENCY'])
self.assertEqual(namespace_names, ['All non-currency', 'template', 'CURRENCY'])

if __name__ == '__main__':
main()
2 changes: 2 additions & 0 deletions gnucash/gtkbuilder/dialog-commodity.glade
Expand Up @@ -305,6 +305,8 @@
<property name="model">liststore2</property>
<property name="has-entry">True</property>
<property name="entry-text-column">0</property>
<property name="has-tooltip">True</property>
<property name="tooltip-markup" translatable="yes">Select a category for the commodity or enter a new one. One might use investment categories like STOCKS and BONDS or exchange names like NASDAQ and LSE.</property>
<signal name="changed" handler="gnc_ui_commodity_changed_cb" swapped="no"/>
<child internal-child="entry">
<object class="GtkEntry" id="combobox-entry5">
Expand Down
49 changes: 10 additions & 39 deletions gnucash/import-export/qif-imp/qif-dialog-utils.scm
Expand Up @@ -736,58 +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 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)))
;; 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))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down
2 changes: 1 addition & 1 deletion gnucash/import-export/qif-imp/qif-to-gnc.scm
Expand Up @@ -270,7 +270,7 @@
(default-currency
(gnc-commodity-table-find-full
(gnc-commodity-table-get-table (gnc-get-current-book))
GNC_COMMODITY_NS_CURRENCY default-currency-name))
(GNC-COMMODITY-NS-CURRENCY) default-currency-name))
(sorted-accounts-list '())
(markable-xtns '())
(sorted-qif-files-list (sort qif-files-list
Expand Down
6 changes: 3 additions & 3 deletions libgnucash/app-utils/options.scm
Expand Up @@ -435,7 +435,7 @@ the option '~a'."))
(if (string? currency)
(gnc-commodity-table-lookup
(gnc-commodity-table-get-table (gnc-get-current-book))
GNC_COMMODITY_NS_CURRENCY currency)
(GNC-COMMODITY-NS-CURRENCY) currency)
currency))

(let* ((value (currency->scm default-value))
Expand Down Expand Up @@ -561,7 +561,7 @@ the option '~a'."))
(define (commodity->scm commodity)
(if (string? commodity)
(list 'commodity-scm
GNC_COMMODITY_NS_CURRENCY
(GNC-COMMODITY-NS-CURRENCY)
commodity)
(list 'commodity-scm
(gnc-commodity-get-namespace commodity)
Expand Down Expand Up @@ -1560,7 +1560,7 @@ the option '~a'."))
(if (string? currency-string)
(gnc-commodity-table-lookup
(gnc-commodity-table-get-table (gnc-get-current-book))
GNC_COMMODITY_NS_CURRENCY currency-string)
(GNC-COMMODITY-NS-CURRENCY) currency-string)
#f))

(define (currency? val)
Expand Down
6 changes: 1 addition & 5 deletions libgnucash/engine/gnc-commodity.c
Expand Up @@ -2510,11 +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_AMEX, book);
gnc_commodity_table_add_namespace(table, GNC_COMMODITY_NS_NYSE, book);
gnc_commodity_table_add_namespace(table, GNC_COMMODITY_NS_NASDAQ, book);
gnc_commodity_table_add_namespace(table, GNC_COMMODITY_NS_EUREX, book);
gnc_commodity_table_add_namespace(table, GNC_COMMODITY_NS_MUTUAL, 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);
Expand Down
20 changes: 6 additions & 14 deletions libgnucash/engine/gnc-commodity.h
Expand Up @@ -104,21 +104,13 @@ GType gnc_commodity_namespace_get_type(void);
* only used to populate an option menu in the commodity selection
* window.
*/
#define GNC_COMMODITY_NS_LEGACY "GNC_LEGACY_CURRENCIES"
#define GNC_COMMODITY_NS_TEMPLATE "template"
#define GNC_COMMODITY_NS_LEGACY "GNC_LEGACY_CURRENCIES"
#define GNC_COMMODITY_NS_TEMPLATE "template"
/* 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_NASDAQ "NASDAQ"
#define GNC_COMMODITY_NS_NYSE "NYSE"
#define GNC_COMMODITY_NS_EUREX "EUREX"
#define GNC_COMMODITY_NS_MUTUAL "FUND"
#define GNC_COMMODITY_NS_AMEX "AMEX"
#define GNC_COMMODITY_NS_ASX "ASX"
#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_ISO "ISO4217"
#define GNC_COMMODITY_NS_CURRENCY "CURRENCY"
#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.
Expand Down
1 change: 0 additions & 1 deletion po/POTFILES.in
@@ -1,7 +1,6 @@
# This is a list of files which contain translatable strings.
# This file was autogenerated by cmake.
bindings/guile/business-core.scm
bindings/guile/commodity-table.scm
bindings/guile/core-utils.scm
bindings/guile/engine.scm
bindings/guile/glib-guile.c
Expand Down

0 comments on commit d841b32

Please sign in to comment.