gnucash stable: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Thu Jan 15 17:32:28 EST 2026


Updated	 via  https://github.com/Gnucash/gnucash/commit/cad455e3 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/4cc37b3f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d72f8de8 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/334b015c (commit)
	from  https://github.com/Gnucash/gnucash/commit/bab04728 (commit)



commit cad455e3c0f6f364eda95199c9ce19eb25d4418f
Merge: bab04728f4 4cc37b3f06
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Jan 16 06:31:42 2026 +0800

    Merge branch 'account-col-earliest-date' into stable #2168


commit 4cc37b3f06a5bc922afab37644ac49633b0679e1
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Jan 12 22:13:46 2026 +0800

    Account tab can show/sort by Earliest Date column
    
    Allows the user to display / sort by account's earliest split
    date. This usually reflect the account opening date.

diff --git a/gnucash/gnome-utils/gnc-tree-model-account.c b/gnucash/gnome-utils/gnc-tree-model-account.c
index dfaaabb8d3..2ab3e52494 100644
--- a/gnucash/gnome-utils/gnc-tree-model-account.c
+++ b/gnucash/gnome-utils/gnc-tree-model-account.c
@@ -379,6 +379,7 @@ gnc_tree_model_account_get_column_type (GtkTreeModel *tree_model, int index)
     case GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED:
     case GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_REPORT:
     case GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_DATE:
+    case GNC_TREE_MODEL_ACCOUNT_COL_EARLIEST_DATE:
     case GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN:
     case GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN_REPORT:
     case GNC_TREE_MODEL_ACCOUNT_COL_TOTAL:
@@ -843,6 +844,13 @@ gnc_tree_model_account_get_value (GtkTreeModel *tree_model,
             g_value_take_string (value, qof_print_date (last_date));
         break;
 
+    case GNC_TREE_MODEL_ACCOUNT_COL_EARLIEST_DATE:
+        g_value_init (value, G_TYPE_STRING);
+        time64 earliest = gnc_account_get_earliest_date (account);
+        if (earliest != INT64_MAX)
+            g_value_take_string (value, qof_print_date (earliest));
+        break;
+
     case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED:
         g_value_init (value, G_TYPE_STRING);
         string = gnc_ui_account_get_print_balance (xaccAccountGetReconciledBalanceInCurrency,
diff --git a/gnucash/gnome-utils/gnc-tree-model-account.h b/gnucash/gnome-utils/gnc-tree-model-account.h
index 4b2baefd1b..1d4acedb8b 100644
--- a/gnucash/gnome-utils/gnc-tree-model-account.h
+++ b/gnucash/gnome-utils/gnc-tree-model-account.h
@@ -68,6 +68,7 @@ typedef enum
     GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED,
     GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_REPORT,
     GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_DATE,
+    GNC_TREE_MODEL_ACCOUNT_COL_EARLIEST_DATE,
     GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN,
     GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN_REPORT,
     GNC_TREE_MODEL_ACCOUNT_COL_TOTAL,
diff --git a/gnucash/gnome-utils/gnc-tree-view-account.c b/gnucash/gnome-utils/gnc-tree-view-account.c
index d3cfe1e8f3..586472a68e 100644
--- a/gnucash/gnome-utils/gnc-tree-view-account.c
+++ b/gnucash/gnome-utils/gnc-tree-view-account.c
@@ -285,6 +285,20 @@ sort_cb_setup (GtkTreeModel *f_model,
                            &iter_a, &iter_b, account_a, account_b);
 }
 
+
+static gint
+sort_by_earliest_date (GtkTreeModel *f_model, GtkTreeIter *f_iter1, GtkTreeIter *f_iter2,
+                       gpointer user_data)
+{
+    const Account *account1, *account2;
+    sort_cb_setup (f_model, f_iter1, f_iter2, &account1, &account2);
+
+    time64 date1 = gnc_account_get_earliest_date (account1);
+    time64 date2 = gnc_account_get_earliest_date (account2);
+    return date1 == date2 ? xaccAccountOrder (account1, account2) :
+        date1 == INT64_MAX || date1 < date2 ? -1 : 1;
+}
+
 static gint
 sort_by_last_reconcile_date (GtkTreeModel *f_model,
                              GtkTreeIter *f_iter1,
@@ -884,6 +898,12 @@ gnc_tree_view_account_new_with_root (Account *root, gboolean show_root)
                                            GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
                                            sort_by_reconciled_value);
 
+    gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Earliest Date"), "earliest-date", NULL,
+                                  "31 December 2000",
+                                  GNC_TREE_MODEL_ACCOUNT_COL_EARLIEST_DATE,
+                                  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+                                  sort_by_earliest_date);
+
     gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Last Reconcile Date"), "last-recon-date", NULL,
                                   "Last Reconcile Date",
                                   GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_DATE,

commit d72f8de89ab1895fc3e506e206e88b497a611d27
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Jan 12 22:30:21 2026 +0800

    [balance-forecast.scm] use gnc-account-get-earliest-date

diff --git a/gnucash/report/reports/standard/balance-forecast.scm b/gnucash/report/reports/standard/balance-forecast.scm
index 52ffeb2047..78e906fb30 100644
--- a/gnucash/report/reports/standard/balance-forecast.scm
+++ b/gnucash/report/reports/standard/balance-forecast.scm
@@ -195,7 +195,7 @@ date point, a projected minimum balance including scheduled transactions."))
               (fold
                (lambda (a b)
                  (if (zero? (xaccAccountGetSplitsSize a)) b
-                     (let ((date (xaccTransGetDate (xaccSplitGetParent (car (xaccAccountGetSplits a))))))
+                     (let ((date (gnc-account-get-earliest-date a)))
                        (if b (min date b) date))))
                #f accounts))
              (sx-hash (if earliest

commit 334b015c195c7547f694551260a0de0163540781
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Jan 12 22:09:14 2026 +0800

    [Account.h] gnc_account_get_earliest_date
    
    Returns posted date of earliest split, or INT64_MAX if the account has
    no splits.
    
    This may reflect the opening date of the account.

diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp
index ed795cc502..41f1705e5d 100644
--- a/libgnucash/engine/Account.cpp
+++ b/libgnucash/engine/Account.cpp
@@ -5078,6 +5078,14 @@ gnc_account_tree_staged_transaction_traversal (const Account *acc,
     return 0;
 }
 
+time64
+gnc_account_get_earliest_date (const Account* account)
+{
+    g_return_val_if_fail (GNC_IS_ACCOUNT(account), INT64_MAX);
+    const auto& splits = xaccAccountGetSplits (account);
+    return splits.empty() ? INT64_MAX : xaccTransGetDate (xaccSplitGetParent (splits.front()));
+}
+
 /********************************************************************\
 \********************************************************************/
 
diff --git a/libgnucash/engine/Account.h b/libgnucash/engine/Account.h
index 3adbd4d1b7..f748588735 100644
--- a/libgnucash/engine/Account.h
+++ b/libgnucash/engine/Account.h
@@ -1580,6 +1580,15 @@ typedef enum
     int xaccAccountTreeForEachTransaction(Account *acc,
                                           TransactionCallback proc, void *data);
 
+    /**
+     * Returns the date of the earliest split in the account, or INT64_MAX.
+     *
+     * @param account   The account to retrieve data about.
+     *
+     * @return posted_date of first split in the account, or INT64_MAX
+     */
+    time64 gnc_account_get_earliest_date (const Account* account);
+
     /* Look up an Account in the map non-Baysian
      */
     Account* gnc_account_imap_find_account (Account* acc, const char* category,



Summary of changes:
 gnucash/gnome-utils/gnc-tree-model-account.c         |  8 ++++++++
 gnucash/gnome-utils/gnc-tree-model-account.h         |  1 +
 gnucash/gnome-utils/gnc-tree-view-account.c          | 20 ++++++++++++++++++++
 gnucash/report/reports/standard/balance-forecast.scm |  2 +-
 libgnucash/engine/Account.cpp                        |  8 ++++++++
 libgnucash/engine/Account.h                          |  9 +++++++++
 6 files changed, 47 insertions(+), 1 deletion(-)



More information about the gnucash-changes mailing list