r22123 - gnucash/trunk/src/register/ledger-core - Take read-only setting of QofBook into account for the transaction duplication.

Christian Stimming cstim at code.gnucash.org
Sun Mar 25 16:18:42 EDT 2012


Author: cstim
Date: 2012-03-25 16:18:42 -0400 (Sun, 25 Mar 2012)
New Revision: 22123
Trac: http://svn.gnucash.org/trac/changeset/22123

Modified:
   gnucash/trunk/src/register/ledger-core/split-register.c
Log:
Take read-only setting of QofBook into account for the transaction duplication.

Modified: gnucash/trunk/src/register/ledger-core/split-register.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register.c	2012-03-25 19:13:16 UTC (rev 22122)
+++ gnucash/trunk/src/register/ledger-core/split-register.c	2012-03-25 20:18:42 UTC (rev 22123)
@@ -509,6 +509,7 @@
         const char *in_num = NULL;
         char *out_num;
         time_t date;
+        gboolean use_autoreadonly = qof_book_uses_autoreadonly(gnc_get_current_book());
 
         /* We are on a transaction row. Copy the whole transaction. */
 
@@ -531,6 +532,30 @@
             return NULL;
         }
 
+        if (use_autoreadonly)
+        {
+            GDate d;
+            GDate *readonly_threshold = qof_book_get_autoreadonly_gdate(gnc_get_current_book());
+            g_date_set_time_t (&d, date);
+            if (g_date_compare(&d, readonly_threshold) < 0)
+            {
+                GtkWidget *dialog = gtk_message_dialog_new(NULL,
+                                    0,
+                                    GTK_MESSAGE_ERROR,
+                                    GTK_BUTTONS_OK,
+                                    "%s", _("Cannot store a transaction at this date"));
+                gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
+                        "%s", _("The entered date of the duplicated transaction is older than the \"Read-Only Threshold\" set for this book.  "
+                                "This setting can be changed in File -> Properties -> Accounts."));
+                gtk_dialog_run(GTK_DIALOG(dialog));
+                gtk_widget_destroy(dialog);
+
+                g_date_free(readonly_threshold);
+                return NULL;
+            }
+            g_date_free(readonly_threshold);
+        }
+
         split_index = xaccTransGetSplitIndex(trans, split);
         trans_split_index = xaccTransGetSplitIndex(trans, trans_split);
 



More information about the gnucash-changes mailing list