r22124 - gnucash/trunk/src/register/register-gnome - Take read-only date setting of QofBook into account (no pun intended) when entering transaction into accounts.
Christian Stimming
cstim at code.gnucash.org
Mon Mar 26 16:15:04 EDT 2012
Author: cstim
Date: 2012-03-26 16:15:04 -0400 (Mon, 26 Mar 2012)
New Revision: 22124
Trac: http://svn.gnucash.org/trac/changeset/22124
Modified:
gnucash/trunk/src/register/register-gnome/datecell-gnome.c
Log:
Take read-only date setting of QofBook into account (no pun intended) when entering transaction into accounts.
The code will silently revert the entered date to the threshold and just
not allow any older date to be entered. I wonder whether we can display
some useful error message additionally, but unfortunately I didn't find
the place in the code where one single error message would have resulted,
only places where multiply (annoying) error messages would have resulted.
Modified: gnucash/trunk/src/register/register-gnome/datecell-gnome.c
===================================================================
--- gnucash/trunk/src/register/register-gnome/datecell-gnome.c 2012-03-25 20:18:42 UTC (rev 22123)
+++ gnucash/trunk/src/register/register-gnome/datecell-gnome.c 2012-03-26 20:15:04 UTC (rev 22124)
@@ -94,12 +94,44 @@
gnc_parse_date (struct tm *parsed, const char * datestr)
{
int day, month, year;
+ gboolean use_autoreadonly = qof_book_uses_autoreadonly(gnc_get_current_book());
if (!parsed) return;
if (!datestr) return;
qof_scan_date (datestr, &day, &month, &year);
+ // If we have an auto-read-only threshold, do not accept a date that is
+ // older than the threshold.
+ if (use_autoreadonly)
+ {
+ GDate *d = g_date_new_dmy(day, month, year);
+ GDate *readonly_threshold = qof_book_get_autoreadonly_gdate(gnc_get_current_book());
+ if (g_date_compare(d, readonly_threshold) < 0)
+ {
+ g_warning("Entered date %s is before the \"auto-read-only threshold\"; resetting to the threshold.", datestr);
+#if 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 new 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);
+#endif
+
+ // Reset the date to the threshold date
+ day = g_date_get_day(readonly_threshold);
+ month = g_date_get_month(readonly_threshold);
+ year = g_date_get_year(readonly_threshold);
+ }
+ g_date_free(d);
+ g_date_free(readonly_threshold);
+ }
+
parsed->tm_mday = day;
parsed->tm_mon = month - 1;
parsed->tm_year = year - 1900;
More information about the gnucash-changes
mailing list