Prices in Price Database dialog

Robert Fewell 14ubobit at gmail.com
Tue Apr 4 16:20:44 EDT 2017


John,

Regarding the warnings, I suppose I am used to having a trace file with
zero bytes so it looked unusual but these warnings maybe the norm with the
c++ changes as the csv importer does the same when the date format is wrong.

It looks like it is difficult to get a fraction now with some quick testing
and as these prices were a while back I could just delete them. I did try
this code snippet in gnc_tree_model_price.c line 781 which works but not
sure it is worth while...

    case GNC_TREE_MODEL_PRICE_COL_VALUE:
        g_value_init (value, G_TYPE_STRING);
        priv = GNC_TREE_MODEL_PRICE_GET_PRIVATE(model);
        {
            gnc_numeric num = gnc_numeric_convert (gnc_price_get_value
(price), 1000000, GNC_HOW_RND_ROUND_HALF_UP);
            if (gnc_numeric_check (num) == GNC_ERROR_OK)
                 g_value_set_string (value, xaccPrintAmount (num,
priv->print_info));
            else
                 g_value_set_string (value, xaccPrintAmount
(gnc_price_get_value (price), priv->print_info));
        }
        break;

Regards,
Bob

On 3 April 2017 at 17:18, John Ralls <jralls at ceridwen.us> wrote:

>
> On Apr 3, 2017, at 8:21 AM, Robert Fewell <14ubobit at gmail.com> wrote:
>
> Hi,
>
> I gave been seeing these error messages in my trace file...
>
> * 15:53:27  WARN <qof> [gnc_numeric_to_decimal()] Rounding required when
> 'never round' specified.
> * 15:53:27  WARN <qof> [gnc_numeric_to_decimal()] Rounding required when
> 'never round' specified.
> * 15:53:27  WARN <qof> [gnc_numeric_to_decimal()] Rounding required when
> 'never round' specified.
>
> and was not sure why they were there, a bt revealed this ...
>
> #0  0x00007ffff756cbd8 in g_logv () from /usr/lib/libglib-2.0.so.0
> #1  0x00007ffff756ce0f in g_log () from /usr/lib/libglib-2.0.so.0
> #2  0x00007ffff5ff0f77 in gnc_numeric_to_decimal (a=a at entry
> =0x7fffffffd7d0,
> max_decimal_places=max_decimal_places at entry=0x0)
>    at
> /var/tmp/portage/app-office/gnucash-2.6.99/work/gnucash-2.
> 6.99/src/libqof/qof/gnc-numeric.cpp:1054
> #3  0x00007ffff69bac9c in PrintAmountInternal (info=<synthetic pointer>,
> val=..., buf=0x7ffff6bd4400 <buf> "-1,240.04")
>    at
> /var/tmp/portage/app-office/gnucash-2.6.99/work/gnucash-2.
> 6.99/src/app-utils/gnc-ui-util.c:1357
> #4  xaccSPrintAmount (bufp=bufp at entry=0x7ffff6bd4400 <buf> "-1,240.04",
> val=..., info=...)
>    at
> /var/tmp/portage/app-office/gnucash-2.6.99/work/gnucash-2.
> 6.99/src/app-utils/gnc-ui-util.c:1652
> #5  0x00007ffff69bb5bf in xaccPrintAmount (val=..., info=...)
>    at
> /var/tmp/portage/app-office/gnucash-2.6.99/work/gnucash-2.
> 6.99/src/app-utils/gnc-ui-util.c:1693
> #6  0x00007ffff6c713d3 in gnc_tree_model_price_get_value
> (tree_model=0x7c18a0, iter=<optimized out>, column=<optimized out>,
>    value=0x7fffffffd9e0) at
> /var/tmp/portage/app-office/gnucash-2.6.99/work/gnucash-2.
> 6.99/src/gnome-utils/gnc-tree-model-price.c:784
>
> I can see that the print_info is set in model_price to be 6 decimal places
> but on the attached screen shot you can see the warnings are against the
> ones that are fractions in the list.
> I would of expected all entries to be displayed to 6 decimal places.
>
> Is this correct and should just be ignored or should some thing be changed
> ?
>
>
> Bob,
>
> Well, it's doing what we're telling it to, and the warning is a side
> effect: PrintAmountInternal calls gnc_numeric_to_decimal() to find out if
> the number can be exactly represented as a decimal, and in order for that
> to work gnc_numeric_to_decimal() has to set the rounding flag to exact,
> which causes the rounding code to post the warning when it finds that it
> must round the result.
>
> That said, some users complain that prices are displayed too exactly and
> that displaying some as decimals and others as rationals is confusing.,
> e.g. https://bugzilla.gnome.org/show_bug.cgi?id=410060. If you decide to
> fix it do note that xaccPrintAmount is widely used, so be careful!
>
> Regards,
> John Ralls
>
>


More information about the gnucash-devel mailing list