diff --git a/ChangeLog b/ChangeLog index 055d392250..fe4a2535f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,9 @@ * src/gnome-utils/exchange-dialog.glade -- New dialog to deal with exchanges from "within the register", but here because it is relatively generic. + + * src/register/ledger-core/split-register-load.c -- set the txn + currency based on the currency of the "default account" 2002-11-24 David Hampton diff --git a/src/register/ledger-core/split-register-load.c b/src/register/ledger-core/split-register-load.c index 79ccf249c9..4ed018b963 100644 --- a/src/register/ledger-core/split-register-load.c +++ b/src/register/ledger-core/split-register-load.c @@ -175,13 +175,28 @@ gnc_split_register_load (SplitRegister *reg, GList * slist, if (blank_split == NULL) { Transaction *trans; + gnc_commodity * currency = NULL; + + /* Determine the proper currency to use for this transaction. + * if default_account != NULL and default_account->commodity is + * a currency, then use that. Otherwise use the default currency. + */ + if (default_account != NULL) { + gnc_commodity * commodity = xaccAccountGetCommodity (default_account); + if (commodity) { + const char * namespace = gnc_commodity_get_namespace (commodity); + if (!safe_strcmp (namespace, GNC_COMMODITY_NS_ISO) || + !safe_strcmp (namespace, GNC_COMMODITY_NS_LEGACY)) + currency = commodity; + } + } gnc_suspend_gui_refresh (); trans = xaccMallocTransaction (gnc_get_current_book ()); xaccTransBeginEdit (trans); - xaccTransSetCurrency (trans, gnc_default_currency ()); /* is this lame? */ + xaccTransSetCurrency (trans, currency ? currency : gnc_default_currency ()); xaccTransSetDateSecs (trans, info->last_date_entered); blank_split = xaccMallocSplit (gnc_get_current_book ()); xaccTransAppendSplit (trans, blank_split);