[grisbi-cvs] [SCM] grisbi branch, grisbi-0.8.x, updated. upstream_version_0_8_7-27-g6215b9a

Pierre Biava nobody at users.sourceforge.net
Sun Nov 27 17:26:10 CET 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grisbi".

The branch, grisbi-0.8.x has been updated
       via  6215b9a7ce27d85224b6ac263a8ab78d379af401 (commit)
       via  7409e2d4e876d6b3adb347e743a2a11984976b36 (commit)
       via  1427612c5ac7c1f6df987f112d5d16f7e3d68aed (commit)
       via  f3ea336a6f5c42ce1d767ecfc13b3827432eea28 (commit)
      from  067b3a198c416e399e2c1cf77ad7619ea08516ab (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6215b9a7ce27d85224b6ac263a8ab78d379af401
Author: pbiava <pierre.biava at nerim.net>
Date:   Sun Nov 27 17:24:59 2011 +0100

    Fixed a bug sorting of transactions when changing column

commit 7409e2d4e876d6b3adb347e743a2a11984976b36
Author: pbiava <pierre.biava at nerim.net>
Date:   Sun Nov 27 16:43:33 2011 +0100

    Formatting the code

commit 1427612c5ac7c1f6df987f112d5d16f7e3d68aed
Author: pbiava <pierre.biava at nerim.net>
Date:   Sat Nov 12 00:00:33 2011 +0100

    fixed bug 1364: Fixed a problem of updating of check number of a planned operation

commit f3ea336a6f5c42ce1d767ecfc13b3827432eea28
Author: pbiava <pierre.biava at nerim.net>
Date:   Fri Nov 11 22:34:21 2011 +0100

    Fixed a problem of importing a check from a QIF file

-----------------------------------------------------------------------

Changes:
diff --git a/src/gsb_data_transaction.c b/src/gsb_data_transaction.c
index bea3199..2367796 100644
--- a/src/gsb_data_transaction.c
+++ b/src/gsb_data_transaction.c
@@ -31,7 +31,7 @@
 #endif
 
 #include "include.h"
-
+#include <errno.h>
 
 /*START_INCLUDE*/
 #include "gsb_data_transaction.h"
@@ -2458,25 +2458,44 @@ gint gsb_data_transaction_find_by_payment_content ( const gchar *string,
                         gint account_number )
 {
     GSList *tmp_list;
+    gint64 number_1;
+    gchar *endptr;
 
     if (!string)
-	return 0;
+        return 0;
+
+    errno = 0;
+    number_1 = g_ascii_strtoll ( string, &endptr, 10);
+    if ( errno == ERANGE )
+        return 0;
+
+    if ( endptr )
+        return 0;
 
     tmp_list = transactions_list;
     while (tmp_list)
     {
-	struct_transaction *transaction;
+        struct_transaction *transaction;
 
-	transaction = tmp_list -> data;
+        transaction = tmp_list -> data;
 
-	if ( transaction -> method_of_payment_content
-	     &&
-	     transaction -> account_number == account_number
-	     &&
-	     !strcmp ( string,
-		       transaction -> method_of_payment_content ))
-	    return transaction -> transaction_number;
-	tmp_list = tmp_list -> next;
+        if ( transaction -> method_of_payment_content
+         &&
+         transaction -> account_number == account_number )
+        {
+            gint64 number_2;
+
+            errno = 0;
+            number_2 = g_ascii_strtoll ( transaction -> method_of_payment_content, &endptr, 10);
+            if ( errno == ERANGE )
+                return 0;
+            if ( endptr )
+                return 0;
+
+            if ( number_1 == number_2 )
+                return transaction -> transaction_number;
+        }
+        tmp_list = tmp_list -> next;
     }
     return 0;
 }
diff --git a/src/gsb_form.c b/src/gsb_form.c
index 3360fce..dcd5bba 100644
--- a/src/gsb_form.c
+++ b/src/gsb_form.c
@@ -2350,12 +2350,12 @@ gboolean gsb_form_finish_edition ( void )
 
     /* get the number of the transaction, stored in the form (< 0 if new ) */
     transaction_number = GPOINTER_TO_INT (g_object_get_data ( G_OBJECT ( transaction_form ),
-							      "transaction_number_in_form" ));
+                                "transaction_number_in_form" ));
 
     /* set a debug here, if transaction_number is 0, should look for where it comes */
     if (!transaction_number)
-	notice_debug ("Coming in gsb_form_finish_edition with a 0 number of transaction. "
-                  "This is a bug,\nplease try to do it again and report the bug.");
+        notice_debug ("Coming in gsb_form_finish_edition with a 0 number of transaction. "
+                        "This is a bug,\nplease try to do it again and report the bug.");
 
     account_number = gsb_form_get_account_number ();
 
@@ -2363,26 +2363,26 @@ gboolean gsb_form_finish_edition ( void )
      * we have to decide if it's a transaction or a scheduled transaction,
      * and if it's a scheduled, if we execute it (and create transaction) or work on it*/
     if (gsb_form_get_origin () == ORIGIN_VALUE_SCHEDULED
-	||
-	gsb_form_get_origin () == ORIGIN_VALUE_HOME )
+     ||
+     gsb_form_get_origin () == ORIGIN_VALUE_HOME )
     {
         if (g_object_get_data ( G_OBJECT (transaction_form), "execute_scheduled"))
         {
-	       /* we want to execute the scheduled transaction */
-	       is_transaction = TRUE;
-	       execute_scheduled = TRUE;
+           /* we want to execute the scheduled transaction */
+           is_transaction = TRUE;
+           execute_scheduled = TRUE;
 
-	       /* we need to keep the number of scheduled, to check later if there is
+           /* we need to keep the number of scheduled, to check later if there is
             * some children and modifie the scheduled transaction */
-	       saved_scheduled_number = transaction_number;
-	       /* as it's a new transaction, do the same as a white line */
-	       transaction_number = -1;
+           saved_scheduled_number = transaction_number;
+           /* as it's a new transaction, do the same as a white line */
+           transaction_number = -1;
         }
         else
             is_transaction = FALSE;
     }
     else
-	is_transaction = TRUE;
+        is_transaction = TRUE;
 
     /* a new transaction has a number < 0
      * -1 for the general white line
@@ -2463,16 +2463,16 @@ gboolean gsb_form_finish_edition ( void )
                     gsb_transactions_list_append_new_transaction ( transaction_number, TRUE);
                 }
                 nbre_passage++;
-	        }
+            }
 
             list_tmp = list_tmp -> next;
             if ( list_tmp == NULL )
                 break;
             else if ( nbre_passage > 1 )
                 continue;
-	    }
+        }
 
-	    /* now we create the transaction if necessary and set the mother in case of child of split */
+        /* now we create the transaction if necessary and set the mother in case of child of split */
         if ( new_transaction )
         {
             /* it's a new transaction, we create it, and set the mother if necessary */
@@ -2495,6 +2495,25 @@ gboolean gsb_form_finish_edition ( void )
         /* take the datas in the form, except the category */
         gsb_form_take_datas_from_form ( transaction_number, is_transaction );
 
+        /* si l'opération est une opération planifiée exécutée on met en forme TRANSACTION_FORM_CHEQUE */
+        if ( execute_scheduled )
+        {
+            gint payment_number;
+
+            payment_number = gsb_data_transaction_get_method_of_payment_number ( transaction_number );
+
+            if ( gsb_data_payment_get_automatic_numbering ( payment_number ) )
+            {
+                gchar *tmp_str;
+
+                tmp_str = gsb_data_payment_incremente_last_number ( payment_number, 1 );
+                gsb_data_transaction_set_method_of_payment_content (
+                                transaction_number,
+                                tmp_str );
+                g_free ( tmp_str ) ;
+            }
+        }
+
         /* perhaps the currency button is not shown
          * in that case, we give the account currency to that transaction */
         if ( new_transaction
@@ -2582,9 +2601,7 @@ gboolean gsb_form_finish_edition ( void )
 
     /* if it's a reconciliation and we modify a transaction, check
      * the amount of marked transactions */
-    if ( is_transaction
-	 &&
-	 etat.equilibrage )
+    if ( is_transaction && etat.equilibrage )
     {
         if (new_transaction)
             /* we are reconciling and it's a new transaction, so need to show the checkbox */
@@ -2621,36 +2638,34 @@ gboolean gsb_form_finish_edition ( void )
     }
 
     /* if it was a new transaction, do the stuff to do another new transaction */
-    if ( new_transaction
-	 &&
-	 !execute_scheduled)
+    if ( new_transaction && !execute_scheduled )
     {
-	/* we are on a new transaction, if that transaction is a split,
-	 * we give the focus to the new white line created for that and
-	 * edit it, for that we need to open the transaction to select the
-	 * white line, and set it as current transaction */
-	if ( gsb_data_mix_get_split_of_transaction (transaction_number, is_transaction))
-	{
-	    /* it's a split */
-	    gint white_line_number;
+        /* we are on a new transaction, if that transaction is a split,
+         * we give the focus to the new white line created for that and
+         * edit it, for that we need to open the transaction to select the
+         * white line, and set it as current transaction */
+        if ( gsb_data_mix_get_split_of_transaction (transaction_number, is_transaction))
+        {
+            /* it's a split */
+            gint white_line_number;
 
-	    white_line_number = gsb_data_mix_get_white_line (transaction_number, is_transaction);
-	    if ( is_transaction )
-            transaction_list_select ( white_line_number );
-	    else
-            gsb_scheduler_list_select (white_line_number);
-	}
+            white_line_number = gsb_data_mix_get_white_line (transaction_number, is_transaction);
+            if ( is_transaction )
+                transaction_list_select ( white_line_number );
+            else
+                gsb_scheduler_list_select (white_line_number);
+        }
 
-	/* it was a new transaction, we save the last date entry */
-	gsb_date_set_last_date ( gtk_entry_get_text (
+        /* it was a new transaction, we save the last date entry */
+        gsb_date_set_last_date ( gtk_entry_get_text (
                         GTK_ENTRY ( gsb_form_widget_get_widget ( TRANSACTION_FORM_DATE ) ) ) );
 
-	/* we need to use edit_transaction to make a new child split if necessary */
-	if ( is_transaction)
-	    gsb_transactions_list_edit_transaction (
+        /* we need to use edit_transaction to make a new child split if necessary */
+        if ( is_transaction)
+            gsb_transactions_list_edit_transaction (
                         gsb_data_account_get_current_transaction_number ( account_number ) );
-	else
-	    gsb_scheduler_list_edit_transaction ( gsb_scheduler_list_get_current_scheduled_number ( ) );
+        else
+            gsb_scheduler_list_edit_transaction ( gsb_scheduler_list_get_current_scheduled_number ( ) );
     }
     else
         gsb_form_hide ();
diff --git a/src/gsb_transactions_list.c b/src/gsb_transactions_list.c
index ae96a4c..b4da49f 100644
--- a/src/gsb_transactions_list.c
+++ b/src/gsb_transactions_list.c
@@ -95,6 +95,9 @@ static GtkWidget *gsb_transactions_list_create_tree_view ( GtkTreeModel *model )
 static void gsb_transactions_list_create_tree_view_columns ( void );
 static void gsb_transactions_list_display_contra_transaction ( gint *transaction_number );
 static gboolean gsb_transactions_list_fill_model ( void );
+static gint gsb_transactions_list_get_valid_element_sort ( gint account_number,
+                        gint column_number,
+                        gint element_number );
 static gboolean gsb_transactions_list_key_press ( GtkWidget *widget,
                         GdkEventKey *ev );
 static gboolean gsb_transactions_list_move_transaction_to_account ( gint transaction_number,
@@ -3181,7 +3184,7 @@ gboolean gsb_transactions_list_change_sort_column ( GtkTreeViewColumn *tree_view
 
     account_number = gsb_gui_navigation_get_current_account ();
     transaction_list_sort_get_column ( &current_column, &sort_type );
-    new_column = GPOINTER_TO_INT (column_ptr);
+    new_column = GPOINTER_TO_INT ( column_ptr );
 
     element_number = gsb_data_account_get_element_sort ( account_number, new_column );
 
@@ -3190,56 +3193,66 @@ gboolean gsb_transactions_list_change_sort_column ( GtkTreeViewColumn *tree_view
 
     /* if we come here and the list was user custom sorted for reconcile,
      * we stop the reconcile sort and set what is asked by the user */
-    if (transaction_list_sort_get_reconcile_sort ())
-    {
-	transaction_list_sort_set_reconcile_sort (FALSE);
-	gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (reconcile_sort_list_button),
-				       FALSE );
-	/* if we asked the same last column, we invert the value,
-	 * to come back to the last sort_type before the sort reconciliation */
-	if (new_column == current_column)
-	{
-	    if (sort_type == GTK_SORT_ASCENDING)
-		sort_type = GTK_SORT_DESCENDING;
-	    else
-		sort_type = GTK_SORT_ASCENDING;
-	}
+    if ( transaction_list_sort_get_reconcile_sort () )
+    {
+        transaction_list_sort_set_reconcile_sort ( FALSE );
+        gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( reconcile_sort_list_button ),
+                                FALSE );
+        /* if we asked the same last column, we invert the value,
+         * to come back to the last sort_type before the sort reconciliation */
+        if ( new_column == current_column )
+        {
+            if ( sort_type == GTK_SORT_ASCENDING )
+                sort_type = GTK_SORT_DESCENDING;
+            else
+                sort_type = GTK_SORT_ASCENDING;
+        }
     }
 
     /* if the new column is the same as the old one, we change
      * the sort type */
-    if (new_column == current_column)
+    if ( new_column == current_column )
     {
-	if (sort_type == GTK_SORT_ASCENDING)
-	    sort_type = GTK_SORT_DESCENDING;
-	else
-	    sort_type = GTK_SORT_ASCENDING;
+        if ( sort_type == GTK_SORT_ASCENDING )
+            sort_type = GTK_SORT_DESCENDING;
+        else
+            sort_type = GTK_SORT_ASCENDING;
     }
     else
-	/* we sort by another column, so sort type by default is descending */
-	sort_type = GTK_SORT_ASCENDING;
+    {
+        gint new_element;
 
+        /* on vérifie que l'élément de tri existe sinon on met le premier élément de la colonne */
+        new_element = gsb_transactions_list_get_valid_element_sort ( account_number,
+                        new_column,
+                        element_number );
+        if ( new_element != element_number )
+        {
+            gsb_data_account_set_element_sort ( account_number, new_column, new_element );
+            element_number = new_element;
+        }
+        /* we sort by another column, so sort type by default is descending */
+        sort_type = GTK_SORT_ASCENDING;
+    }
     /* now have to save the new column and sort type in the account
      * or in all account if global conf for all accounts */
     tmp_list = gsb_data_account_get_list_accounts ();
-    while (tmp_list)
+    while ( tmp_list )
     {
-	gint tmp_account;
+        gint tmp_account;
 
-	tmp_account = gsb_data_account_get_no_account (tmp_list -> data);
+        tmp_account = gsb_data_account_get_no_account ( tmp_list -> data );
 
-	if (tmp_account == account_number
-	    ||
-	    !etat.retient_affichage_par_compte)
-	{
-	    /* set the new column to sort */
-	    gsb_data_account_set_sort_column ( tmp_account,
-					       new_column );
-	    /* save the sort_type */
-	    gsb_data_account_set_sort_type ( tmp_account,
-					     sort_type );
-	}
-	tmp_list = tmp_list -> next;
+        if ( tmp_account == account_number
+            ||
+            !etat.retient_affichage_par_compte )
+        {
+            /* set the new column to sort */
+            gsb_data_account_set_sort_column ( tmp_account, new_column );
+            /* save the sort_type */
+            gsb_data_account_set_sort_type ( tmp_account, sort_type );
+        }
+        tmp_list = tmp_list -> next;
     }
 
     selected_transaction = transaction_list_select_get ();
@@ -3835,6 +3848,28 @@ gboolean gsb_transactions_list_set_largeur_col ( void )
 }
 
 
+/**
+ *
+ *
+ *
+ *
+ **/
+gint gsb_transactions_list_get_valid_element_sort ( gint account_number,
+                        gint column_number,
+                        gint element_number )
+{
+    gint i;
+
+    for ( i = 0 ; i < 4 ; i++ )
+    {
+        if ( tab_affichage_ope[i][column_number] == element_number )
+            return element_number;
+    }
+
+    return tab_affichage_ope[0][column_number];
+}
+
+
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */


hooks/post-receive
-- 
grisbi


More information about the cvs mailing list