Revert visible changes to File->Properties for Book Currency from master in order to do further work in feature branch.

This commit is contained in:
Alex Aycinena 2017-07-22 12:53:54 -07:00
parent 2ceaba371d
commit cb5e311a3f
5 changed files with 13 additions and 183 deletions

View File

@ -145,27 +145,10 @@
#f))
(reg-option
(gnc:make-currency-accounting-option
gnc:*option-section-accounts* gnc:*option-name-currency-accounting*
"c"
(N_ "Select the currency accounting method to use for transactions involving more than one currency or commodity.")
'neither
(list
(vector 'neither
(N_ "Use neither Trading Accounts nor a Book Currency")
(N_ "Check to use neither trading accounts nor a book-currency for transactions involving more than one currency or commodity."))
(vector 'trading
(N_ "Use Trading Accounts")
(N_ "Check to have trading accounts used for transactions involving more than one currency or commodity."))
(vector 'book-currency
(N_ "Use a Book Currency")
(N_ "Check to use a book-currency for transactions involving more than one currency or commodity.")))
(N_ "Select the book-currency which is to be used to track costs of transactions involving currencies or commodities other than the book-currency.")
(gnc-default-currency)
(N_ "Select the default gains policy; this policy will be used unless over-ridden at the account level.")
'fifo
(N_ "Select the default gains/loss account (income or expense account, in book-currency, neither placeholder nor hidden); this account will be used unless over-ridden at the account level. If one is not selected, an account will be created as needed."))
)
(gnc:make-simple-boolean-option
gnc:*option-section-accounts* gnc:*option-name-trading-accounts*
"a" (N_ "Check to have trading accounts used for transactions involving more than one currency or commodity.")
#f))
;; Budgeting Tab

View File

@ -74,20 +74,6 @@ setup_kvp (Fixture *fixture, gconstpointer pData)
qof_commit_edit (QOF_INSTANCE (book));
}
static void
setup_kvp_book_currency (Fixture *fixture, gconstpointer pData)
{
QofBook *book;
setup (fixture, pData);
book = fixture->book;
qof_begin_edit (QOF_INSTANCE (book));
qof_instance_set (QOF_INSTANCE (book),
"book-currency", "GTQ",
"default-gains-policy", "fifo",
NULL);
qof_commit_edit (QOF_INSTANCE (book));
}
static void
teardown (Fixture *fixture, gconstpointer pData)
{
@ -105,22 +91,7 @@ test_option_load (Fixture *fixture, gconstpointer pData)
GNCOptionDB *odb = gnc_option_db_new_for_type (QOF_ID_BOOK);
qof_book_load_options (book, gnc_option_db_load, odb);
symbol_value = gnc_currency_accounting_option_value_get_method (
gnc_option_db_lookup_option (odb,
OPTION_SECTION_ACCOUNTS,
OPTION_NAME_CURRENCY_ACCOUNTING,
SCM_BOOL_F));
if (scm_is_symbol(symbol_value))
{
SCM string_value = scm_symbol_to_string (symbol_value);
if (scm_is_string (string_value))
{
str = scm_to_utf8_string (string_value);
}
}
g_assert_cmpstr (str, ==, "trading");
if (str)
g_free (str);
g_assert (gnc_option_db_lookup_boolean_option (odb, OPTION_SECTION_ACCOUNTS, OPTION_NAME_TRADING_ACCOUNTS, FALSE));
g_assert (gnc_option_db_lookup_boolean_option (odb,
OPTION_SECTION_ACCOUNTS,
OPTION_NAME_NUM_FIELD_SOURCE, FALSE));
@ -130,92 +101,6 @@ test_option_load (Fixture *fixture, gconstpointer pData)
gnc_option_db_destroy (odb);
}
static void
test_option_load_book_currency (Fixture *fixture, gconstpointer pData)
{
gchar *str = NULL;
SCM symbol_value;
const gchar *curr = NULL;
SCM curr_scm;
/* SCM acct_guid_scm = NULL; */
gnc_commodity *commodity;
QofBook *book = fixture->book;
GNCOptionDB *odb = gnc_option_db_new_for_type (QOF_ID_BOOK);
/* Account *acct, *acc;
qof_book_begin_edit (book);
acc = get_random_account( book );
qof_instance_set (QOF_INSTANCE (book),
"default-gain-loss-account-guid", qof_entity_get_guid(QOF_INSTANCE(acc)),
NULL);
qof_book_commit_edit (book); */
qof_book_load_options (book, gnc_option_db_load, odb);
symbol_value = gnc_currency_accounting_option_value_get_method (
gnc_option_db_lookup_option (odb,
OPTION_SECTION_ACCOUNTS,
OPTION_NAME_CURRENCY_ACCOUNTING,
SCM_BOOL_F));
if (scm_is_symbol(symbol_value))
{
SCM string_value = scm_symbol_to_string (symbol_value);
if (scm_is_string (string_value))
{
str = scm_to_utf8_string (string_value);
}
}
g_assert_cmpstr (str, ==, "book-currency");
if (str)
g_free (str);
/* acct_guid_scm = gnc_currency_accounting_option_value_get_default_account (
gnc_option_db_lookup_option (odb,
OPTION_SECTION_ACCOUNTS,
OPTION_NAME_CURRENCY_ACCOUNTING,
SCM_BOOL_F));
if (acct_guid_scm && (scm_is_string(acct_guid_scm)))
{
GncGUID *guid = g_new (GncGUID, 1);
str = scm_to_utf8_string (acct_guid_scm);
if (string_to_guid (str, guid))
acct = xaccAccountLookup( guid, book );
g_free (guid);
}
g_assert ( xaccAccountEqual(acct, acc, TRUE) );
if (str)
g_free (str); */
symbol_value = gnc_currency_accounting_option_value_get_default_policy (
gnc_option_db_lookup_option (odb,
OPTION_SECTION_ACCOUNTS,
OPTION_NAME_CURRENCY_ACCOUNTING,
SCM_BOOL_F));
if (scm_is_symbol(symbol_value))
{
SCM string_value = scm_symbol_to_string (symbol_value);
if (scm_is_string (string_value))
{
str = scm_to_utf8_string (string_value);
}
}
g_assert_cmpstr (str, ==, "fifo");
if (str)
g_free (str);
curr_scm = gnc_currency_accounting_option_value_get_book_currency(
gnc_option_db_lookup_option(odb,
OPTION_SECTION_ACCOUNTS,
OPTION_NAME_CURRENCY_ACCOUNTING,
SCM_BOOL_F));
commodity = gnc_scm_to_commodity (curr_scm);
if (commodity)
{
curr = gnc_commodity_get_mnemonic (commodity);
}
g_assert_cmpstr (curr, ==, "GTQ");
gnc_option_db_destroy (odb);
}
static void
test_option_save (Fixture *fixture, gconstpointer pData)
{
@ -223,9 +108,9 @@ test_option_save (Fixture *fixture, gconstpointer pData)
GNCOptionDB *odb = gnc_option_db_new_for_type (QOF_ID_BOOK);
KvpFrame *slots = qof_instance_get_slots (QOF_INSTANCE (book));
g_assert (gnc_option_db_set_option (odb, OPTION_SECTION_ACCOUNTS,
OPTION_NAME_CURRENCY_ACCOUNTING,
scm_cons (scm_from_locale_symbol("trading"), SCM_EOL)));
g_assert (gnc_option_db_set_boolean_option (odb, OPTION_SECTION_ACCOUNTS,
OPTION_NAME_TRADING_ACCOUNTS,
TRUE));
g_assert (gnc_option_db_set_boolean_option (odb, OPTION_SECTION_ACCOUNTS,
OPTION_NAME_NUM_FIELD_SOURCE,
TRUE));
@ -243,47 +128,9 @@ test_option_save (Fixture *fixture, gconstpointer pData)
gnc_option_db_destroy (odb);
}
static void
test_option_save_book_currency (Fixture *fixture, gconstpointer pData)
{
QofBook *book = fixture->book;
GNCOptionDB *odb = gnc_option_db_new_for_type (QOF_ID_BOOK);
KvpFrame *slots = qof_instance_get_slots (QOF_INSTANCE (book));
Account *acct, *acc;
gchar *gain_loss_account_guid_str = NULL;
gchar *gain_loss_account_guid_str2 = NULL;
GncGUID *gain_loss_account_guid;
SCM val = NULL;
acc = get_random_account( book );
gain_loss_account_guid_str = guid_to_string (xaccAccountGetGUID (acc));
val = scm_from_utf8_string (gain_loss_account_guid_str);
/* g_assert (gnc_option_db_set_option (odb, OPTION_SECTION_ACCOUNTS,
OPTION_NAME_CURRENCY_ACCOUNTING,
scm_cons (scm_from_locale_symbol("book-currency"),
scm_cons (scm_from_utf8_string("GTQ"),
scm_cons (scm_from_locale_symbol("fifo"),
scm_cons (val, SCM_EOL))))));
qof_book_save_options (book, gnc_option_db_save, odb, TRUE);
g_assert_cmpstr (slots->get_slot("options/Accounts/Book Currency")->get<const char*>(), == , "GTQ");
g_assert_cmpstr (slots->get_slot("options/Accounts/Default Gains Policy")->get<const char*>(), == , "fifo");
gain_loss_account_guid =
slots->get_slot("options/Accounts/Default Gain or Loss Account")->get<GncGUID*>();
gain_loss_account_guid_str2 = guid_to_string (gain_loss_account_guid);
g_assert_cmpstr (gain_loss_account_guid_str2, == , gain_loss_account_guid_str);
if (gain_loss_account_guid_str)
g_free (gain_loss_account_guid_str);
if (gain_loss_account_guid_str2)
g_free (gain_loss_account_guid_str2); */
gnc_option_db_destroy (odb);
}
extern "C" void
test_suite_option_util (void)
{
GNC_TEST_ADD (suitename, "Option DB Load", Fixture, NULL, setup_kvp, test_option_load, teardown);
GNC_TEST_ADD (suitename, "Option DB Load - Book Currency", Fixture, NULL, setup_kvp_book_currency, test_option_load_book_currency, teardown);
GNC_TEST_ADD (suitename, "Option DB Save", Fixture, NULL, setup, test_option_save, teardown);
GNC_TEST_ADD (suitename, "Option DB Save - Book Currency", Fixture, NULL, setup, test_option_save_book_currency, teardown);
}

View File

@ -2100,7 +2100,7 @@ refresh_handler (GHashTable *changes, gpointer user_data)
/* The default_gain_loss_account_widget needs to be refreshed if any
changes have been made via account maintenance, if it exists and
if the book currency widget has a selection */
if (book_currency_data->default_gain_loss_account_widget &&
/* if (book_currency_data->default_gain_loss_account_widget &&
gtk_combo_box_get_active_iter(
GTK_COMBO_BOX(book_currency_data->book_currency_widget), &iter))
{
@ -2109,7 +2109,7 @@ refresh_handler (GHashTable *changes, gpointer user_data)
book_currency_data->book_currency_widget));
gnc_set_default_gain_loss_account_widget(commodity);
gtk_widget_show_all(book_currency_data->book_currency_vbox);
}
} */
}
/* gnc_options_dialog_new:

View File

@ -6,7 +6,7 @@
<property name="can_focus">False</property>
<property name="title" translatable="yes">GnuCash Options</property>
<property name="default_width">400</property>
<property name="default_height">625</property>
<property name="default_height">400</property>
<property name="type_hint">dialog</property>
<signal name="response" handler="gnc_options_dialog_response_cb" swapped="no"/>
<child internal-child="vbox">

View File

@ -6,7 +6,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">12</property>
<property name="default_height">800</property>
<property name="default_height">550</property>
<signal name="cancel" handler="on_cancel" swapped="no"/>
<signal name="close" handler="on_finish" swapped="no"/>
<signal name="prepare" handler="on_prepare" swapped="no"/>