Skip to content

Commit

Permalink
Add preference for forcing prices to decimal display.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jralls committed Jul 15, 2018
1 parent 1fffbaf commit a51be51
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
5 changes: 5 additions & 0 deletions gnucash/gschemas/org.gnucash.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
25 changes: 22 additions & 3 deletions gnucash/gtkbuilder/dialog-preferences.glade
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand Down
8 changes: 6 additions & 2 deletions libgnucash/app-utils/gnc-ui-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand All @@ -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;
}

Expand Down

0 comments on commit a51be51

Please sign in to comment.