gnucash maint: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Fri Sep 21 16:00:51 EDT 2018
Updated via https://github.com/Gnucash/gnucash/commit/6d2ef903 (commit)
via https://github.com/Gnucash/gnucash/commit/dd10ac8b (commit)
via https://github.com/Gnucash/gnucash/commit/80a45917 (commit)
from https://github.com/Gnucash/gnucash/commit/70bc472f (commit)
commit 6d2ef90313884672625a2641f9340f10211117de
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Sep 21 13:00:34 2018 -0700
Fix a magic number.
diff --git a/libgnucash/backend/dbi/gnc-dbisqlresult.cpp b/libgnucash/backend/dbi/gnc-dbisqlresult.cpp
index 334061a..0436c07 100644
--- a/libgnucash/backend/dbi/gnc-dbisqlresult.cpp
+++ b/libgnucash/backend/dbi/gnc-dbisqlresult.cpp
@@ -113,6 +113,7 @@ GncDbiSqlResult::IteratorImpl::get_int_at_col(const char* col) const
double
GncDbiSqlResult::IteratorImpl::get_float_at_col(const char* col) const
{
+ constexpr double float_precision = 1000000.0;
auto type = dbi_result_get_field_type (m_inst->m_dbi_result, col);
auto attrs = dbi_result_get_field_attribs (m_inst->m_dbi_result, col);
if(type != DBI_TYPE_DECIMAL ||
@@ -121,7 +122,7 @@ GncDbiSqlResult::IteratorImpl::get_float_at_col(const char* col) const
auto locale = gnc_push_locale (LC_NUMERIC, "C");
auto interim = dbi_result_get_float(m_inst->m_dbi_result, col);
gnc_pop_locale (LC_NUMERIC, locale);
- double retval = static_cast<double>(round(interim * 1000000.0)) / 1000000.0;
+ double retval = static_cast<double>(round(interim * float_precision)) / float_precision;
return retval;
}
commit dd10ac8bc79430b1b6795c8b67bd013ae4fc0d79
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Sep 21 13:00:19 2018 -0700
Don't need NANOS_PER_SECOND anymore.
diff --git a/libgnucash/engine/gnc-date-p.h b/libgnucash/engine/gnc-date-p.h
index 0a09d37..94f3639 100644
--- a/libgnucash/engine/gnc-date-p.h
+++ b/libgnucash/engine/gnc-date-p.h
@@ -31,8 +31,6 @@ extern "C"
#include <stdint.h>
#include "gnc-date.h"
-#define NANOS_PER_SECOND INT32_C(1000000000)
-
/** Convert a given date/time format from UTF-8 to an encoding suitable for the
* strftime system call.
*
commit 80a4591736f7a3715a81f57ff37733e28af360e5
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Sep 21 12:29:56 2018 -0700
Bug 786708 - GnuCash won't load currency fractions larger than 1000000.
Also create larger fractions for the account dialog.
diff --git a/gnucash/gtkbuilder/dialog-account.glade b/gnucash/gtkbuilder/dialog-account.glade
index 998d380..f53fdc6 100644
--- a/gnucash/gtkbuilder/dialog-account.glade
+++ b/gnucash/gtkbuilder/dialog-account.glade
@@ -875,6 +875,15 @@
<row>
<col id="0" translatable="yes">1/1000000</col>
</row>
+ <row>
+ <col id="0" translatable="yes">1/10000000</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">1/100000000</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">1/1000000000</col>
+ </row>
</data>
</object>
<object class="GtkDialog" id="account_dialog">
diff --git a/gnucash/gtkbuilder/dialog-commodity.glade b/gnucash/gtkbuilder/dialog-commodity.glade
index f5c12f8..66864dd 100644
--- a/gnucash/gtkbuilder/dialog-commodity.glade
+++ b/gnucash/gtkbuilder/dialog-commodity.glade
@@ -4,7 +4,7 @@
<requires lib="gtk+" version="3.10"/>
<object class="GtkAdjustment" id="adjustment1">
<property name="lower">1</property>
- <property name="upper">100000000</property>
+ <property name="upper">1000000000</property>
<property name="value">10000</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
diff --git a/gnucash/register/ledger-core/gncEntryLedger.c b/gnucash/register/ledger-core/gncEntryLedger.c
index e54c590..8bf2d19 100644
--- a/gnucash/register/ledger-core/gncEntryLedger.c
+++ b/gnucash/register/ledger-core/gncEntryLedger.c
@@ -265,21 +265,21 @@ gnc_entry_ledger_config_cells (GncEntryLedger *ledger)
((ComboCell *)
gnc_table_layout_get_cell (ledger->table->layout, ENTRY_ACTN_CELL), FALSE);
- /* Use 6 decimal places for all prices and quantities */
+ /* Use GNC_COMMODITY_MAX_FRACTION for all prices and quantities */
gnc_price_cell_set_fraction
((PriceCell *)
gnc_table_layout_get_cell (ledger->table->layout, ENTRY_PRIC_CELL),
- 1000000);
+ GNC_COMMODITY_MAX_FRACTION);
gnc_price_cell_set_fraction
((PriceCell *)
gnc_table_layout_get_cell (ledger->table->layout, ENTRY_DISC_CELL),
- 1000000);
+ GNC_COMMODITY_MAX_FRACTION);
gnc_price_cell_set_fraction
((PriceCell *) gnc_table_layout_get_cell (ledger->table->layout,
ENTRY_QTY_CELL),
- 1000000);
+ GNC_COMMODITY_MAX_FRACTION);
/* add menu items for the action and payment cells */
gnc_entry_ledger_config_action (ledger);
diff --git a/gnucash/register/ledger-core/split-register-util.c b/gnucash/register/ledger-core/split-register-util.c
index c48a2cf..3c34073 100644
--- a/gnucash/register/ledger-core/split-register-util.c
+++ b/gnucash/register/ledger-core/split-register-util.c
@@ -426,7 +426,7 @@ gnc_split_register_set_cell_fractions (SplitRegister *reg, Split *split)
if (split_account)
gnc_price_cell_set_fraction (cell, xaccAccountGetCommoditySCU (split_account));
else
- gnc_price_cell_set_fraction (cell, 1000000);
+ gnc_price_cell_set_fraction (cell, GNC_COMMODITY_MAX_FRACTION);
}
CellBlock *
diff --git a/gnucash/register/ledger-core/split-register.c b/gnucash/register/ledger-core/split-register.c
index f37dcd8..c3bfd49 100644
--- a/gnucash/register/ledger-core/split-register.c
+++ b/gnucash/register/ledger-core/split-register.c
@@ -65,9 +65,6 @@ static QofLogModule log_module = GNC_MOD_LEDGER;
static CursorClass copied_class = CURSOR_CLASS_NONE;
static SCM copied_item = SCM_UNDEFINED;
static GncGUID copied_leader_guid;
-/* A denominator representing number of digits to the right of the decimal point
- * displayed in a price cell. */
-static int PRICE_CELL_DENOM = 1000000;
/** static prototypes *****************************************************/
static gboolean gnc_split_register_save_to_scm (SplitRegister *reg,
@@ -2609,11 +2606,11 @@ gnc_split_register_config_cells (SplitRegister *reg)
((ComboCell *)
gnc_table_layout_get_cell (reg->table->layout, ACTN_CELL), TRUE);
- /* Use 6 decimal places for prices and "exchange rates" */
+ /* Use GNC_COMMODITY_MAX_FRACTION for prices and "exchange rates" */
gnc_price_cell_set_fraction
((PriceCell *)
gnc_table_layout_get_cell (reg->table->layout, PRIC_CELL),
- PRICE_CELL_DENOM);
+ GNC_COMMODITY_MAX_FRACTION);
/* Initialize shares and share balance cells */
gnc_price_cell_set_print_info
diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp
index 72ae32b..e3861f5 100644
--- a/libgnucash/engine/Account.cpp
+++ b/libgnucash/engine/Account.cpp
@@ -687,7 +687,7 @@ gnc_account_class_init (AccountClass *klass)
"1 USD can be divided into 100 cents.",
0,
G_MAXINT32,
- 1000000,
+ GNC_COMMODITY_MAX_FRACTION,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
diff --git a/libgnucash/engine/Split.c b/libgnucash/engine/Split.c
index 288c424..7893b4c 100644
--- a/libgnucash/engine/Split.c
+++ b/libgnucash/engine/Split.c
@@ -1111,7 +1111,7 @@ get_currency_denom(const Split * s)
}
else if (!s->parent || !s->parent->common_currency)
{
- return 1000000; /* Max supported denom to avoid premature rounding. */
+ return GNC_COMMODITY_MAX_FRACTION;
}
else
{
@@ -1128,7 +1128,7 @@ get_commodity_denom(const Split * s)
}
else if (!s->acc)
{
- return 1000000; /* Max supported denom to avoid premature rounding. */
+ return GNC_COMMODITY_MAX_FRACTION;
}
else
{
diff --git a/libgnucash/engine/gnc-commodity.c b/libgnucash/engine/gnc-commodity.c
index ee6b46a..f7b6c0c 100644
--- a/libgnucash/engine/gnc-commodity.c
+++ b/libgnucash/engine/gnc-commodity.c
@@ -842,7 +842,7 @@ gnc_commodity_class_init(struct _GncCommodityClass* klass)
"The fraction is the number of sub-units that "
"the basic commodity can be divided into.",
1,
- 1000000,
+ GNC_COMMODITY_MAX_FRACTION,
1,
G_PARAM_READWRITE));
g_object_class_install_property(gobject_class,
diff --git a/libgnucash/engine/gnc-commodity.h b/libgnucash/engine/gnc-commodity.h
index a2d3f28..1f20a71 100644
--- a/libgnucash/engine/gnc-commodity.h
+++ b/libgnucash/engine/gnc-commodity.h
@@ -115,6 +115,11 @@ GType gnc_commodity_namespace_get_type(void);
when presenting the currency related namespace to the user */
#define GNC_COMMODITY_NS_ISO_GUI N_("Currencies")
+/** Max fraction is 10^9 because 10^10 would require changing it to an
+ * int64_t.
+ */
+#define GNC_COMMODITY_MAX_FRACTION 1000000000
+
typedef GList CommodityList;
/** @name Commodity Quote Source functions
Summary of changes:
gnucash/gtkbuilder/dialog-account.glade | 9 +++++++++
gnucash/gtkbuilder/dialog-commodity.glade | 2 +-
gnucash/register/ledger-core/gncEntryLedger.c | 8 ++++----
gnucash/register/ledger-core/split-register-util.c | 2 +-
gnucash/register/ledger-core/split-register.c | 7 ++-----
libgnucash/backend/dbi/gnc-dbisqlresult.cpp | 3 ++-
libgnucash/engine/Account.cpp | 2 +-
libgnucash/engine/Split.c | 4 ++--
libgnucash/engine/gnc-commodity.c | 2 +-
libgnucash/engine/gnc-commodity.h | 5 +++++
libgnucash/engine/gnc-date-p.h | 2 --
11 files changed, 28 insertions(+), 18 deletions(-)
More information about the gnucash-changes
mailing list