From 944fe15782fd8c02e98d8503e4fcfc7a18c3f9b4 Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Tue, 19 Apr 2011 12:15:46 +0000 Subject: [PATCH] Bug #613502: Summary bar total display uses wrong currency Patch by Ajay Thomas: I have attached a proposed patch for this bug. It would work in all cases wherein the user enters the currency of the book to be different from the default report currency. For Example: Suppose the user set the default report and account default currency (through GnuCash preferences dialog) to be USD. If user creates a new account hierarchy (new book) with the currency as INR, The summary bar would be displayed as: -Grand Total in INR -TOTAL_SINGLE_MODE in INR ( any accounts within the book which has amount in INR) -OTHER CURRENCIES (if accounts within the book belong to other currencies) The new account hierarchy dialog creates a new book or adds accounts to an already existing account tree. This summary bar will display the book default currency for all books created after applying the patch. My change sets the currency of the new book as the commodity of the root account of the book. Earlier, the user entered currency for the newly created book was not saved as an attribute in the book or root account. I have tested the patch with 3 test cases by: 1. creating a new book with currency different from the default currency ( both account default and report default currency within the report) . 2. using an existing book to setup an account hierarchy which sets a new default currency for the book ( it merges the existing account tree with the newly created book) 3. Already existing books summary bars work the same way as before. BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20568 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/gnome-utils/window-main-summarybar.c | 9 +++++++-- src/gnome/assistant-hierarchy.c | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/gnome-utils/window-main-summarybar.c b/src/gnome-utils/window-main-summarybar.c index 74b5372e39..d6ac2e6252 100644 --- a/src/gnome-utils/window-main-summarybar.c +++ b/src/gnome-utils/window-main-summarybar.c @@ -385,8 +385,14 @@ gnc_main_window_summary_refresh (GNCMainSummary * summary) GList *current; GNCSummarybarOptions options; - options.default_currency = gnc_default_report_currency (); + root = gnc_get_current_root_account (); + options.default_currency = xaccAccountGetCommodity(root); + if(options.default_currency == NULL) + { + options.default_currency = gnc_default_currency (); + } + options.euro = gnc_gconf_get_bool(GCONF_GENERAL, KEY_ENABLE_EURO, NULL); options.grand_total = gnc_gconf_get_bool(GCONF_SECTION, KEY_GRAND_TOTAL, NULL); @@ -407,7 +413,6 @@ gnc_main_window_summary_refresh (GNCMainSummary * summary) gnc_ui_get_currency_accumulator (¤cy_list, options.default_currency, TOTAL_SINGLE); - root = gnc_get_current_root_account (); gnc_ui_accounts_recurse(root, ¤cy_list, options); { diff --git a/src/gnome/assistant-hierarchy.c b/src/gnome/assistant-hierarchy.c index 8a50576474..c81793f583 100644 --- a/src/gnome/assistant-hierarchy.c +++ b/src/gnome/assistant-hierarchy.c @@ -1009,13 +1009,18 @@ on_finish (GtkAssistant *gtkassistant, hierarchy_data *data) { GncHierarchyAssistantFinishedCallback when_completed; + gnc_commodity *com; + Account * root; ENTER (" "); - + com = gnc_currency_edit_get_currency (GNC_CURRENCY_EDIT(data->currency_selector)); + if (data->our_account_tree) { gnc_account_foreach_descendant (data->our_account_tree, (AccountCb)starting_balance_helper, data); + + } // delete before we suspend GUI events, and then muck with the model, @@ -1027,12 +1032,17 @@ on_finish (GtkAssistant *gtkassistant, gnc_suspend_gui_refresh (); account_trees_merge(gnc_get_current_root_account(), data->our_account_tree); - + delete_our_account_tree (data); when_completed = data->when_completed; g_free(data); + + root = gnc_get_current_root_account(); + xaccAccountSetCommodity(root, com); + gnc_resume_gui_refresh (); + if (when_completed) { (*when_completed)();