[grisbi-cvs] grisbi/src balance_estimate_data.c, 1.7, 1.8 balance_estimate_data.h, 1.6, 1.7 balance_estimate_hist.c, 1.4, 1.5 gsb_file_load.c, 1.207, 1.208 gsb_transactions_list.c, 1.196, 1.197

Pierre Biava pbiava at users.sourceforge.net
Sun Feb 21 21:48:41 CET 2010


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

Modified Files:
	balance_estimate_data.c balance_estimate_data.h 
	balance_estimate_hist.c gsb_file_load.c 
	gsb_transactions_list.c 
Log Message:
corrections of historical part for the budget module

Index: gsb_transactions_list.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_transactions_list.c,v
retrieving revision 1.196
retrieving revision 1.197
diff -u -d -r1.196 -r1.197
--- gsb_transactions_list.c	20 Feb 2010 08:54:00 -0000	1.196
+++ gsb_transactions_list.c	21 Feb 2010 20:48:39 -0000	1.197
@@ -1267,13 +1267,13 @@
     case GDK_Up :       /* touches flèche haut */
     case GDK_KP_Up :
 
-        transaction_list_select_up (TRUE);
+        transaction_list_select_up (FALSE);
         break;
 
     case GDK_Down :     /* touches flèche bas */
     case GDK_KP_Down :
 
-        transaction_list_select_down (TRUE);
+        transaction_list_select_down (FALSE);
         break;
 
     case GDK_Delete:    /*  del  */

Index: balance_estimate_data.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_data.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- balance_estimate_data.c	21 Feb 2010 12:30:16 -0000	1.7
+++ balance_estimate_data.c	21 Feb 2010 20:48:38 -0000	1.8
@@ -101,8 +101,7 @@
  * */
 gboolean bet_data_add_div_hist ( gint account_nb,
                         gint div_number,
-                        gint sub_div_nb,
-                        gsb_real amount )
+                        gint sub_div_nb )
 {
     gchar *key;
     gchar *sub_key;
@@ -116,6 +115,9 @@
 
     if ( ( shd = g_hash_table_lookup ( bet_hist_div_list, key ) ) )
     {
+        shd -> div_edited = FALSE;
+        shd -> amount = null_real;
+
         if ( sub_div_nb > 0 )
         {
             sub_key = utils_str_itoa ( sub_div_nb );
@@ -130,9 +132,13 @@
                     return FALSE;
                 }
                 sub_shd -> div_number = sub_div_nb;
-                sub_shd -> amount = amount;
                 g_hash_table_insert ( shd -> sub_div_list, sub_key, sub_shd );
             }
+            else
+            {
+                shd -> div_edited = FALSE;
+                shd -> amount = null_real;
+            }
         }
     }
     else
@@ -157,7 +163,6 @@
             }
             sub_key = utils_str_itoa ( sub_div_nb );
             sub_shd -> div_number = sub_div_nb;
-            sub_shd -> amount = amount;
             g_hash_table_insert ( shd -> sub_div_list, sub_key, sub_shd );
         }
         g_hash_table_insert ( bet_hist_div_list, key, shd );
@@ -187,7 +192,6 @@
 
     if ( ( tmp_shd = g_hash_table_lookup ( bet_hist_div_list, key ) ) )
     {
-        tmp_shd -> div_full = shd -> div_full;
         tmp_shd -> div_edited = shd -> div_edited;
         tmp_shd -> amount = shd -> amount;
 
@@ -526,54 +530,6 @@
  *
  *
  * */
-gboolean bet_data_get_div_full ( 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 shd -> div_full;
-    else
-        return FALSE;
-}
-
-
-/**
- *
- *
- *
- *
- * */
-gboolean bet_data_set_div_full ( gint account_nb, gint div_number, gboolean full )
-{
-    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 ) ) )
-        shd -> div_full = full;
-
-    return FALSE;
-}
-
-
-/**
- *
- *
- *
- *
- * */
 gint bet_data_get_selected_currency ( void )
 {
     gint selected_account;
@@ -684,12 +640,11 @@
         if ( g_hash_table_size ( shd -> sub_div_list ) == 0 )
         {
             tmp_str = g_markup_printf_escaped ( "\t<Bet_historical Nb=\"%d\" Ac=\"%d\" "
-                        "Div=\"%d\"  Full=\"%d\" Edit=\"%d\" Damount=\"%s\" SDiv=\"%d\" "
+                        "Div=\"%d\" Edit=\"%d\" Damount=\"%s\" SDiv=\"%d\" "
                         "SEdit=\"%d\" SDamount=\"%s\" />\n",
                         tab -> len + 1,
                         shd -> account_nb,
                         shd -> div_number,
-                        shd -> div_full,
                         shd -> div_edited,
                         gsb_real_save_real_to_string ( shd -> amount, 2 ),
                         0, 0, "0.00" );
@@ -707,12 +662,11 @@
                 struct_hist_div *sub_shd = ( struct_hist_div* ) value;
 
                 tmp_str = g_markup_printf_escaped ( "\t<Bet_historical Nb=\"%d\" Ac=\"%d\" "
-                        "Div=\"%d\"  Full=\"%d\" Edit=\"%d\" Damount=\"%s\" SDiv=\"%d\" "
+                        "Div=\"%d\" Edit=\"%d\" Damount=\"%s\" SDiv=\"%d\" "
                         "SEdit=\"%d\" SDamount=\"%s\" />\n",
                         tab -> len + 1,
                         shd -> account_nb,
                         shd -> div_number,
-                        shd -> div_full,
                         shd -> div_edited,
                         gsb_real_get_string ( shd -> amount ),
                         sub_shd -> div_number,
@@ -857,13 +811,12 @@
     shd = g_malloc ( sizeof ( struct_hist_div ) );
     shd -> account_nb = 0;
     shd -> div_number = 0;
-    shd -> div_full = FALSE;
     shd -> div_edited = FALSE;
+    shd -> amount = null_real;
     shd -> sub_div_list = g_hash_table_new_full ( g_str_hash,
                         g_str_equal,
                         (GDestroyNotify) g_free,
                         (GDestroyNotify) free_struct_hist_div );
-    shd -> amount = null_real;
 
     return shd;
 }

Index: balance_estimate_hist.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_hist.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- balance_estimate_hist.c	21 Feb 2010 12:30:16 -0000	1.4
+++ balance_estimate_hist.c	21 Feb 2010 20:48:38 -0000	1.5
@@ -75,8 +75,9 @@
 static gboolean bet_historical_div_toggle_clicked ( GtkCellRendererToggle *renderer,
                         gchar *path_string,
                         GtkTreeModel *store );
+gsb_real bet_historical_get_children_amount ( GtkTreeModel *model, GtkTreeIter *parent );
 static GtkWidget *bet_historical_get_data ( GtkWidget *container );
-static gboolean bet_historical_get_full_div ( gint account_nb, gint div_number );
+static gboolean bet_historical_get_full_div ( GtkTreeModel *model, GtkTreeIter *parent );
 static void bet_historical_populate_div_model ( gpointer key,
                         gpointer value,
                         gpointer user_data);
@@ -314,27 +315,25 @@
  * */
 gboolean bet_historical_div_toggle_clicked ( GtkCellRendererToggle *renderer,
                         gchar *path_string,
-                        GtkTreeModel *store )
+                        GtkTreeModel *model )
 {
     GtkTreeIter iter;
 
     //~ devel_debug (path_string);
-    if ( gtk_tree_model_get_iter_from_string ( GTK_TREE_MODEL ( store ), &iter, path_string ) )
+    if ( gtk_tree_model_get_iter_from_string ( GTK_TREE_MODEL ( model ), &iter, path_string ) )
     {
-        gchar *tmp_str;
-        gchar *str_average;
         gchar *str_amount;
+        gchar *str_average;
         gint div;
         gint sub_div;
         gint nbre_fils;
         gint account_nb;
         gboolean valeur;
 
-        gtk_tree_model_get ( GTK_TREE_MODEL ( store ), &iter,
+        gtk_tree_model_get ( GTK_TREE_MODEL ( model ), &iter,
                         SPP_HISTORICAL_SELECT_COLUMN, &valeur,
-                        SPP_HISTORICAL_AVERAGE_COLUMN, &tmp_str,
-                        SPP_HISTORICAL_AVERAGE_AMOUNT, &str_average,
-                        SPP_HISTORICAL_RETAINED_AMOUNT, &str_amount,
+                        SPP_HISTORICAL_AVERAGE_COLUMN, &str_average,
+                        SPP_HISTORICAL_AVERAGE_AMOUNT, &str_amount,
                         SPP_HISTORICAL_ACCOUNT_NUMBER, &account_nb,
                         SPP_HISTORICAL_DIV_NUMBER, &div,
                         SPP_HISTORICAL_SUB_DIV_NUMBER, &sub_div,
@@ -342,64 +341,55 @@
         valeur = 1 - valeur;
         if ( valeur == 1 )
         {
-            bet_data_add_div_hist ( account_nb,
-                        div,
-                        sub_div,
-                        gsb_real_get_from_string ( str_amount ) );
-            gtk_tree_store_set ( GTK_TREE_STORE ( store ), &iter,
+            bet_data_add_div_hist ( account_nb, div, sub_div );
+            gtk_tree_store_set ( GTK_TREE_STORE ( model ), &iter,
                         SPP_HISTORICAL_SELECT_COLUMN, 1,
-                        SPP_HISTORICAL_RETAINED_COLUMN, tmp_str,
+                        SPP_HISTORICAL_RETAINED_COLUMN, str_average,
+                        SPP_HISTORICAL_RETAINED_AMOUNT, str_amount,
                         -1 );
         }
         else
         {
-            //~ printf ("str_amount = %s str_average = %s\n", str_amount, str_average);
             bet_data_remove_div_hist ( account_nb, div, sub_div );
-            gtk_tree_store_set ( GTK_TREE_STORE ( store ), &iter,
+            gtk_tree_store_set ( GTK_TREE_STORE ( model ), &iter,
                         SPP_HISTORICAL_SELECT_COLUMN, 0,
                         SPP_HISTORICAL_RETAINED_COLUMN, "",
-                        SPP_HISTORICAL_RETAINED_AMOUNT, str_average,
+                        SPP_HISTORICAL_RETAINED_AMOUNT, str_amount
                         -1 );
         }
 
-        nbre_fils = gtk_tree_model_iter_n_children ( GTK_TREE_MODEL ( store ), &iter );
+        nbre_fils = gtk_tree_model_iter_n_children ( GTK_TREE_MODEL ( model ), &iter );
         if ( nbre_fils > 0 )
         {
             gint i = 0;
             GtkTreeIter fils_iter;
 
-            while ( gtk_tree_model_iter_nth_child ( GTK_TREE_MODEL ( store ),
+            while ( gtk_tree_model_iter_nth_child ( GTK_TREE_MODEL ( model ),
                         &fils_iter, &iter, i ) )
             {
-                gtk_tree_model_get ( GTK_TREE_MODEL ( store ), &fils_iter,
-                                SPP_HISTORICAL_AVERAGE_COLUMN, &tmp_str,
-                                SPP_HISTORICAL_AVERAGE_AMOUNT, &str_average,
-                                SPP_HISTORICAL_RETAINED_AMOUNT, &str_amount,
+                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 )
                 {
-                    //~ printf ("str_amount = %s\n", str_amount);
-                    bet_data_add_div_hist ( account_nb,
-                                div,
-                                sub_div,
-                                gsb_real_get_from_string ( str_amount ) );
-                    bet_data_set_div_full ( account_nb, div, TRUE );
+                    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 ( store ), &fils_iter,
+                    gtk_tree_store_set ( GTK_TREE_STORE ( model ), &fils_iter,
                                 SPP_HISTORICAL_SELECT_COLUMN, TRUE,
-                                SPP_HISTORICAL_RETAINED_COLUMN, tmp_str,
+                                SPP_HISTORICAL_RETAINED_COLUMN, str_average,
+                                
                                 -1 );
                 }
                 else
                 {
-                    bet_data_set_div_full ( account_nb, div, FALSE );
                     bet_data_remove_div_hist ( account_nb, div, sub_div );
-                    gtk_tree_store_set ( GTK_TREE_STORE ( store ), &fils_iter,
+                    gtk_tree_store_set ( GTK_TREE_STORE ( model ), &fils_iter,
                                 SPP_HISTORICAL_SELECT_COLUMN, FALSE,
                                 SPP_HISTORICAL_RETAINED_COLUMN, "",
-                                SPP_HISTORICAL_RETAINED_AMOUNT, str_average,
+                                SPP_HISTORICAL_RETAINED_AMOUNT, str_amount,
                                 -1 );
                 }
                 i++;
@@ -407,60 +397,36 @@
         }
         else
         {
+            GtkTreeView *tree_view;
             GtkTreeIter parent;
-            gboolean fils_val;
-            gboolean test = TRUE;
-            gint i = 0;
-            gsb_real balance = null_real;
+            gsb_real average;
 
-            if ( gtk_tree_model_iter_parent ( GTK_TREE_MODEL ( store ), &parent, &iter ) )
+            if ( gtk_tree_model_iter_parent ( GTK_TREE_MODEL ( model ), &parent, &iter ) )
             {
-                while ( gtk_tree_model_iter_nth_child ( GTK_TREE_MODEL ( store ),
-                        &iter, &parent, i ) )
-                {
-                    gtk_tree_model_get ( GTK_TREE_MODEL ( store ), &iter,
-                                SPP_HISTORICAL_SELECT_COLUMN, &fils_val,
-                                SPP_HISTORICAL_RETAINED_AMOUNT, &str_amount,
-                                -1 );
-                    if ( fils_val != valeur )
-                    {
-                        test = FALSE;
-                        break;
-                    }
-                    if ( valeur == 1 )
-                    {
-                        balance = gsb_real_add ( balance,
-                                gsb_real_get_from_string ( str_amount ) );
-                    }
-                    i++;
-                }
-                if ( test == TRUE )
+                if ( bet_historical_get_full_div ( model, &parent ) )
                 {
-                    gtk_tree_store_set ( GTK_TREE_STORE ( store ), &parent,
-                                SPP_HISTORICAL_SELECT_COLUMN, valeur, -1 );
-                    if ( valeur == 1 )
-                    {
-                        GtkTreeView *tree_view;
-
-                        tree_view = g_object_get_data ( G_OBJECT ( bet_container ),
-                                "bet_historical_treeview" );
-                        tmp_str = gsb_real_get_string_with_currency ( balance,
-                                bet_data_get_selected_currency ( ), TRUE );
-                        bet_data_set_div_full ( account_nb, div, TRUE );
-                        gtk_tree_store_set ( GTK_TREE_STORE ( store ), &parent,
+                    average = bet_historical_get_children_amount ( model, &parent );
+                    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, tmp_str,
-                                -1 );
-                        gtk_tree_view_collapse_row ( tree_view,
-                                gtk_tree_model_get_path ( store, &parent ) );
-                        gtk_tree_selection_select_iter ( gtk_tree_view_get_selection (
+                                SPP_HISTORICAL_RETAINED_COLUMN, str_average,
+                                SPP_HISTORICAL_RETAINED_AMOUNT, str_amount,
+                                -1);
+                    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, &parent ) );
+                    gtk_tree_selection_select_iter ( gtk_tree_view_get_selection (
                                 tree_view ), &parent );
-                    }
                 }
                 else
                 {
-                    bet_data_set_div_full ( account_nb, div, FALSE );
-                    gtk_tree_store_set ( GTK_TREE_STORE ( store ), &parent,
+                    gtk_tree_store_set ( GTK_TREE_STORE ( model ), &parent,
                                 SPP_HISTORICAL_SELECT_COLUMN, FALSE,
                                 SPP_HISTORICAL_RETAINED_COLUMN, "",
                                 -1 );
@@ -510,46 +476,57 @@
     GtkTreeModel *model;
     GtkTreeIter iter;
 
-    //~ devel_debug (NULL);
+    devel_debug (new_text);
     model = gtk_tree_view_get_model ( GTK_TREE_VIEW ( tree_view ) );
     if ( gtk_tree_model_get_iter_from_string ( GTK_TREE_MODEL ( model ), &iter, path_string ) )
     {
+        GtkTreeIter parent;
         gboolean valeur;
-        gint selected_account;
+        gint account_nb;
         gint currency_number;
         gint div;
         gint sub_div;
         gchar *tmp_str;
+        gchar *str_amount;
         gsb_real 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,
                         SPP_HISTORICAL_SUB_DIV_NUMBER, &sub_div,
                         -1 );
 
-        /* find the selected account */
-        selected_account = bet_parameter_get_account_selected ( );
-        if ( selected_account == -1 )
-            return;
-
-        if ( valeur == FALSE )
-        {
-            bet_data_set_div_edited  ( selected_account, div, sub_div, FALSE );
-            return;
-        }
-
         number = gsb_real_get_from_string ( new_text );
-        currency_number = gsb_data_account_get_currency ( selected_account );
+        currency_number = gsb_data_account_get_currency ( account_nb );
         tmp_str = gsb_real_get_string_with_currency ( number, currency_number, TRUE );
 
-        bet_data_set_div_edited  ( selected_account, div, sub_div, TRUE );
-        bet_data_set_div_amount ( selected_account, div, sub_div, number );
+        bet_data_set_div_edited  ( account_nb, div, sub_div, TRUE );
+        bet_data_set_div_amount ( account_nb, div, sub_div, number );
         gtk_tree_store_set ( GTK_TREE_STORE ( model ), &iter,
+                            SPP_HISTORICAL_SELECT_COLUMN, TRUE,
                             SPP_HISTORICAL_RETAINED_COLUMN, tmp_str,
                             SPP_HISTORICAL_RETAINED_AMOUNT, new_text,
                             -1 );
 
+        if ( gtk_tree_model_iter_parent ( GTK_TREE_MODEL ( model ), &parent, &iter ) )
+        {
+            if ( bet_historical_get_full_div ( model, &parent ) )
+            {
+                number = bet_historical_get_children_amount ( model, &parent );
+                str_amount = gsb_real_get_string ( number );
+                if ( tmp_str )
+                    g_free ( tmp_str );
+                tmp_str = gsb_real_get_string_with_currency ( number,
+                            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, tmp_str,
+                            SPP_HISTORICAL_RETAINED_AMOUNT, str_amount,
+                            -1);
+            }
+        }
         bet_array_refresh_estimate_tab ( );
     }
 
@@ -858,10 +835,11 @@
     titre = g_object_get_data ( G_OBJECT ( bet_container ), "bet_historical_period" );
 
     model = gtk_tree_view_get_model ( tree_view );
-    average = gsb_real_div ( sbr -> current_balance, period );
-    str_amount = gsb_real_get_string ( average );
+
     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_average = gsb_real_get_string_with_currency ( average,
                         gsb_data_account_get_currency ( account_nb ), TRUE );
 
@@ -932,10 +910,10 @@
                 g_strfreev ( tab_str );
         }
 
-        average = gsb_real_div ( sub_sbr -> current_balance, period );
-        str_amount = gsb_real_get_string ( average );
         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_average = gsb_real_get_string_with_currency ( average,
                         gsb_data_account_get_currency ( sh -> account_nb ), TRUE );
 
@@ -943,7 +921,6 @@
         gtk_tree_store_set ( GTK_TREE_STORE ( model ),
                         &fils,
                         SPP_HISTORICAL_DESC_COLUMN, div_name,
-                        SPP_HISTORICAL_PERIOD_COLUMN, titre,
                         SPP_HISTORICAL_BALANCE_COLUMN, str_balance,
                         SPP_HISTORICAL_AVERAGE_COLUMN, str_average,
                         SPP_HISTORICAL_AVERAGE_AMOUNT, str_amount,
@@ -960,6 +937,7 @@
                 if ( str_amount )
                     g_free ( str_amount );
                 str_amount = gsb_real_get_string ( average );
+                printf ("str_amount = %s\n", str_amount );
                 if ( str_average )
                     g_free ( str_average );
                 str_average = gsb_real_get_string_with_currency ( average,
@@ -980,22 +958,9 @@
         g_free ( str_amount );
     }
 
-    if ( sub_div_visible && bet_historical_get_full_div ( account_nb, div ) )
+    if ( sub_div_visible && bet_historical_get_full_div ( model, &parent ) )
     {
-        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 );
-        }
-        else
-        {
-            average = gsb_real_div ( sbr -> current_balance, period );
+            average = bet_historical_get_children_amount ( model, &parent );
             if ( str_amount )
                 g_free ( str_amount );
             str_amount = gsb_real_get_string ( average );
@@ -1003,7 +968,6 @@
                 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,
@@ -1146,53 +1110,56 @@
  *
  *
  * */
-gboolean bet_historical_get_full_div ( gint account_nb, gint div_number )
+gboolean bet_historical_get_full_div ( GtkTreeModel *model, GtkTreeIter *parent )
 {
-    GtkWidget *tree_view;
-    GtkTreeModel *model;
-    GtkTreeIter iter;
     GtkTreeIter fils_iter;
-    gint account_number;
-    gint div;
-    gboolean valeur;
-
-    tree_view = g_object_get_data ( G_OBJECT ( bet_container ), "bet_historical_treeview" );
-    model = gtk_tree_view_get_model ( GTK_TREE_VIEW ( tree_view ) );
+    gint valeur;
 
-    if ( gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( model ), &iter ) )
+    if ( gtk_tree_model_iter_children ( GTK_TREE_MODEL ( model ), &fils_iter, parent ) )
     {
         do
         {
-            gtk_tree_model_get ( GTK_TREE_MODEL ( model ), &iter,
+            gtk_tree_model_get ( GTK_TREE_MODEL ( model ), &fils_iter,
                         SPP_HISTORICAL_SELECT_COLUMN, &valeur,
-                        SPP_HISTORICAL_ACCOUNT_NUMBER, &account_number,
-                        SPP_HISTORICAL_DIV_NUMBER, &div,
                         -1 );
-            if ( account_nb == account_number && div == div_number )
-            {
-                if ( gtk_tree_model_iter_children ( GTK_TREE_MODEL ( model ), &fils_iter, &iter ) )
-                {
-                    do
-                    {
-                        gtk_tree_model_get ( GTK_TREE_MODEL ( model ), &fils_iter,
-                                    SPP_HISTORICAL_SELECT_COLUMN, &valeur,
-                                    -1 );
 
-                        if ( valeur == FALSE )
-                        {
-                            return FALSE;
-                        }
-                    }
-                    while ( gtk_tree_model_iter_next (
-                            GTK_TREE_MODEL ( model ), &fils_iter ) );
-                }
-                return TRUE;
+            if ( valeur == FALSE )
+            {
+                return FALSE;
             }
-            
-        } while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &iter ) );
+        }
+        while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &fils_iter ) );
     }
+    return TRUE;
+}
 
-    return FALSE;
+
+/**
+ *
+ *
+ *
+ *
+ * */
+gsb_real bet_historical_get_children_amount ( GtkTreeModel *model, GtkTreeIter *parent )
+{
+    GtkTreeIter fils_iter;
+    gchar *str_amount;
+    gsb_real amount = null_real;
+
+    if ( gtk_tree_model_iter_children ( GTK_TREE_MODEL ( model ), &fils_iter, parent ) )
+    {
+        do
+        {
+            gtk_tree_model_get ( GTK_TREE_MODEL ( model ), &fils_iter,
+                        SPP_HISTORICAL_RETAINED_AMOUNT, &str_amount,
+                        -1 );
+            amount = gsb_real_add ( amount,
+                                gsb_real_get_from_string ( str_amount ) );
+        }
+        while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &fils_iter ) );
+    }
+
+    return amount;
 }
 
 

Index: gsb_file_load.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_file_load.c,v
retrieving revision 1.207
retrieving revision 1.208
diff -u -d -r1.207 -r1.208
--- gsb_file_load.c	21 Feb 2010 12:30:16 -0000	1.207
+++ gsb_file_load.c	21 Feb 2010 20:48:38 -0000	1.208
@@ -3705,13 +3705,6 @@
         continue;
     }
 
-    if ( !strcmp ( attribute_names[i], "Full" ) )
-    {
-        shd -> div_full = utils_str_atoi ( attribute_values[i] );
-        i++;
-        continue;
-    }
-
     if ( !strcmp ( attribute_names[i], "Edit" ) )
     {
         shd -> div_edited = utils_str_atoi ( attribute_values[i] );

Index: balance_estimate_data.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_data.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- balance_estimate_data.h	21 Feb 2010 12:30:16 -0000	1.6
+++ balance_estimate_data.h	21 Feb 2010 20:48:38 -0000	1.7
@@ -36,7 +36,6 @@
 {
     gint account_nb;
     gint div_number;
-    gboolean div_full;
     gboolean div_edited;
     GHashTable *sub_div_list;
     gsb_real amount;
@@ -46,14 +45,12 @@
 /* START_DECLARATION */
 gboolean bet_data_add_div_hist ( gint account_nb,
                         gint div_number,
-                        gint sub_div_nb,
-                        gsb_real amount );
+                        gint sub_div_nb );
 gsb_real bet_data_get_div_amount ( 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 );
-gboolean bet_data_get_div_full ( gint account_nb, gint div_number );
 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 );
@@ -73,7 +70,6 @@
                         gint div_number,
                         gint sub_div_nb,
                         gboolean edited );
-gboolean bet_data_set_div_full ( gint account_nb, gint div_number, gboolean full );
 gboolean bet_data_set_div_ptr ( gint type_div );
 void bet_data_synchronise_hist_div_list ( GHashTable  *list_div );
 SBR *initialise_struct_bet_range ( void );



More information about the cvs mailing list