[grisbi-cvs] [SCM] grisbi branch, grisbi-0.8.x, updated. upstream_version_0_8_5-6-g0babebc

Pierre Biava nobody at users.sourceforge.net
Sat Apr 16 18:31:27 CEST 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  0babebc9fe0dbaf7226251e2fc5fe1e8fa28b3e8 (commit)
      from  7544052c224eb02a4671a0469ba92170eb803354 (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 0babebc9fe0dbaf7226251e2fc5fe1e8fa28b3e8
Author: pbiava <pierre.biava at nerim.net>
Date:   Sat Apr 16 18:30:52 2011 +0200

    Fixed a bug in the selection form of planned transactions. Adds support for the variance for the planned transactions.

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

Changes:
diff --git a/src/gsb_data_scheduled.c b/src/gsb_data_scheduled.c
index 2528128..00683be 100644
--- a/src/gsb_data_scheduled.c
+++ b/src/gsb_data_scheduled.c
@@ -42,6 +42,7 @@
 #include "gsb_real.h"
 #include "utils_dates.h"
 #include "utils_str.h"
+#include "erreur.h"
 /*END_INCLUDE*/
 
 
@@ -1875,6 +1876,42 @@ gboolean gsb_data_scheduled_copy_scheduled ( gint source_scheduled_number,
 }
 
 
+/**
+ * retourne TRUE si la variance de l'opération ventilée == 0
+ *
+ *
+ *
+ * */
+gboolean gsb_data_scheduled_get_variance ( gint mother_scheduled_number )
+{
+    GSList *tmp_list;
+    gsb_real total_split = null_real;
+    gsb_real variance;
+
+    tmp_list = scheduled_list;
+    while ( tmp_list )
+    {
+        struct_scheduled *tmp_scheduled;
+
+        tmp_scheduled = tmp_list -> data;
+
+        if ( tmp_scheduled -> mother_scheduled_number == mother_scheduled_number )
+        {
+            total_split = gsb_real_add ( total_split,
+                        gsb_data_scheduled_get_amount ( tmp_scheduled -> scheduled_number ) );
+        }
+        tmp_list = tmp_list -> next;
+    }
+
+    variance = gsb_real_sub ( gsb_data_scheduled_get_amount ( mother_scheduled_number ), total_split );
+
+    if ( variance.mantissa == 0 )
+        return TRUE;
+    else
+        return FALSE;
+}
+
+
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */
diff --git a/src/gsb_data_scheduled.h b/src/gsb_data_scheduled.h
index 88825e4..37b738a 100644
--- a/src/gsb_data_scheduled.h
+++ b/src/gsb_data_scheduled.h
@@ -39,6 +39,7 @@ gint gsb_data_scheduled_get_sub_budgetary_number ( gint scheduled_number );
 gint gsb_data_scheduled_get_sub_category_number ( gint scheduled_number );
 gint gsb_data_scheduled_get_user_entry ( gint scheduled_number );
 gint gsb_data_scheduled_get_user_interval ( gint scheduled_number );
+gboolean gsb_data_scheduled_get_variance ( gint mother_scheduled_number );
 gint gsb_data_scheduled_get_white_line ( gint scheduled_number);
 gboolean gsb_data_scheduled_init_variables ( void );
 gboolean gsb_data_scheduled_is_transfer ( gint scheduled_number );
diff --git a/src/gsb_form.c b/src/gsb_form.c
index 5d93c8a..3360fce 100644
--- a/src/gsb_form.c
+++ b/src/gsb_form.c
@@ -539,19 +539,24 @@ gboolean gsb_form_fill_by_transaction ( gint transaction_number,
     /* we take focus only if asked */
     if (grab_focus)
     {
-	/* the form is full, if it's not a split, we give the focus to the date
-	 * else, we give the focus to the first free form element */
-	if (mother_number)
-	    focus_to = gsb_form_widget_next_element ( account_number,
+        GtkWidget *widget;
+
+        /* the form is full, if it's not a split, we give the focus to the date
+         * else, we give the focus to the first free form element */
+        if (mother_number)
+            focus_to = gsb_form_widget_next_element ( account_number,
 						      TRANSACTION_FORM_DATE,
 						      GSB_RIGHT );
-	else
-	    focus_to = TRANSACTION_FORM_DATE;
+        else
+            focus_to = TRANSACTION_FORM_DATE;
+
+        widget = gsb_form_widget_get_widget ( focus_to );
+        gtk_editable_select_region ( GTK_EDITABLE ( widget ), 0, -1 );
+        if ( !is_transaction && gtk_widget_is_focus ( widget ) )
+            gsb_form_widget_entry_get_focus ( widget, NULL, GINT_TO_POINTER ( focus_to ) );
+        else
+            gtk_widget_grab_focus ( widget );
 
-	gtk_editable_select_region ( GTK_EDITABLE ( gsb_form_widget_get_widget (focus_to)),
-				  0,
-				  -1);
-	gtk_widget_grab_focus ( gsb_form_widget_get_widget (focus_to));
     }
 
     return FALSE;
@@ -2643,25 +2648,27 @@ gboolean gsb_form_finish_edition ( void )
 	/* 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) );
+                        gsb_data_account_get_current_transaction_number ( account_number ) );
 	else
-	    gsb_scheduler_list_edit_transaction (gsb_scheduler_list_get_current_scheduled_number ());
+	    gsb_scheduler_list_edit_transaction ( gsb_scheduler_list_get_current_scheduled_number ( ) );
     }
     else
         gsb_form_hide ();
 
     /* on sort de la saisie des opérations filles si variance == 0 */
-    if ( is_transaction
-     &&
-     ( mother_number = gsb_data_transaction_get_mother_transaction_number ( transaction_number ) )
-     &&
-     transaction_list_get_variance ( gsb_data_account_get_current_transaction_number (
-                        account_number ) ) )
-        transaction_list_select ( mother_number );
+    if ( ( mother_number = gsb_data_mix_get_mother_transaction_number ( transaction_number, is_transaction ) ) )
+    {
+        if ( is_transaction
+         &&
+         transaction_list_get_variance ( gsb_data_account_get_current_transaction_number ( account_number ) ) )
+            transaction_list_select ( mother_number );
+        else if ( !is_transaction && !execute_scheduled && gsb_data_scheduled_get_variance ( mother_number ) )
+            gsb_scheduler_list_select ( mother_number );
+    }
 
     /* if it was a modification of transaction, we need to update the sort and colors
      * (done automatically for new transaction) */
-    if ( !new_transaction && !execute_scheduled )
+    if ( is_transaction && !new_transaction )
         gsb_transactions_list_update_tree_view (account_number, TRUE);
 
     /* show the warnings */
diff --git a/src/gsb_form_widget.c b/src/gsb_form_widget.c
index 50fe93f..c4d74df 100644
--- a/src/gsb_form_widget.c
+++ b/src/gsb_form_widget.c
@@ -57,9 +57,6 @@
 static gboolean gsb_form_combo_selection_changed ( GtkTreeSelection *tree_selection,
 						  gint *ptr_origin );
 static gboolean gsb_form_widget_can_focus ( gint element_number );
-static gboolean gsb_form_widget_entry_get_focus ( GtkWidget *entry,
-                        GdkEventFocus *ev,
-                        gint *ptr_origin );
 /*END_STATIC*/
 
 /*START_EXTERN*/
diff --git a/src/gsb_form_widget.h b/src/gsb_form_widget.h
index 2af4a26..7f69a4b 100644
--- a/src/gsb_form_widget.h
+++ b/src/gsb_form_widget.h
@@ -23,6 +23,9 @@ gboolean gsb_form_widget_amount_entry_validate ( gint element_number );
 gboolean gsb_form_widget_check_empty ( GtkWidget *entry );
 GtkWidget *gsb_form_widget_create ( gint element_number,
                         gint account_number );
+gboolean gsb_form_widget_entry_get_focus ( GtkWidget *entry,
+                        GdkEventFocus *ev,
+                        gint *ptr_origin );
 gboolean gsb_form_widget_free_list ( void );
 GSList *gsb_form_widget_get_list ( void );
 gchar *gsb_form_widget_get_name ( gint element_number );
diff --git a/src/gsb_scheduler_list.c b/src/gsb_scheduler_list.c
index a08b567..c343f45 100644
--- a/src/gsb_scheduler_list.c
+++ b/src/gsb_scheduler_list.c
@@ -104,6 +104,8 @@ static gint gsb_scheduler_list_sort_function_by_payee ( GtkTreeModel *model,
                         GtkTreeIter *iter_2,
                         gint *column_ptr );
 static gboolean gsb_scheduler_list_switch_expander ( gint scheduled_number );
+static gboolean gsb_scheduler_list_update_white_child ( gint white_line_number,
+                        gint mother_scheduled_number );
 static void popup_scheduled_context_menu ( void );
 /*END_STATIC*/
 
@@ -117,6 +119,7 @@ extern GdkColor couleur_selection;
 extern struct conditional_message delete_msg[];
 extern gint mise_a_jour_liste_echeances_manuelles_accueil;
 extern GtkWidget * navigation_tree_view;
+extern gsb_real null_real;
 extern GtkWidget *scheduler_button_delete;
 extern GtkWidget *scheduler_button_edit;
 extern GtkWidget *scheduler_button_execute;
@@ -838,12 +841,17 @@ gboolean gsb_scheduler_list_append_new_scheduled ( gint scheduled_number,
     mother_scheduled_number = gsb_data_scheduled_get_mother_scheduled_number ( scheduled_number );
     if ( mother_scheduled_number )
     {
+        gint white_line_number;
+
         mother_iter = gsb_scheduler_list_get_iter_from_scheduled_number ( mother_scheduled_number );
         if ( !mother_iter )
             /* it's a child but didn't find the mother, it can happen in old files previous to 0.6
              * where the children wer saved before the mother, return FALSE here will add that
              * child to a list to append it again later */
             return FALSE;
+
+        white_line_number = gsb_data_scheduled_get_white_line ( mother_scheduled_number );
+        gsb_scheduler_list_update_white_child ( white_line_number, mother_scheduled_number );
     }
 
     pGDateCurrent = gsb_date_copy ( gsb_data_scheduled_get_date ( scheduled_number ) );
@@ -878,6 +886,8 @@ gboolean gsb_scheduler_list_append_new_scheduled ( gint scheduled_number,
                 white_line_number = gsb_data_scheduled_new_white_line ( scheduled_number );
                 gsb_scheduler_list_append_new_scheduled ( white_line_number, end_date );
             }
+
+            gsb_scheduler_list_update_white_child ( white_line_number, scheduled_number );
         }
 
         /* if it's a split, we show only one time and color the background */
@@ -984,63 +994,73 @@ gboolean gsb_scheduler_list_update_transaction_in_list ( gint scheduled_number )
 
     devel_debug_int (scheduled_number);
 
-    if ( !scheduled_number
-	 ||
-	 !gsb_scheduler_list_get_model ())
-	return FALSE;
+    if ( !scheduled_number || !gsb_scheduler_list_get_model ( ) )
+        return FALSE;
 
     /* the same transaction can be showed more than one time because of the different views,
      * not so difficult, go throw the list and for each iter corresponding to the scheduled
      * transaction, re-fill the line */
-    store = GTK_TREE_STORE (gsb_scheduler_list_get_model ());
+    store = GTK_TREE_STORE ( gsb_scheduler_list_get_model ( ) );
 
-    pGDateCurrent = gsb_date_copy (gsb_data_scheduled_get_date (scheduled_number));
+    pGDateCurrent = gsb_date_copy ( gsb_data_scheduled_get_date ( scheduled_number ) );
 
     /* fill the text line */
-    gsb_scheduler_list_fill_transaction_text ( scheduled_number,
-					       line );
+    gsb_scheduler_list_fill_transaction_text ( scheduled_number, line );
 
-    if (gtk_tree_model_get_iter_first ( GTK_TREE_MODEL (store), &iter))
+    if ( gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( store ), &iter ) )
     {
-	do
-	{
-	    gint scheduled_number_tmp;
-	    GtkTreeIter child_iter;
+        do
+        {
+            gint scheduled_number_tmp;
+            GtkTreeIter child_iter;
+
+            gtk_tree_model_get ( GTK_TREE_MODEL ( store ),
+                                &iter,
+                                SCHEDULER_COL_NB_TRANSACTION_NUMBER, &scheduled_number_tmp,
+                                -1 );
+            if ( scheduled_number_tmp == scheduled_number )
+            {
+                gsb_scheduler_list_fill_transaction_row ( GTK_TREE_STORE ( store ), &iter, line );
 
-	    gtk_tree_model_get ( GTK_TREE_MODEL (store), &iter,
-				 SCHEDULER_COL_NB_TRANSACTION_NUMBER, &scheduled_number_tmp,
-				 -1 );
-	    if (scheduled_number_tmp == scheduled_number)
-	    {
-		gsb_scheduler_list_fill_transaction_row ( GTK_TREE_STORE (store),
-							  &iter,
-							  line );
-		/* go to the next date if ever there is several lines of that scheduled */
-		pGDateCurrent = gsb_scheduler_get_next_date ( scheduled_number, pGDateCurrent );
+                /* go to the next date if ever there is several lines of that scheduled */
+                pGDateCurrent = gsb_scheduler_get_next_date ( scheduled_number, pGDateCurrent );
 
-		line[COL_NB_DATE] = gsb_format_gdate ( pGDateCurrent );
-	    }
+                line[COL_NB_DATE] = gsb_format_gdate ( pGDateCurrent );
+            }
 
-	    /* i still haven't found a function to go line by line, including the children,
-	     * so do another do/while into the first one */
-	    if (gtk_tree_model_iter_children (GTK_TREE_MODEL (store), &child_iter, &iter))
-	    {
-		/* we are on the child */
-		do
-		{
-		    gtk_tree_model_get ( GTK_TREE_MODEL (store), &child_iter,
-					 SCHEDULER_COL_NB_TRANSACTION_NUMBER, &scheduled_number_tmp,
-					 -1 );
-		    if (scheduled_number_tmp == scheduled_number)
-			gsb_scheduler_list_fill_transaction_row ( GTK_TREE_STORE (store),
-								  &child_iter,
-								  line );
-		}
-		while ( gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &child_iter));
-	    }
-	}
-	while ( gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter));
+            /* i still haven't found a function to go line by line, including the children,
+             * so do another do/while into the first one */
+            if ( gtk_tree_model_iter_children ( GTK_TREE_MODEL ( store ), &child_iter, &iter ) )
+            {
+                gint white_line_number = 0;
+                gint mother_number = 0;
+                /* we are on the child */
+                do
+                {
+                    gtk_tree_model_get ( GTK_TREE_MODEL (store),
+                                        &child_iter,
+                                        SCHEDULER_COL_NB_TRANSACTION_NUMBER, &scheduled_number_tmp,
+                                        -1 );
+
+                    if ( scheduled_number_tmp < -1 )
+                    {
+                        white_line_number = scheduled_number_tmp;
+                        mother_number = gsb_data_scheduled_get_mother_scheduled_number ( white_line_number );
+                    }
+
+                    if (scheduled_number_tmp == scheduled_number)
+                        gsb_scheduler_list_fill_transaction_row ( GTK_TREE_STORE (store),
+                                        &child_iter,
+                                        line );
+                }
+                while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( store ), &child_iter ) );
+
+                gsb_scheduler_list_update_white_child ( white_line_number, mother_number );
+            }
+        }
+        while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( store ), &iter ) );
     }
+
     return FALSE;
 }
 
@@ -2519,6 +2539,69 @@ gint gsb_scheduler_list_sort_function_by_account ( GtkTreeModel *model,
 }
 
 
+gboolean gsb_scheduler_list_update_white_child ( gint white_line_number,
+                        gint mother_scheduled_number )
+{
+    GtkTreeIter *iter = NULL;
+    GSList *tmp_list;
+    gsb_real total_split = null_real;
+    gsb_real variance;
+    gchar *tmp_str;
+
+    if ( !tree_model_scheduler_list )
+        return FALSE;
+
+    iter = gsb_scheduler_list_get_iter_from_scheduled_number ( white_line_number );
+    if ( !iter )
+        return FALSE;
+
+    tmp_list = gsb_data_scheduled_get_scheduled_list (  );
+    while ( tmp_list )
+    {
+        gint split_scheduled_number;
+
+        split_scheduled_number = gsb_data_scheduled_get_scheduled_number ( tmp_list -> data );
+
+        if ( gsb_data_scheduled_get_mother_scheduled_number (
+         split_scheduled_number ) == mother_scheduled_number )
+        {
+            total_split = gsb_real_add ( total_split,
+                        gsb_data_scheduled_get_amount ( split_scheduled_number ) );
+        }
+        tmp_list = tmp_list -> next;
+    }
+
+    variance = gsb_real_sub ( gsb_data_scheduled_get_amount ( mother_scheduled_number ), total_split );
+
+    /* show the variance and sub-total only if different of the scheduled */
+    if ( variance.mantissa )
+    {
+        gchar *amount_string;
+        gchar *variance_string;
+        gint currency_number;
+
+        currency_number = gsb_data_scheduled_get_currency_number ( mother_scheduled_number );
+        amount_string = gsb_real_get_string_with_currency ( total_split, currency_number, TRUE);
+        variance_string = gsb_real_get_string_with_currency (variance, currency_number, TRUE);
+
+        tmp_str = g_strdup_printf ( _("Total : %s (variance : %s)"), amount_string, variance_string );
+
+        g_free ( amount_string );
+        g_free ( variance_string );
+    }
+    else
+        tmp_str = "";
+
+    gtk_tree_store_set ( GTK_TREE_STORE ( tree_model_scheduler_list ), iter, 2, tmp_str, -1 );
+
+    if ( tmp_str && strlen ( tmp_str ) )
+        g_free ( tmp_str );
+
+    return TRUE;
+}
+
+
+
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */


hooks/post-receive
-- 
grisbi


More information about the cvs mailing list