(Deliberately top-posting because the original message is somewhat long)

I'm very happy with this patch, thanks ! It was on my to do list but I never 
got to actually write code for this bug.

I notice this one is marked for backporting. This may be slightly tricky 
because the 2.4 branch doesn't have an assistant-hierarchy.c source file. It 
does have a druid-hierarchy.c file though which is equivalent, but based on 
the obsolete GnomeDruid functionality instead of the GtkAssistent replacement.

The code can be backported (as the modified functions in essence haven't 
changed much in the conversion from Druid to Assistant), but not without 
manual intervention.

Geert

On dinsdag 19 april 2011, Christian Stimming wrote:
> Author: cstim
> Date: 2011-04-19 08:15:46 -0400 (Tue, 19 Apr 2011)
> New Revision: 20568
> Trac: http://svn.gnucash.org/trac/changeset/20568
> 
> Modified:
>    gnucash/trunk/src/gnome-utils/window-main-summarybar.c
>    gnucash/trunk/src/gnome/assistant-hierarchy.c
> Log:
> 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
> 
> Modified: gnucash/trunk/src/gnome/assistant-hierarchy.c
> ===================================================================
> --- gnucash/trunk/src/gnome/assistant-hierarchy.c     2011-04-19 11:32:51 UTC
> (rev 20567) +++ gnucash/trunk/src/gnome/assistant-hierarchy.c 2011-04-19
> 12:15:46 UTC (rev 20568) @@ -1009,13 +1009,18 @@
>             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 @@
>      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)();
> 
> Modified: gnucash/trunk/src/gnome-utils/window-main-summarybar.c
> ===================================================================
> --- gnucash/trunk/src/gnome-utils/window-main-summarybar.c    2011-04-19
> 11:32:51 UTC (rev 20567) +++
> gnucash/trunk/src/gnome-utils/window-main-summarybar.c        2011-04-19 
12:15:46
> UTC (rev 20568) @@ -385,8 +385,14 @@
>      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_ui_get_currency_accumulator (&currency_list,
> options.default_currency, TOTAL_SINGLE);
> 
> -    root = gnc_get_current_root_account ();
>      gnc_ui_accounts_recurse(root, &currency_list, options);
> 
>      {
> 
> _______________________________________________
> gnucash-changes mailing list
> gnucash-chan...@gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-changes


_______________________________________________
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to