gnucash maint: Bug 789674 - Close Book tool regression

Geert Janssens gjanssens at code.gnucash.org
Tue Nov 20 12:59:10 EST 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/11af81b5 (commit)
	from  https://github.com/Gnucash/gnucash/commit/37056297 (commit)



commit 11af81b51b46e02b9da12bbf583426c63e828ba4
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Tue Nov 20 18:55:09 2018 +0100

    Bug 789674 - Close Book tool regression

diff --git a/gnucash/gnome-utils/dialog-book-close.c b/gnucash/gnome-utils/dialog-book-close.c
index 8cec934..b67b4b6 100644
--- a/gnucash/gnome-utils/dialog-book-close.c
+++ b/gnucash/gnome-utils/dialog-book-close.c
@@ -103,13 +103,7 @@ find_or_create_txn(struct CloseAccountsCB* cacb, gnc_commodity* cmdty)
         txn->txn = xaccMallocTransaction(cacb->cbw->book);
         xaccTransBeginEdit(txn->txn);
         xaccTransSetDateEnteredSecs(txn->txn, gnc_time (NULL));
-
-        /* Watch out: The book-closing txn currently assume that their
-        posted-date is the end date plus 12 hours, so that the closing txn can
-        be distinguished from normal txns of the last day. This is the only
-        case within GnuCash where the PostedDate is a different time-of-day
-        that what the GDate normally says as a normalized date. */
-        xaccTransSetDatePostedSecs(txn->txn, cacb->cbw->close_date);
+        xaccTransSetDatePostedSecsNormalized(txn->txn, cacb->cbw->close_date);
 
         xaccTransSetDescription(txn->txn, cacb->cbw->desc);
         xaccTransSetCurrency(txn->txn, cmdty);
@@ -142,7 +136,7 @@ static void close_accounts_cb(Account *a, gpointer data)
     if (cacb->acct_type != xaccAccountGetType(a))
         return;
 
-    bal = xaccAccountGetBalanceAsOfDate(a, cacb->cbw->close_date + 1);
+    bal = xaccAccountGetBalanceAsOfDate(a, gnc_time64_get_day_end (cacb->cbw->close_date));
     if (gnc_numeric_zero_p(bal))
         return;
 
@@ -289,7 +283,6 @@ gnc_book_close_response_cb(GtkDialog *dialog, gint response, GtkDialog *unused)
         break;
     case GTK_RESPONSE_OK:
         cbw->close_date = gnc_date_edit_get_date(GNC_DATE_EDIT(cbw->close_date_widget));
-        cbw->close_date += (3600 * 12);  /* Add 12 hours to the timestamp */
         cbw->desc = gtk_entry_get_text(GTK_ENTRY(cbw->desc_widget));
 
         income_acct = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(cbw->income_acct_widget));
diff --git a/libgnucash/engine/Transaction.c b/libgnucash/engine/Transaction.c
index f9edab7..355ccb0 100644
--- a/libgnucash/engine/Transaction.c
+++ b/libgnucash/engine/Transaction.c
@@ -1886,6 +1886,14 @@ xaccTransOrder_num_action (const Transaction *ta, const char *actna,
     if (ta->date_posted != tb->date_posted)
         return (ta->date_posted > tb->date_posted) - (ta->date_posted < tb->date_posted);
 
+    /* Always sort closing transactions after normal transactions */
+    {
+        gboolean ta_is_closing = xaccTransGetIsClosingTxn (ta);
+        gboolean tb_is_closing = xaccTransGetIsClosingTxn (tb);
+        if (ta_is_closing != tb_is_closing)
+            return (ta_is_closing - tb_is_closing);
+    }
+
     /* otherwise, sort on number string */
     if (actna && actnb) /* split action string, if not NULL */
     {



Summary of changes:
 gnucash/gnome-utils/dialog-book-close.c | 11 ++---------
 libgnucash/engine/Transaction.c         |  8 ++++++++
 2 files changed, 10 insertions(+), 9 deletions(-)



More information about the gnucash-changes mailing list