From 03ff5d3778c9d3148f08b72dca0b984a36ec74df Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Sat, 4 Mar 2017 12:25:56 +0100 Subject: [PATCH 1/6] Allow only date entry for opening balances on new accounts This anomaly was spotted by Christopher Lam --- src/gnome-utils/dialog-account.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gnome-utils/dialog-account.c b/src/gnome-utils/dialog-account.c index c4895b5546..66a131770f 100644 --- a/src/gnome-utils/dialog-account.c +++ b/src/gnome-utils/dialog-account.c @@ -1373,7 +1373,7 @@ gnc_account_window_create(AccountWindow *aw) gtk_label_set_mnemonic_widget (GTK_LABEL(label), amount); box = GTK_WIDGET(gtk_builder_get_object (builder, "opening_balance_date_box")); - date_edit = gnc_date_edit_new (gnc_time (NULL), 1, 1); + date_edit = gnc_date_edit_new (gnc_time (NULL), 0, 0); aw->opening_balance_date_edit = date_edit; gtk_box_pack_start(GTK_BOX(box), date_edit, TRUE, TRUE, 0); gtk_widget_show (date_edit); From 97598c430693239d6aeab9dc4ff6f49e789cebff Mon Sep 17 00:00:00 2001 From: John Ralls Date: Thu, 9 Mar 2017 11:38:42 -0800 Subject: [PATCH 2/6] Bug 776564 - Creating a scheduled transaction from an existing... transaction does not include the notes field. In fact, notes support was entirely missing from scheduled transactions. --- src/engine/SX-ttinfo.c | 25 ++++++++++++++++++++++++- src/engine/SX-ttinfo.h | 3 ++- src/engine/SchedXaction.c | 1 + src/gnome/dialog-sx-from-trans.c | 1 + 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/engine/SX-ttinfo.c b/src/engine/SX-ttinfo.c index 052d964fa8..7af023f8cc 100644 --- a/src/engine/SX-ttinfo.c +++ b/src/engine/SX-ttinfo.c @@ -30,9 +30,9 @@ /* KvpFrame policy? */ struct TTInfo_s { - /* FIXME add notes field */ char *description; /* owned by us */ char *num; /* owned by us */ + char *notes; gnc_commodity *common_currency; /* not freed */ GList *splits; /* list of template splits, owned by us */ @@ -67,6 +67,7 @@ void gnc_ttinfo_free(TTInfo *info) g_free(info->description); g_free(info->num); + g_free (info->notes); g_list_foreach(info->splits, delete_splitinfo, NULL); @@ -127,6 +128,28 @@ gnc_ttinfo_get_num(TTInfo *tti) return tti->num; } +void +gnc_ttinfo_set_notes (TTInfo *tti, const char *notes) +{ + g_return_if_fail (tti); + + if (tti->notes) + { + g_free (tti->notes); + } + + tti->notes = g_strdup (notes); + + return; +} + +const char* +gnc_ttinfo_get_notes (TTInfo *tti) +{ + g_return_val_if_fail (tti, NULL); + + return tti->notes; +} void gnc_ttinfo_set_currency(TTInfo *tti, gnc_commodity *common_currency) diff --git a/src/engine/SX-ttinfo.h b/src/engine/SX-ttinfo.h index 084475727a..72486f7a66 100644 --- a/src/engine/SX-ttinfo.h +++ b/src/engine/SX-ttinfo.h @@ -41,7 +41,7 @@ void gnc_ttinfo_free(TTInfo *info); /* these two deep-copy their arguments */ void gnc_ttinfo_set_description(TTInfo *tti, const char *description); void gnc_ttinfo_set_num(TTInfo *tti, const char *num); - +void gnc_ttinfo_set_notes (TTInfo *tti, const char *notes); /* this one points to a persistent pointer so ownership isn't relevant */ void gnc_ttinfo_set_currency(TTInfo *tti, gnc_commodity *common_currency); @@ -52,6 +52,7 @@ void gnc_ttinfo_set_template_splits(TTInfo *tti, GList *splits); const char * gnc_ttinfo_get_description(TTInfo *tti); const char * gnc_ttinfo_get_num(TTInfo *tti); +const char *gnc_ttinfo_get_notes (TTInfo *tti); gnc_commodity * gnc_ttinfo_get_currency(TTInfo *tti); GList * gnc_ttinfo_get_template_splits(TTInfo *tti); diff --git a/src/engine/SchedXaction.c b/src/engine/SchedXaction.c index 1bdcb0b3e8..23ffb1f178 100644 --- a/src/engine/SchedXaction.c +++ b/src/engine/SchedXaction.c @@ -1039,6 +1039,7 @@ xaccSchedXactionSetTemplateTrans(SchedXaction *sx, GList *t_t_list, * xaccTransSetNum with these arguments */ gnc_set_num_action(new_trans, NULL, gnc_ttinfo_get_num(tti), NULL); + xaccTransSetNotes (new_trans, gnc_ttinfo_get_notes (tti)); xaccTransSetCurrency( new_trans, gnc_ttinfo_get_currency(tti) ); diff --git a/src/gnome/dialog-sx-from-trans.c b/src/gnome/dialog-sx-from-trans.c index 596512cc16..f8be47b624 100644 --- a/src/gnome/dialog-sx-from-trans.c +++ b/src/gnome/dialog-sx-from-trans.c @@ -221,6 +221,7 @@ sxftd_add_template_trans(SXFromTransInfo *sxfti) gnc_ttinfo_set_description(tti, xaccTransGetDescription(tr)); gnc_ttinfo_set_num(tti, gnc_get_num_action(tr, NULL)); + gnc_ttinfo_set_notes (tti, xaccTransGetNotes (tr)); gnc_ttinfo_set_currency(tti, xaccTransGetCurrency(tr)); for (splits = xaccTransGetSplitList(tr); splits; splits = splits->next) From bc50f3da005d707067a83d74852ad1bcc69f857b Mon Sep 17 00:00:00 2001 From: John Ralls Date: Fri, 10 Mar 2017 10:54:22 -0800 Subject: [PATCH 3/6] Bug 777949 - Accounts implicitly created in ledger attempt creation twice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Guard against recursively calling the account doesn’t exist query or creation dialog if one is already in the account creation dialog. The underlying problem is that creating the dialog forces a UI update that in turn sets the cell value and checks for the existence of the account. In basic view the cell being displayed (“transfer”) isn’t the one being changed (“account”) so the account check isn’t invoked, but in multi-split view the “account” cell *is* displayed so the check is invoked again. --- src/register/ledger-core/split-register.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/register/ledger-core/split-register.c b/src/register/ledger-core/split-register.c index 3e4eb74a4e..2e2aebdeee 100644 --- a/src/register/ledger-core/split-register.c +++ b/src/register/ledger-core/split-register.c @@ -1833,6 +1833,7 @@ gnc_split_register_get_account_by_name (SplitRegister *reg, BasicCell * bcell, char *account_name; ComboCell *cell = (ComboCell *) bcell; Account *account; + static gboolean creating_account = FALSE; if (!name || (strlen(name) == 0)) return NULL; @@ -1842,15 +1843,16 @@ gnc_split_register_get_account_by_name (SplitRegister *reg, BasicCell * bcell, if (!account) account = gnc_account_lookup_by_code(gnc_get_current_root_account(), name); - if (!account) + if (!account && !creating_account) { /* Ask if they want to create a new one. */ if (!gnc_verify_dialog (gnc_split_register_get_parent (reg), TRUE, missing, name)) return NULL; - + creating_account = TRUE; /* User said yes, they want to create a new account. */ account = gnc_ui_new_accounts_from_name_window (name); + creating_account = FALSE; if (!account) return NULL; } From 3889606dd6779564341247ec796a905b54d36426 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Fri, 10 Mar 2017 13:21:02 -0800 Subject: [PATCH 4/6] Bug 779217 - Transactions rounded to 5 decimal places when opening file. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit xaccSplitSetValue and xaccSplitSetAmount round to the denominator found by get_currency_denom and get_commodity_denom. The problem was that if the commodity was unfindable because either the split’s parent or account hadn’t been set (as is the case during loading, because the parent isn’t yet complete) the returned denominator would be 100000, smaller than the max supported. That would cause the value/amount to be prematurely rounded. --- src/engine/Split.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/Split.c b/src/engine/Split.c index 8d34c2396d..6ed3a4ebfc 100644 --- a/src/engine/Split.c +++ b/src/engine/Split.c @@ -928,7 +928,7 @@ get_currency_denom(const Split * s) } else if (!s->parent || !s->parent->common_currency) { - return 100000; + return 1000000; /* Max supported denom to avoid premature rounding. */ } else { @@ -945,7 +945,7 @@ get_commodity_denom(const Split * s) } else if (!s->acc) { - return 100000; + return 1000000; /* Max supported denom to avoid premature rounding. */ } else { From 80e64a129607f0bd4f02480ee10e85201420c6a8 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Fri, 10 Mar 2017 14:23:20 -0800 Subject: [PATCH 5/6] Fix failed unit test from previous commit. --- src/engine/test/utest-Split.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/test/utest-Split.c b/src/engine/test/utest-Split.c index a383b703a3..64a2a60fcf 100644 --- a/src/engine/test/utest-Split.c +++ b/src/engine/test/utest-Split.c @@ -748,10 +748,10 @@ test_get_currency_denom (Fixture *fixture, gconstpointer pData) const gint denom = gnc_commodity_get_fraction (fixture->curr); g_assert_cmpint (fixture->func->get_currency_denom (NULL), ==, 0); fixture->split->parent = NULL; - g_assert_cmpint (fixture->func->get_currency_denom (fixture->split), ==, 100000); + g_assert_cmpint (fixture->func->get_currency_denom (fixture->split), ==, 1000000); fixture->split->parent = txn; txn->common_currency = NULL; - g_assert_cmpint (fixture->func->get_currency_denom (fixture->split), ==, 100000); + g_assert_cmpint (fixture->func->get_currency_denom (fixture->split), ==, 1000000); txn->common_currency = fixture->curr; g_assert_cmpint (fixture->func->get_currency_denom (fixture->split), ==, denom); } @@ -766,7 +766,7 @@ test_get_commodity_denom (Fixture *fixture, gconstpointer pData) const gint denom = gnc_commodity_get_fraction (fixture->comm); g_assert_cmpint (fixture->func->get_commodity_denom (NULL), ==, 0); fixture->split->acc = NULL; - g_assert_cmpint (fixture->func->get_commodity_denom (fixture->split), ==, 100000); + g_assert_cmpint (fixture->func->get_commodity_denom (fixture->split), ==, 1000000); fixture->split->acc = acc; g_assert_cmpint (fixture->func->get_commodity_denom (fixture->split), ==, denom); } From 4949499bd44581419298a4b220fdbbe2c639a257 Mon Sep 17 00:00:00 2001 From: Christoph Rohland Date: Thu, 9 Mar 2017 15:01:11 +0100 Subject: [PATCH 6/6] Charge back net value of bill entries in invoices When charging entries from bills we need to exclude taxes since the tax rate of the invoice might be different than that of the bill. This fixes Bug 776380 - Gross value of bills charged back instead of net value (https://bugzilla.gnome.org/show_bug.cgi?id=776380) --- src/engine/gncInvoice.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/engine/gncInvoice.c b/src/engine/gncInvoice.c index 222553f435..a624b7bd4b 100644 --- a/src/engine/gncInvoice.c +++ b/src/engine/gncInvoice.c @@ -1465,7 +1465,11 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc, /* If this is a bill, and the entry came from an invoice originally, copy the price */ if (gncEntryGetBillable (entry)) - gncEntrySetInvPrice (entry, gncEntryGetBillPrice (entry)); + { + /* We need to set the net price since it may be another tax rate for invoices than bills */ + gncEntrySetInvPrice (entry, gncEntryGetPrice (entry, FALSE, TRUE)); + gncEntrySetInvTaxIncluded (entry, FALSE); + } } gncEntryCommitEdit (entry);