[grisbi-cvs] grisbi/src accueil.c, 1.221, 1.222 balance_estimate_data.c, 1.8, 1.9 balance_estimate_data.h, 1.7, 1.8 balance_estimate_hist.c, 1.7, 1.8 balance_estimate_tab.c, 1.44, 1.45 classement_echeances.c, 1.13, 1.14 classement_echeances.h, 1.7, 1.8 gsb_file_save.c, 1.153, 1.154

Pierre Biava pbiava at users.sourceforge.net
Thu Feb 25 22:38:19 CET 2010


Update of /cvsroot/grisbi/grisbi/src
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5002/src

Modified Files:
	accueil.c balance_estimate_data.c balance_estimate_data.h 
	balance_estimate_hist.c balance_estimate_tab.c 
	classement_echeances.c classement_echeances.h gsb_file_save.c 
Log Message:
fixed bug 977 and minor changes

Index: gsb_file_save.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_file_save.c,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -d -r1.153 -r1.154
--- gsb_file_save.c	21 Feb 2010 12:30:17 -0000	1.153
+++ gsb_file_save.c	25 Feb 2010 21:38:17 -0000	1.154
@@ -2631,7 +2631,6 @@
 				        new_string );
 
     tab = bet_data_get_strings_to_save ( );
-    //~ printf ("tab -> len = %d\n", tab -> len);
 
     if ( tab == NULL )
         return iterator;

Index: balance_estimate_data.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_data.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- balance_estimate_data.h	21 Feb 2010 20:48:38 -0000	1.7
+++ balance_estimate_data.h	25 Feb 2010 21:38:17 -0000	1.8
@@ -47,10 +47,11 @@
                         gint div_number,
                         gint sub_div_nb );
 gsb_real bet_data_get_div_amount ( gint account_nb, gint div_number, gint sub_div_nb );
+gint bet_data_get_div_children ( gint account_nb, gint div_number );
+gboolean bet_data_get_div_edited ( gint account_nb, gint div_number, gint sub_div_nb );
 gchar *bet_data_get_div_name (gint div_num,
                         gint sub_div,
                         const gchar *return_value_error );
-gboolean bet_data_get_div_edited ( gint account_nb, gint div_number, gint sub_div_nb );
 gint bet_data_get_div_number ( gint transaction_number, gboolean is_transaction );
 gint bet_data_get_selected_currency ( void );
 GPtrArray *bet_data_get_strings_to_save ( void );

Index: accueil.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/accueil.c,v
retrieving revision 1.221
retrieving revision 1.222
diff -u -d -r1.221 -r1.222
--- accueil.c	6 Feb 2010 08:49:46 -0000	1.221
+++ accueil.c	25 Feb 2010 21:38:17 -0000	1.222
@@ -1229,6 +1229,7 @@
 	GSList *pointeur_liste;
 	GtkWidget *event_box;
 	GtkWidget *hbox;
+    gint manual = 1;
 
 	/* s'il y avait déjà un fils dans la frame, le détruit */
 	gtk_notebook_remove_page ( GTK_NOTEBOOK(frame_etat_echeances_manuelles_accueil), 0 );
@@ -1258,8 +1259,9 @@
 	style_label->fg[GTK_STATE_ACTIVE] = couleur_bleue;
 
 
-	pointeur_liste = g_slist_sort(scheduled_transactions_to_take,
-				      (GCompareFunc) classement_sliste_echeance_par_date );
+	pointeur_liste = g_slist_sort_with_data ( scheduled_transactions_to_take,
+				        (GCompareDataFunc) classement_sliste_echeance_par_date,
+                        GINT_TO_POINTER ( manual ) );
 
 	while ( pointeur_liste )
 	{
@@ -1361,6 +1363,7 @@
 	GSList *pointeur_liste;
 	GtkStyle *style_selectable;
 	GdkColor gray_color;
+    gint manual = 0;
 
 	/* s'il y avait déjà un fils dans la frame, le détruit */
 	gtk_notebook_remove_page ( GTK_NOTEBOOK ( frame_etat_echeances_auto_accueil ), 0 );
@@ -1381,8 +1384,9 @@
 	gtk_container_add ( GTK_CONTAINER ( frame_etat_echeances_auto_accueil ), vbox);
 	gtk_widget_show ( vbox);
 
-	pointeur_liste = g_slist_sort( scheduled_transactions_taken,
-				      (GCompareFunc) classement_sliste_echeance_par_date );
+	pointeur_liste = g_slist_sort_with_data ( scheduled_transactions_taken,
+				      (GCompareDataFunc) classement_sliste_echeance_par_date,
+                       GINT_TO_POINTER ( manual ) );
 
 	while ( pointeur_liste )
 	{

Index: classement_echeances.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/classement_echeances.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- classement_echeances.h	22 Jul 2009 19:45:42 -0000	1.7
+++ classement_echeances.h	25 Feb 2010 21:38:17 -0000	1.8
@@ -6,7 +6,8 @@
 
 /* START_DECLARATION */
 gint classement_sliste_echeance_par_date ( gint scheduled_number_1, 
-                        gint scheduled_number_2 );
+                        gint scheduled_number_2,
+                        gpointer manual );
 gint classement_sliste_transactions_par_date ( gpointer transaction_pointer_1, 
                         gpointer transaction_pointer_2 );
 /* END_DECLARATION */

Index: classement_echeances.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/classement_echeances.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- classement_echeances.c	26 Dec 2009 16:57:13 -0000	1.13
+++ classement_echeances.c	25 Feb 2010 21:38:17 -0000	1.14
@@ -46,16 +46,30 @@
 /* Classement de deux échéances d'opérations par date                        */
 /* ************************************************************************* */
 gint classement_sliste_echeance_par_date ( gint scheduled_number_1, 
-                        gint scheduled_number_2 )
+                        gint scheduled_number_2,
+                        gpointer manual )
 {
     const GDate *date;
 
-    date = gsb_data_transaction_get_date ( scheduled_number_1 );
-    if ( date )
-        return ( g_date_compare ( date,
-                        gsb_data_transaction_get_date (scheduled_number_2) ));
+    if ( manual )
+    {
+        date = gsb_data_scheduled_get_date ( scheduled_number_1 );
+        if ( date )
+            return ( g_date_compare ( date,
+                            gsb_data_scheduled_get_date (scheduled_number_2) ));
+        else
+            return -1;
+    }
     else
-        return -1;
+    {
+        date = gsb_data_transaction_get_date ( scheduled_number_1 );
+        if ( date )
+            return ( g_date_compare ( date,
+                            gsb_data_transaction_get_date (scheduled_number_2) ));
+        else
+            return -1;
+    }
+
 }
 
 

Index: balance_estimate_tab.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_tab.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- balance_estimate_tab.c	23 Feb 2010 21:36:45 -0000	1.44
+++ balance_estimate_tab.c	25 Feb 2010 21:38:17 -0000	1.45
@@ -406,7 +406,7 @@
     current_balance = gsb_data_account_calculate_current_day_balance (
                         selected_account, date_min );
 
-    str_amount = gsb_real_get_string ( current_balance );
+    str_amount = gsb_real_save_real_to_string ( current_balance, 2 );
     str_current_balance = gsb_real_get_string_with_currency ( current_balance,
                         gsb_data_account_get_currency ( selected_account ), TRUE );
 
@@ -1323,7 +1323,7 @@
         else
             continue;
 
-        str_amount = gsb_real_get_string ( amount );
+        str_amount = gsb_real_save_real_to_string ( amount, 2 );
         if (amount.mantissa < 0)
             str_debit = gsb_real_get_string_with_currency ( gsb_real_abs ( amount ),
                         gsb_data_scheduled_get_currency_number ( scheduled_number ), TRUE );
@@ -1445,7 +1445,7 @@
         g_value_set_boxed ( &date_value, date );
 
         amount = gsb_data_transaction_get_amount ( transaction_number );
-        str_amount = gsb_real_get_string ( amount );
+        str_amount = gsb_real_save_real_to_string ( amount, 2 );
 
         if (amount.mantissa < 0)
             str_debit = gsb_real_get_string_with_currency ( gsb_real_abs ( amount ),

Index: balance_estimate_data.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_data.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- balance_estimate_data.c	21 Feb 2010 20:48:38 -0000	1.8
+++ balance_estimate_data.c	25 Feb 2010 21:38:17 -0000	1.9
@@ -226,7 +226,10 @@
     gchar *key;
     char *sub_key;
     struct_hist_div *shd;
-
+    
+    //~ devel_debug ( g_strdup_printf ("account_nb = %d div_number = %d sub_div_nb = %d",
+                                    //~ account_nb, div_number, sub_div_nb));
+    
     if ( account_nb == 0 )
         key = g_strconcat ("0:", utils_str_itoa ( div_number ), NULL );
     else
@@ -270,7 +273,7 @@
 
     if ( ( shd = g_hash_table_lookup ( bet_hist_div_list, key ) ) )
     {
-        if ( g_hash_table_size ( shd -> sub_div_list ) == 0 )
+        if ( sub_div_nb == 0 )
         {
             g_free ( key );
             return TRUE;
@@ -445,6 +448,32 @@
  *
  *
  * */
+gint bet_data_get_div_children ( gint account_nb, gint div_number )
+{
+    gchar *key;
+    struct_hist_div *shd;
+
+    if ( account_nb == 0 )
+        key = g_strconcat ("0:", utils_str_itoa ( div_number ), NULL );
+    else
+        key = g_strconcat ( utils_str_itoa ( account_nb ), ":",
+                        utils_str_itoa ( div_number ), NULL );
+
+    if ( ( shd = g_hash_table_lookup ( bet_hist_div_list, key ) ) )
+    {
+        return g_hash_table_size ( shd -> sub_div_list );
+    }
+    else
+        return 0;
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
 gsb_real bet_data_get_div_amount ( gint account_nb, gint div_number, gint sub_div_nb )
 {
     gchar *key;
@@ -668,7 +697,7 @@
                         shd -> account_nb,
                         shd -> div_number,
                         shd -> div_edited,
-                        gsb_real_get_string ( shd -> amount ),
+                        gsb_real_save_real_to_string ( shd -> amount, 2 ),
                         sub_shd -> div_number,
                         sub_shd -> div_edited,
                         gsb_real_save_real_to_string ( sub_shd -> amount, 2 ) );

Index: balance_estimate_hist.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_hist.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- balance_estimate_hist.c	23 Feb 2010 21:36:45 -0000	1.7
+++ balance_estimate_hist.c	25 Feb 2010 21:38:17 -0000	1.8
@@ -64,6 +64,8 @@
 /*END_INCLUDE*/
 
 /*START_STATIC*/
+static gboolean bet_historical_amount_differ_average ( GtkTreeModel *model,
+                        GtkTreeIter *iter );
 static void bet_historical_div_cell_edited (GtkCellRendererText *cell,
                         const gchar *path_string,
                         const gchar *new_text,
@@ -328,9 +330,10 @@
 {
     GtkTreeIter iter;
 
-    //~ devel_debug (path_string);
+    devel_debug (path_string);
     if ( gtk_tree_model_get_iter_from_string ( GTK_TREE_MODEL ( model ), &iter, path_string ) )
     {
+        GtkTreeView *tree_view;
         gchar *str_amount;
         gchar *str_average;
         gint div;
@@ -373,52 +376,50 @@
             gint i = 0;
             GtkTreeIter fils_iter;
 
-            while ( gtk_tree_model_iter_nth_child ( GTK_TREE_MODEL ( model ),
-                        &fils_iter, &iter, i ) )
+            if ( valeur == 1 )
             {
-                gtk_tree_model_get ( GTK_TREE_MODEL ( model ), &fils_iter,
-                                SPP_HISTORICAL_AVERAGE_COLUMN, &str_average,
-                                SPP_HISTORICAL_AVERAGE_AMOUNT, &str_amount,
-                                SPP_HISTORICAL_DIV_NUMBER, &div,
-                                SPP_HISTORICAL_SUB_DIV_NUMBER, &sub_div,
-                                -1 );
-                if ( valeur == 1 )
-                {
-                    bet_data_add_div_hist ( account_nb, div, sub_div );
-                    bet_data_set_div_edited ( account_nb, div, sub_div, FALSE );
-                    gtk_tree_store_set ( GTK_TREE_STORE ( model ), &fils_iter,
-                                SPP_HISTORICAL_SELECT_COLUMN, TRUE,
-                                SPP_HISTORICAL_RETAINED_COLUMN, str_average,
-                                
-                                -1 );
-                }
-                else
+                tree_view = g_object_get_data ( G_OBJECT ( bet_container ),
+                                "bet_historical_treeview" );
+                gtk_tree_view_collapse_row ( tree_view,
+                                gtk_tree_model_get_path ( model, &iter ) );
+                gtk_tree_selection_select_iter ( gtk_tree_view_get_selection (
+                                tree_view ), &iter );
+            }
+            else
+            {
+                while ( gtk_tree_model_iter_nth_child ( GTK_TREE_MODEL ( model ),
+                            &fils_iter, &iter, i ) )
                 {
-                    bet_data_remove_div_hist ( account_nb, div, sub_div );
-                    gtk_tree_store_set ( GTK_TREE_STORE ( model ), &fils_iter,
-                                SPP_HISTORICAL_SELECT_COLUMN, FALSE,
-                                SPP_HISTORICAL_RETAINED_COLUMN, "",
-                                SPP_HISTORICAL_RETAINED_AMOUNT, str_amount,
-                                -1 );
+                    gtk_tree_model_get ( GTK_TREE_MODEL ( model ), &fils_iter,
+                                    SPP_HISTORICAL_AVERAGE_AMOUNT, &str_amount,
+                                    SPP_HISTORICAL_SUB_DIV_NUMBER, &sub_div,
+                                    -1 );
+                        bet_data_remove_div_hist ( account_nb, div, sub_div );
+                        gtk_tree_store_set ( GTK_TREE_STORE ( model ), &fils_iter,
+                                    SPP_HISTORICAL_SELECT_COLUMN, FALSE,
+                                    SPP_HISTORICAL_RETAINED_COLUMN, "",
+                                    SPP_HISTORICAL_RETAINED_AMOUNT, str_amount,
+                                    -1 );
+                    i++;
                 }
-                i++;
             }
         }
         else
         {
-            GtkTreeView *tree_view;
             GtkTreeIter parent;
-            gsb_real average;
+            gsb_real amount;
 
             if ( gtk_tree_model_iter_parent ( GTK_TREE_MODEL ( model ), &parent, &iter ) )
             {
                 if ( bet_historical_get_full_div ( model, &parent ) )
                 {
-                    average = bet_historical_get_children_amount ( model, &parent );
-                    str_amount = gsb_real_get_string ( average );
+                    amount = bet_historical_get_children_amount ( model, &parent );
+                    if ( str_amount )
+                        g_free ( str_amount );
+                    str_amount = gsb_real_save_real_to_string ( amount, 2 );
                     if ( str_average )
                         g_free ( str_average );
-                    str_average = gsb_real_get_string_with_currency ( average,
+                    str_average = gsb_real_get_string_with_currency ( amount,
                                 gsb_data_account_get_currency ( account_nb ), TRUE );
                     gtk_tree_store_set ( GTK_TREE_STORE ( model ),
                                 &parent,
@@ -426,6 +427,12 @@
                                 SPP_HISTORICAL_RETAINED_COLUMN, str_average,
                                 SPP_HISTORICAL_RETAINED_AMOUNT, str_amount,
                                 -1);
+                    if ( bet_historical_amount_differ_average ( model, &parent) )
+                    {
+                        bet_data_set_div_edited  ( account_nb, div, 0, TRUE );
+                        bet_data_set_div_amount ( account_nb, div, 0, amount );
+                    }
+                        
                     tree_view = g_object_get_data ( G_OBJECT ( bet_container ),
                                 "bet_historical_treeview" );
                     gtk_tree_view_collapse_row ( tree_view,
@@ -509,6 +516,9 @@
         number = gsb_real_get_from_string ( new_text );
         currency_number = gsb_data_account_get_currency ( account_nb );
         tmp_str = gsb_real_get_string_with_currency ( number, currency_number, TRUE );
+printf ("div = %d sub_div = %d tmp_str = %s\n", div, sub_div, tmp_str);
+        if ( bet_data_search_div_hist ( account_nb, div, sub_div ) == FALSE )
+            bet_data_add_div_hist ( account_nb, div, sub_div );
 
         bet_data_set_div_edited  ( account_nb, div, sub_div, TRUE );
         bet_data_set_div_amount ( account_nb, div, sub_div, number );
@@ -523,7 +533,9 @@
             if ( bet_historical_get_full_div ( model, &parent ) )
             {
                 number = bet_historical_get_children_amount ( model, &parent );
-                str_amount = gsb_real_get_string ( number );
+                bet_data_set_div_edited  ( account_nb, div, sub_div, TRUE );
+                bet_data_set_div_amount ( account_nb, div, 0, number );
+                str_amount = gsb_real_save_real_to_string ( number, 2 );
                 if ( tmp_str )
                     g_free ( tmp_str );
                 tmp_str = gsb_real_get_string_with_currency ( number,
@@ -536,6 +548,11 @@
                             -1);
             }
         }
+        else
+        {
+
+
+        }
         bet_array_refresh_estimate_tab ( );
     }
 
@@ -836,14 +853,15 @@
     gchar *str_average;
     gchar *str_amount;
     gchar *titre;
-    gint div;
+    gint div_number;
     gint account_nb;
     gsb_real period = { 12, 0 };
     gsb_real average;
+    gboolean div_edited = FALSE;
     gboolean sub_div_visible = FALSE;
-
-    div = sh -> div;
-    div_name = bet_data_get_div_name ( div, 0, FALSE );
+devel_debug ("bet_historical_populate_div_model");
+    div_number = sh -> div;
+    div_name = bet_data_get_div_name ( div_number, 0, FALSE );
     account_nb = bet_parameter_get_account_selected ( );
 
     titre = g_object_get_data ( G_OBJECT ( bet_container ), "bet_historical_period" );
@@ -853,7 +871,7 @@
     str_balance = gsb_real_get_string_with_currency ( sbr -> current_balance, 
                         gsb_data_account_get_currency ( account_nb ), TRUE );
     average = gsb_real_div ( sbr -> current_balance, period );
-    str_amount = gsb_real_get_string ( average );
+    str_amount = gsb_real_save_real_to_string ( average, 2 );
     str_average = gsb_real_get_string_with_currency ( average,
                         gsb_data_account_get_currency ( account_nb ), TRUE );
 
@@ -867,38 +885,30 @@
                         SPP_HISTORICAL_AVERAGE_AMOUNT, str_amount,
                         SPP_HISTORICAL_RETAINED_AMOUNT, str_amount,
                         SPP_HISTORICAL_ACCOUNT_NUMBER, account_nb,
-                        SPP_HISTORICAL_DIV_NUMBER, div,
+                        SPP_HISTORICAL_DIV_NUMBER, div_number,
                         SPP_HISTORICAL_SUB_DIV_NUMBER, 0,
                         -1);
 
-    if ( g_hash_table_size ( sh -> list_sub_div ) <= 1 )
+    if ( bet_data_search_div_hist ( account_nb, div_number, 0 ) )
     {
-        if ( bet_data_search_div_hist ( account_nb, div, 0 ) )
+        if ( bet_data_get_div_edited ( account_nb, div_number, 0 ) )
         {
-            if ( bet_data_get_div_edited ( account_nb, div, 0 ) )
-            {
-                average = bet_data_get_div_amount ( account_nb, div, 0 );
-                if ( str_amount )
-                    g_free ( str_amount );
-                str_amount = gsb_real_get_string ( average );
-                if ( str_average )
-                    g_free ( str_average );
-                str_average = gsb_real_get_string_with_currency ( average,
-                                gsb_data_account_get_currency ( sh -> account_nb ), TRUE );
-            }
-            gtk_tree_store_set ( GTK_TREE_STORE ( model ),
-                            &parent,
-                            SPP_HISTORICAL_SELECT_COLUMN, TRUE,
-                            SPP_HISTORICAL_RETAINED_COLUMN, str_average,
-                            SPP_HISTORICAL_RETAINED_AMOUNT, str_amount,
-                            -1);
+            div_edited = TRUE;
+            average = bet_data_get_div_amount ( account_nb, div_number, 0 );
+            if ( str_amount )
+                g_free ( str_amount );
+            str_amount =gsb_real_save_real_to_string ( average, 2 );
+            if ( str_average )
+                g_free ( str_average );
+            str_average = gsb_real_get_string_with_currency ( average,
+                            gsb_data_account_get_currency ( sh -> account_nb ), TRUE );
         }
-        g_free ( div_name );
-        g_free ( str_balance );
-        g_free ( str_average );
-        g_free ( str_amount );
-
-        return;
+        gtk_tree_store_set ( GTK_TREE_STORE ( model ),
+                        &parent,
+                        SPP_HISTORICAL_SELECT_COLUMN, TRUE,
+                        SPP_HISTORICAL_RETAINED_COLUMN, str_average,
+                        SPP_HISTORICAL_RETAINED_AMOUNT, str_amount,
+                        -1);
     }
 
     g_free ( div_name );
@@ -906,6 +916,9 @@
     g_free ( str_average );
     g_free ( str_amount );
 
+    if ( g_hash_table_size ( sh -> list_sub_div ) <= 1 )
+        return;
+
     g_hash_table_iter_init ( &iter, sh -> list_sub_div );
     while ( g_hash_table_iter_next ( &iter, &sub_key, &sub_value ) ) 
     {
@@ -914,7 +927,7 @@
         GtkTreeIter fils;
         gchar **tab_str = NULL;
 
-        div_name = bet_data_get_div_name ( div, sub_sh -> div, FALSE );
+        div_name = bet_data_get_div_name ( div_number, sub_sh -> div, FALSE );
         if ( g_utf8_strrchr ( div_name, -1, ':' ) )
         {
 	        tab_str = g_strsplit ( div_name, ":", 2 );
@@ -927,7 +940,7 @@
         str_balance = gsb_real_get_string_with_currency ( sub_sbr -> current_balance, 
                         gsb_data_account_get_currency ( sh -> account_nb ), TRUE );
         average = gsb_real_div ( sub_sbr -> current_balance, period );
-        str_amount = gsb_real_get_string ( average );
+        str_amount = gsb_real_save_real_to_string ( average, 2 );
         str_average = gsb_real_get_string_with_currency ( average,
                         gsb_data_account_get_currency ( sh -> account_nb ), TRUE );
 
@@ -940,18 +953,19 @@
                         SPP_HISTORICAL_AVERAGE_AMOUNT, str_amount,
                         SPP_HISTORICAL_RETAINED_AMOUNT, str_amount,
                         SPP_HISTORICAL_ACCOUNT_NUMBER, account_nb,
-                        SPP_HISTORICAL_DIV_NUMBER, div,
+                        SPP_HISTORICAL_DIV_NUMBER, div_number,
                         SPP_HISTORICAL_SUB_DIV_NUMBER, sub_sh -> div,
                         -1);
-        if ( bet_data_search_div_hist ( account_nb, div, sub_sh -> div ) )
+
+        if ( bet_data_search_div_hist ( account_nb, div_number, sub_sh -> div ) )
         {
-            if ( bet_data_get_div_edited ( account_nb, div, sub_sh -> div ) )
+            //~ printf ("account_nb = %d div_number = %d sub_sh -> div = %d\n", account_nb, div_number, sub_sh -> div );
+            if ( bet_data_get_div_edited ( account_nb, div_number, sub_sh -> div ) )
             {
-                average = bet_data_get_div_amount ( account_nb, div, sub_sh -> div );
+                average = bet_data_get_div_amount ( account_nb, div_number, sub_sh -> div );
                 if ( str_amount )
                     g_free ( str_amount );
-                str_amount = gsb_real_get_string ( average );
-                //~ printf ("str_amount = %s\n", str_amount );
+                str_amount = gsb_real_save_real_to_string ( average, 2 );
                 if ( str_average )
                     g_free ( str_average );
                 str_average = gsb_real_get_string_with_currency ( average,
@@ -974,20 +988,20 @@
 
     if ( sub_div_visible && bet_historical_get_full_div ( model, &parent ) )
     {
-            average = bet_historical_get_children_amount ( model, &parent );
-            if ( str_amount )
-                g_free ( str_amount );
-            str_amount = gsb_real_get_string ( average );
-            if ( str_average )
-                g_free ( str_average );
-            str_average = gsb_real_get_string_with_currency ( average,
-                        gsb_data_account_get_currency ( account_nb ), TRUE );
-            gtk_tree_store_set ( GTK_TREE_STORE ( model ),
-                        &parent,
-                        SPP_HISTORICAL_SELECT_COLUMN, TRUE,
-                        SPP_HISTORICAL_RETAINED_COLUMN, str_average,
-                        SPP_HISTORICAL_RETAINED_AMOUNT, str_amount,
-                        -1);
+        //~ average = bet_historical_get_children_amount ( model, &parent );
+        //~ if ( str_amount )
+            //~ g_free ( str_amount );
+        //~ str_amount = gsb_real_save_real_to_string ( average, 2 );
+        //~ if ( str_average )
+            //~ g_free ( str_average );
+        //~ str_average = gsb_real_get_string_with_currency ( average,
+                    //~ gsb_data_account_get_currency ( account_nb ), TRUE );
+        //~ gtk_tree_store_set ( GTK_TREE_STORE ( model ),
+                        //~ &parent,
+                        //~ SPP_HISTORICAL_SELECT_COLUMN, TRUE,
+                        //~ SPP_HISTORICAL_RETAINED_COLUMN, str_average,
+                        //~ SPP_HISTORICAL_RETAINED_AMOUNT, str_amount,
+                        //~ -1);
         gtk_tree_view_collapse_row ( tree_view, gtk_tree_model_get_path ( model, &parent ) );
         gtk_tree_selection_select_iter ( gtk_tree_view_get_selection ( tree_view ), &parent );
     }
@@ -1188,18 +1202,45 @@
                         GtkTreePath *path,
                         GtkTreeModel *model )
 {
-    gboolean valeur;
+    gint account_nb;
+    gint div_number;
 
     gtk_tree_model_get ( GTK_TREE_MODEL ( model ), iter,
-                        SPP_HISTORICAL_SELECT_COLUMN, &valeur,
+                        SPP_HISTORICAL_ACCOUNT_NUMBER, &account_nb,
+                        SPP_HISTORICAL_DIV_NUMBER, &div_number,
                         -1 );
 
-    if ( valeur == 1 )
+    if ( bet_data_get_div_edited ( account_nb, div_number, 0 ) == TRUE
+     &&
+     bet_historical_get_full_div ( model, iter ) == FALSE )
     {
         gtk_tree_view_collapse_row ( tree_view, path );
         gtk_tree_selection_select_iter ( gtk_tree_view_get_selection ( tree_view ), iter );
     }
 }
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+gboolean bet_historical_amount_differ_average ( GtkTreeModel *model,
+                        GtkTreeIter *iter )
+{
+    gchar *str_average;
+    gchar *str_amount;
+    
+    gtk_tree_model_get ( GTK_TREE_MODEL ( model ), iter,
+                        SPP_HISTORICAL_AVERAGE_AMOUNT, &str_average,
+                        SPP_HISTORICAL_RETAINED_AMOUNT, &str_amount,
+                        -1 );
+    printf ("str_average = %s str_amount = %s\n", str_average, str_amount);
+
+    return gsb_real_cmp ( gsb_real_get_from_string ( str_average ),
+                        gsb_real_get_from_string ( str_amount ) );
+}
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */



More information about the cvs mailing list