r22109 - gnucash/trunk/src/register/ledger-core - Add auto-read-only feature for old transactions after N days, denoted by the new red line in the register.

Christian Stimming cstim at code.gnucash.org
Wed Mar 21 18:18:53 EDT 2012


Author: cstim
Date: 2012-03-21 18:18:53 -0400 (Wed, 21 Mar 2012)
New Revision: 22109
Trac: http://svn.gnucash.org/trac/changeset/22109

Modified:
   gnucash/trunk/src/register/ledger-core/split-register-model.c
Log:
Add auto-read-only feature for old transactions after N days, denoted by the new red line in the register.

Modified: gnucash/trunk/src/register/ledger-core/split-register-model.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-model.c	2012-03-21 22:18:41 UTC (rev 22108)
+++ gnucash/trunk/src/register/ledger-core/split-register-model.c	2012-03-21 22:18:53 UTC (rev 22109)
@@ -1770,6 +1770,41 @@
     return xaccPrintAmount (balance, gnc_account_print_info (account, FALSE));
 }
 
+static gboolean posted_date_means_readonly(const Transaction *trans)
+{
+    GDate *threshold_date;
+    GDate trans_date;
+    const QofBook *book = gnc_get_current_book ();
+    gboolean result;
+    g_assert(trans);
+
+    if (!qof_book_uses_autofreeze(book))
+    {
+        //g_warning("we don't use auto-read-only, num_days=%d", qof_book_get_num_days_autofreeze(book));
+        return FALSE;
+    }
+
+    threshold_date = qof_book_get_autofreeze_gdate(book);
+    trans_date = xaccTransGetDatePostedGDate(trans);
+
+//    g_warning("there is auto-read-only with days=%d, trans_date_day=%d, threshold_date_day=%d",
+//              qof_book_get_num_days_autofreeze(book),
+//              g_date_get_day(&trans_date),
+//              g_date_get_day(threshold_date));
+
+    if (g_date_compare(&trans_date, threshold_date) <= 0)
+    {
+        //g_warning("we must auto-read-only");
+        result = TRUE;
+    }
+    else
+    {
+        result = FALSE;
+    }
+    g_date_free(threshold_date);
+    return result;
+}
+
 static gboolean
 gnc_split_register_cursor_is_readonly (VirtualLocation virt_loc,
                                        gpointer user_data)
@@ -1785,7 +1820,8 @@
     txn = xaccSplitGetParent (split);
     if (!txn) return FALSE;
 
-    if (xaccTransGetReadOnly(txn))
+    if (xaccTransGetReadOnly(txn)
+            || posted_date_means_readonly(txn))
         return(TRUE);
 
     type = xaccTransGetTxnType (txn);



More information about the gnucash-changes mailing list