Add preference for forcing prices to decimal display.

Anticipating that some users might prefer to see exact prices,
add a preference to General>Numbers to configure whether prices
are rounded to decimals or are displayed as exact fractions.
This commit is contained in:
John Ralls 2018-07-15 14:18:01 -07:00
parent 1fffbaf856
commit a51be5157c
3 changed files with 33 additions and 5 deletions

View File

@ -65,6 +65,11 @@
<summary>Number of automatic decimal places</summary>
<description>This field specifies the number of automatic decimal places that will be filled in.</description>
</key>
<key name='force-price-decimal' type="b">
<default>false</default>
<summary>Force prices to display as decimals even if they must be rounded.</summary>
<description>If active, GnuCash will round prices as necessary to display them as decimals instead of displaying the exact fraction if the fractional part cannont be exactly represented as a decimal.</description>
</key>
<key name="migrate-prefs-done" type="b">
<default>false</default>
<summary>Tool to migrate preferences from old backend (CGonf) to new one (GSettings) has run successfully.</summary>

View File

@ -1338,7 +1338,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">12</property>
<property name="top_attach">13</property>
</packing>
</child>
<child>
@ -1356,7 +1356,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">12</property>
<property name="top_attach">13</property>
</packing>
</child>
<child>
@ -1375,7 +1375,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">11</property>
<property name="top_attach">12</property>
</packing>
</child>
<child>
@ -1392,6 +1392,25 @@ many months before the current month:</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">11</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="pref/general/force-price-decimal">
<property name="label" translatable="yes">Force P_rices to display as decimals.</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_markup">Force prices to display as decimals even if they must be rounded.</property>
<property name="tooltip_text" translatable="yes">If active, GnuCash will round prices as necessary to display them as decimals instead of displaying the exact fraction if the fractional part cannont be exactly represented as a decimal.</property>
<property name="halign">start</property>
<property name="margin_left">12</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">10</property>

View File

@ -66,6 +66,7 @@
#define GNC_PREF_REVERSED_ACCTS_NONE "reversed-accounts-none"
#define GNC_PREF_REVERSED_ACCTS_CREDIT "reversed-accounts-credit"
#define GNC_PREF_REVERSED_ACCTS_INC_EXP "reversed-accounts-incomeexpense"
#define GNC_PREF_PRICES_FORCE_DECIMAL "force-price-decimal"
static QofLogModule log_module = GNC_MOD_GUI;
@ -1325,6 +1326,8 @@ GNCPrintAmountInfo
gnc_default_price_print_info (const gnc_commodity *curr)
{
GNCPrintAmountInfo info;
gboolean force = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL,
GNC_PREF_PRICES_FORCE_DECIMAL);
info.commodity = curr;
if (info.commodity)
@ -1345,8 +1348,9 @@ gnc_default_price_print_info (const gnc_commodity *curr)
info.use_symbol = 0;
info.use_locale = 1;
info.monetary = 1;
info.force_fit = TRUE;
info.round = TRUE;
info.force_fit = force;
info.round = force;
return info;
}