[grisbi-cvs] grisbi/src balance_estimate_tab.c, 1.24, 1.25 gsb_data_account.c, 1.93, 1.94 gsb_data_account.h, 1.38, 1.39 gsb_file_load.c, 1.201, 1.202 gsb_file_save.c, 1.144, 1.145 gsb_form.c, 1.142, 1.143 gsb_form_config.c, 1.34, 1.35 gsb_real.c, 1.61, 1.62 main.c, 1.158, 1.159

Pierre Biava pbiava at users.sourceforge.net
Wed Jan 6 23:17:47 CET 2010


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

Modified Files:
	balance_estimate_tab.c gsb_data_account.c gsb_data_account.h 
	gsb_file_load.c gsb_file_save.c gsb_form.c gsb_form_config.c 
	gsb_real.c main.c 
Log Message:
bug fixes of module of budget and the possibility of having one form per account

Index: gsb_form_config.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form_config.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- gsb_form_config.c	16 Dec 2009 21:37:59 -0000	1.34
+++ gsb_form_config.c	6 Jan 2010 22:17:45 -0000	1.35
@@ -71,10 +71,10 @@
 				    gpointer null );
 static gboolean gsb_form_config_remove_column ( void );
 static gboolean gsb_form_config_remove_line ( void );
-static gboolean gsb_form_config_switch_general_to_several_form ( void );
+//~ static gboolean gsb_form_config_switch_general_to_several_form ( void );
 static gboolean gsb_form_config_toggle_element_button ( GtkWidget *toggle_button );
-static  gboolean gsb_form_config_update_accounts ( GtkWidget *button,
-						  GtkWidget *combobox );
+//~ static  gboolean gsb_form_config_update_accounts ( GtkWidget *button,
+						  //~ GtkWidget *combobox );
 static gboolean gsb_form_config_update_form_config ( gint account_number );
 /*END_STATIC*/
 
@@ -98,7 +98,7 @@
 static GtkWidget *accounts_combobox;
 
 /** the button to update all the accounts forms */
-static GtkWidget *update_button;
+//~ static GtkWidget *update_button;
 
 /** the tree view */
 static GtkWidget *form_config_tree_view;
@@ -144,9 +144,9 @@
 {
     GtkWidget *sw;
     GtkWidget *hbox;
-    GtkWidget *button;
+    //~ GtkWidget *button;
     GtkWidget *paddingbox;
-    GtkWidget *label;
+    //~ GtkWidget *label;
 	GtkListStore* list_store;
 
     /* create the paddingbox into the parent */
@@ -159,31 +159,31 @@
     gtk_box_pack_start ( GTK_BOX (paddingbox), hbox, FALSE, FALSE, 0 );
 
     /* the button to choose the configuration for all/one account */
-    button = gsb_automem_checkbutton_new ( _("Each account has his own form"),
-                        &etat.formulaire_distinct_par_compte,
-                        G_CALLBACK ( gsb_form_config_switch_general_to_several_form ),
-                        NULL);
-    gtk_box_pack_start ( GTK_BOX (hbox ), button, FALSE, FALSE, 0 );
+    //~ button = gsb_automem_checkbutton_new ( _("Each account has his own form"),
+                        //~ &etat.formulaire_distinct_par_compte,
+                        //~ G_CALLBACK ( gsb_form_config_switch_general_to_several_form ),
+                        //~ NULL);
+    //~ gtk_box_pack_start ( GTK_BOX (hbox ), button, FALSE, FALSE, 0 );
 
     /* the accounts option_menu */
     accounts_combobox = gsb_account_create_combo_list ((GtkSignalFunc) gsb_form_config_change_account_choice, NULL, FALSE );
-    gtk_widget_set_sensitive ( accounts_combobox, etat.formulaire_distinct_par_compte );
-    gtk_box_pack_start ( GTK_BOX (hbox ), accounts_combobox, FALSE, FALSE, 0 );
+    //~ gtk_widget_set_sensitive ( accounts_combobox, etat.formulaire_distinct_par_compte );
+    //~ gtk_box_pack_start ( GTK_BOX (hbox ), accounts_combobox, FALSE, FALSE, 0 );
 
     /* add the update-form button */
-    hbox = gtk_hbox_new ( FALSE, 5 );
-    gtk_box_pack_start ( GTK_BOX (paddingbox), hbox, FALSE, FALSE, 0 );
+    //~ hbox = gtk_hbox_new ( FALSE, 5 );
+    //~ gtk_box_pack_start ( GTK_BOX (paddingbox), hbox, FALSE, FALSE, 0 );
 
-    update_button = gtk_button_new_with_label (_("Update"));
-    gtk_widget_set_sensitive ( update_button, etat.formulaire_distinct_par_compte );
-    g_signal_connect ( G_OBJECT (update_button),
-                        "clicked",
-                        G_CALLBACK (gsb_form_config_update_accounts),
-                        accounts_combobox );
-    gtk_box_pack_start ( GTK_BOX (hbox), update_button, FALSE, FALSE, 0 );
+    //~ update_button = gtk_button_new_with_label (_("Update"));
+    //~ gtk_widget_set_sensitive ( update_button, etat.formulaire_distinct_par_compte );
+    //~ g_signal_connect ( G_OBJECT (update_button),
+                        //~ "clicked",
+                        //~ G_CALLBACK (gsb_form_config_update_accounts),
+                        //~ accounts_combobox );
+    //~ gtk_box_pack_start ( GTK_BOX (hbox), update_button, FALSE, FALSE, 0 );
 
-    label = gtk_label_new ( _(" : Duplicate the selected form for all accounts") );
-    gtk_box_pack_start ( GTK_BOX (hbox), label, FALSE, FALSE, 0 );
+    //~ label = gtk_label_new ( _(" : Duplicate the selected form for all accounts") );
+    //~ gtk_box_pack_start ( GTK_BOX (hbox), label, FALSE, FALSE, 0 );
 
     /*create the scolled window for tree_view */
     sw = gtk_scrolled_window_new ( NULL, NULL);
@@ -559,29 +559,29 @@
  * \param
  *
  * \return FALSE*/
-gboolean gsb_form_config_switch_general_to_several_form ( void )
-{
-    if ( etat.formulaire_distinct_par_compte )
-    {
-	gtk_widget_set_sensitive ( accounts_combobox,
-				   TRUE );
-	gtk_widget_set_sensitive ( update_button,
-				   TRUE );
-    }
-    else
-    {
-	gtk_combo_box_set_active ( GTK_COMBO_BOX (accounts_combobox),
-				   0 );
-	/* just in case we were already on the first choice */
-	gsb_form_config_change_account_choice (accounts_combobox, NULL);
+//~ gboolean gsb_form_config_switch_general_to_several_form ( void )
+//~ {
+    //~ if ( etat.formulaire_distinct_par_compte )
+    //~ {
+	//~ gtk_widget_set_sensitive ( accounts_combobox,
+				   //~ TRUE );
+	//~ gtk_widget_set_sensitive ( update_button,
+				   //~ TRUE );
+    //~ }
+    //~ else
+    //~ {
+	//~ gtk_combo_box_set_active ( GTK_COMBO_BOX (accounts_combobox),
+				   //~ 0 );
+	//~ /* just in case we were already on the first choice */
+	//~ gsb_form_config_change_account_choice (accounts_combobox, NULL);
 
-	gtk_widget_set_sensitive ( accounts_combobox,
-				   FALSE );
-	gtk_widget_set_sensitive ( update_button,
-				   FALSE );
-    }
-    return FALSE;
-}
+	//~ gtk_widget_set_sensitive ( accounts_combobox,
+				   //~ FALSE );
+	//~ gtk_widget_set_sensitive ( update_button,
+				   //~ FALSE );
+    //~ }
+    //~ return FALSE;
+//~ }
 
 						       
 /**
@@ -612,17 +612,17 @@
  *
  * \return FALSE
  * */
-static gboolean gsb_form_config_update_accounts ( GtkWidget *button,
-						  GtkWidget *combobox )
-{
-    if (!question_yes_no (_("Warning : all the form of the accounts will be updated according to the selected account. All the changes in the other accounts will be overwritten.\n\nAre you sure to do that ?"), GTK_RESPONSE_CANCEL))
-	return FALSE;
+//~ static gboolean gsb_form_config_update_accounts ( GtkWidget *button,
+						  //~ GtkWidget *combobox )
+//~ {
+    //~ if (!question_yes_no (_("Warning : all the form of the accounts will be updated according to the selected account. All the changes in the other accounts will be overwritten.\n\nAre you sure to do that ?"), GTK_RESPONSE_CANCEL))
+	//~ return FALSE;
 
-    /* update all the accounts */
-    gsb_form_config_update_from_account (gsb_account_get_combo_account_number (combobox));
+    //~ /* update all the accounts */
+    //~ gsb_form_config_update_from_account (gsb_account_get_combo_account_number (combobox));
 
-    return FALSE;
-}
+    //~ return FALSE;
+//~ }
 
 /**
  * called when toggle a button of the form configuration, append or remove

Index: gsb_real.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_real.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- gsb_real.c	10 Dec 2009 15:54:38 -0000	1.61
+++ gsb_real.c	6 Jan 2010 22:17:45 -0000	1.62
@@ -457,7 +457,7 @@
 
     if ( !string)
         return error_real;
-
+//~ printf ("string  = %s\n", string);
     for ( ; ; )
     {
         if ( g_ascii_isdigit ( *p ) )
@@ -469,14 +469,19 @@
             if ( sign == 0 ) sign = 1; // no sign found yet ==> positive
             ++nb_digits;
             ++p;
+            //~ printf ("mantissa = %lld nb_digits = %d\n", mantissa, nb_digits);
         }
         else if ( *p == 0 ) // terminal zero
         {
 			gsb_real result;
 			result.mantissa = sign * mantissa;
-            result.exponent = ( dot_position >= 0 )
+            if ( mantissa == 0 )
+                result.exponent = 0;
+            else
+                result.exponent = ( dot_position >= 0 )
                               ? nb_digits - dot_position
                               : 0;
+            //~ printf ("result.mantissa = %ld result.exponent = %d\n", result.mantissa, result.exponent);
             return result;
         }
         else if ( strchr ( ".", *p ) )

Index: gsb_file_save.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_file_save.c,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -d -r1.144 -r1.145
--- gsb_file_save.c	10 Dec 2009 22:02:33 -0000	1.144
+++ gsb_file_save.c	6 Jan 2010 22:17:45 -0000	1.145
@@ -726,7 +726,8 @@
 	display_one_line,
 	display_two_lines,
 	display_three_lines,
-	etat.formulaire_distinct_par_compte,
+	//~ etat.formulaire_distinct_par_compte,
+    0,
 	my_safe_null_str(transaction_column_width_write),
 	my_safe_null_str(scheduler_column_width_write),
 	etat.combofix_mixed_sort,

Index: gsb_form.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form.c,v
retrieving revision 1.142
retrieving revision 1.143
diff -u -d -r1.142 -r1.143
--- gsb_form.c	3 Jan 2010 11:21:26 -0000	1.142
+++ gsb_form.c	6 Jan 2010 22:17:45 -0000	1.143
@@ -1193,9 +1193,9 @@
 
     /* if each account has a separate form, get it here,
      * else, get the form of the first account */
-    if (etat.formulaire_distinct_par_compte)
-	form_account_number = account_number;
-    else
+    //~ if (etat.formulaire_distinct_par_compte)
+	//~ form_account_number = account_number;
+    //~ else
 	form_account_number = gsb_data_account_first_number ();
 
     rows_number = gsb_data_form_get_nb_rows (form_account_number);

Index: gsb_data_account.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_account.c,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- gsb_data_account.c	26 Dec 2009 16:57:13 -0000	1.93
+++ gsb_data_account.c	6 Jan 2010 22:17:45 -0000	1.94
@@ -2683,3 +2683,68 @@
 	gsb_gui_headings_update_suffix ( string );
 	g_free ( string );
 }
+
+
+/**
+ * calcule le solde du compte à la date à aujourd'hui.
+ * exclut les transactions futures.
+ *
+ *
+ * */
+gsb_real gsb_data_account_calculate_current_day_balance ( gint account_number )
+{
+    struct_account *account;
+    GDate *date_jour = g_date_new ( );
+    GSList *tmp_list;
+    gsb_real current_balance;
+	gsb_real current_balance_later = null_real;
+    gint floating_point;
+
+    account = gsb_data_account_get_structure ( account_number );
+
+    if ( !account )
+        return null_real;
+
+    floating_point = gsb_data_currency_get_floating_point ( account -> currency );
+
+    current_balance = gsb_real_adjust_exponent ( account -> init_balance,
+						 floating_point );
+
+    g_date_set_time_t (date_jour, time (NULL));
+
+    tmp_list = gsb_data_transaction_get_complete_transactions_list ();
+
+    while (tmp_list)
+    {
+        gint transaction_number;
+        gint res = 0;
+        gsb_real adjusted_amout;
+        gsb_real tmp_balance;
+
+        transaction_number = gsb_data_transaction_get_transaction_number ( tmp_list->data );
+
+        /* on ne tient pas compte des échéances futures pour le solde */
+        res = g_date_compare ( date_jour,
+                            gsb_data_transaction_get_date ( transaction_number ) );
+        if ( gsb_data_transaction_get_account_number (transaction_number) == account_number
+             &&
+             !gsb_data_transaction_get_mother_transaction_number (transaction_number)
+             && res >= 0 )
+        {
+            adjusted_amout = gsb_data_transaction_get_adjusted_amount (
+                        transaction_number, floating_point );
+
+            tmp_balance = gsb_real_add ( current_balance, adjusted_amout );
+
+            if( tmp_balance.mantissa != error_real.mantissa )
+                current_balance = tmp_balance;
+            else
+                current_balance_later = gsb_real_add ( current_balance_later, adjusted_amout);
+        }
+        tmp_list = tmp_list -> next;
+    }
+
+    g_date_free ( date_jour ); 
+
+    return gsb_real_add ( current_balance, current_balance_later );
+}

Index: gsb_file_load.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_file_load.c,v
retrieving revision 1.201
retrieving revision 1.202
diff -u -d -r1.201 -r1.202
--- gsb_file_load.c	29 Dec 2009 21:32:09 -0000	1.201
+++ gsb_file_load.c	6 Jan 2010 22:17:45 -0000	1.202
@@ -885,7 +885,9 @@
     else if ( !strcmp ( attribute_names[i],
                         "Remind_form_per_account" ))
     {
-        etat.formulaire_distinct_par_compte = utils_str_atoi( attribute_values[i]);
+        //~ etat.formulaire_distinct_par_compte = utils_str_atoi( attribute_values[i]);
+        etat.formulaire_distinct_par_compte = 0;
+
     }
 
     else if ( !strcmp ( attribute_names[i],
@@ -5955,7 +5957,8 @@
     if ( !strcmp ( element_name,
            "Formulaire_distinct_par_compte" ))
     {
-    etat.formulaire_distinct_par_compte = utils_str_atoi( text);
+    //~ etat.formulaire_distinct_par_compte = utils_str_atoi( text);
+    etat.formulaire_distinct_par_compte = 0;
     return;
     }
 

Index: balance_estimate_tab.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_tab.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- balance_estimate_tab.c	25 Dec 2009 18:19:55 -0000	1.24
+++ balance_estimate_tab.c	6 Jan 2010 22:17:45 -0000	1.25
@@ -2,6 +2,7 @@
 /*                                                                            */
 /*     Copyright (C) 2007 Dominique Parisot                                   */
 /*          zionly at free.org                                                   */
+/*          2008-2010 Pierre Biava (grisbi at pierre.biava.name)                 */
 /*          http://www.grisbi.org                                             */
 /*                                                                            */
 /*  This program is free software; you can redistribute it and/or modify      */
@@ -20,8 +21,7 @@
 /*                                                                            */
 /* ************************************************************************** */
 
-/* Ajout du 18/12/2008 Pierre Biava option de compilation :
- * ./configure --with-balance-estimate */
+/* ./configure --with-balance-estimate */
 
 /*
  * prefix bet : Balance Estimate Tab
@@ -57,12 +57,17 @@
 static  void bet_account_selection_changed (GtkTreeSelection *treeselection, gpointer user_data);
 static  gint bet_date_sort_function (GtkTreeModel *model, GtkTreeIter *itera, GtkTreeIter *iterb, gpointer user_data);
 static  void bet_duration_button_clicked (GtkToggleButton *togglebutton, gpointer data);
-static  void bet_estimate_refresh();
+static  void bet_estimate_refresh (void);
 static  gboolean bet_update_average_column (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data);
 static  gboolean bet_update_graph (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data);
+static gint bet_date_sort_function (GtkTreeModel *model,
+                        GtkTreeIter *a,
+                        GtkTreeIter *b,
+                        gpointer user_data);
 /*END_STATIC*/
 
 /*START_EXTERN*/
+extern gboolean balances_with_scheduled;
 extern gsb_real null_real;
 extern GtkWidget *window;
 /*END_EXTERN*/
@@ -115,15 +120,13 @@
 /* the notebook of the bet */
 static GtkWidget *bet_container = NULL;
 
-gint bet_date_sort_function (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data);
-
 /*
  * bet_duration_button_clicked
  * This function is called when a radio button is called to change the estimate duration.
  * It copies the new durations from the data parameter (of the radio button) into
  * the bet_months property of the bet container
  */
-static void bet_duration_button_clicked (GtkToggleButton *togglebutton, gpointer data)
+static void bet_duration_button_clicked ( GtkToggleButton *togglebutton, gpointer data )
 {
     gint months = GPOINTER_TO_INT(data);
     g_object_set_data (G_OBJECT(bet_container),
@@ -136,7 +139,8 @@
  * This function is called for each change in the selected line in the account list.
  * It refreshs balance estimation.
  */
-static void bet_account_selection_changed (GtkTreeSelection *treeselection, gpointer user_data)
+static void bet_account_selection_changed ( GtkTreeSelection *treeselection,
+                        gpointer user_data )
 {
     bet_estimate_refresh();
 }
@@ -147,22 +151,37 @@
  * This function create the widget (notebook) which contains all the
  * balance estimate interface. This widget is added in the main window
  */
-GtkWidget *bet_create_balance_estimate_tab(void)
+GtkWidget *bet_create_balance_estimate_tab ( void )
 {
+    GtkWidget* notebook;
+    GtkWidget *widget;
+    GtkWidget *page;
+    GtkWidget *vbox;
+    GtkWidget *hbox;
+    GtkWidget *scrolled_window;
+    GtkWidget *tree_view;
+    GtkWidget *previous = NULL;
+    GtkTreeStore *tree_model;
+    GtkTreeSelection *tree_selection;
+    GtkCellRenderer *cell;
+    GtkTreeViewColumn *column;
+    gint iduration;
+
     /* create a notebook for array and graph */
-    GtkWidget* notebook = gtk_notebook_new();
+    notebook = gtk_notebook_new();
     gtk_widget_show(notebook);
     bet_container = notebook;
 
     /****** Parameter page ******/
-    GtkWidget *widget = gtk_label_new(_("Estimate parameters"));
+    widget = gtk_label_new(_("Choice the prevision"));
     gtk_widget_show(GTK_WIDGET(widget));
-    GtkWidget *page = gtk_vbox_new(FALSE, 5);
+
+    page = gtk_vbox_new(FALSE, 5);
     gtk_widget_show(GTK_WIDGET(page));
     gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
 			     GTK_WIDGET(page), GTK_WIDGET(widget));
 
-    GtkWidget *hbox = gtk_hbox_new(FALSE, 5);
+    hbox = gtk_hbox_new(FALSE, 5);
     gtk_widget_show(GTK_WIDGET(hbox));
     gtk_box_pack_start(GTK_BOX(page), hbox, FALSE, FALSE, 15);
 
@@ -170,6 +189,7 @@
 				      GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
     gtk_widget_show(GTK_WIDGET(widget));
     gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 5);
+
     widget = gtk_label_new(NULL);
     gtk_label_set_markup(GTK_LABEL(widget),
 			 _("Please select an account and a duration\n"\
@@ -182,18 +202,22 @@
     gtk_box_pack_start(GTK_BOX(page), hbox, FALSE, FALSE, 5);
 
     /* create the account list */
-    GtkWidget *tree_view = gtk_tree_view_new();
+    tree_view = gtk_tree_view_new();
     g_object_set_data (G_OBJECT(notebook), "bet_account_treeview", tree_view);
     gtk_widget_show(tree_view);
-    GtkTreeStore *tree_model = gtk_tree_store_new(SPP_ACCOUNT_TREE_NUM_COLUMNS, G_TYPE_STRING);
+
+    tree_model = gtk_tree_store_new(SPP_ACCOUNT_TREE_NUM_COLUMNS, G_TYPE_STRING);
     gtk_tree_view_set_model(GTK_TREE_VIEW(tree_view), GTK_TREE_MODEL(tree_model));
     g_object_unref (G_OBJECT(tree_model));
-    GtkTreeSelection* tree_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
+
+    tree_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
     gtk_tree_selection_set_mode(tree_selection, GTK_SELECTION_SINGLE);
-    g_signal_connect(G_OBJECT(tree_selection), "changed",
-		     G_CALLBACK(bet_account_selection_changed), NULL);
+    g_signal_connect(G_OBJECT(tree_selection),
+                        "changed",
+                        G_CALLBACK(bet_account_selection_changed),
+                        NULL);
 
-    GtkWidget *scrolled_window = gtk_scrolled_window_new ( NULL, NULL );
+    scrolled_window = gtk_scrolled_window_new ( NULL, NULL );
     gtk_widget_show(scrolled_window);
     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
 				   GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
@@ -201,44 +225,45 @@
     gtk_widget_show(scrolled_window);
     gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(scrolled_window), TRUE, TRUE, 0);
 
-    GtkCellRenderer *cell = gtk_cell_renderer_text_new ();
-    GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes (
-									  _("Account"), cell,
-									  "text", SPP_ACCOUNT_TREE_NAME_COLUMN,
-									  NULL);
+    cell = gtk_cell_renderer_text_new ();
+    column = gtk_tree_view_column_new_with_attributes (
+                        _("Account"), cell,
+                        "text", SPP_ACCOUNT_TREE_NAME_COLUMN,
+                        NULL);
     gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view),
 				GTK_TREE_VIEW_COLUMN(column));
 
     /* create duration selection */
-    GtkWidget *vbox = gtk_vbox_new(FALSE, 5);
+    vbox = gtk_vbox_new(FALSE, 5);
     gtk_widget_show(GTK_WIDGET(vbox));
     gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(vbox), FALSE, FALSE, 5);
 
-    gint iduration;
-    GtkWidget *previous = NULL;
     for (iduration = 0; bet_duration_array[iduration] != NULL; iduration++)
     {
-	GtkWidget *widget;
-	if (previous == NULL)
-	{
-	    widget = gtk_radio_button_new_with_label(NULL,
-						     _(bet_duration_array[iduration]));
-	    previous = widget;
-	} else {
-	    widget = gtk_radio_button_new_with_label_from_widget(
-								 GTK_RADIO_BUTTON(previous),
-								 _(bet_duration_array[iduration]));
-	}
-	gtk_widget_show(GTK_WIDGET(widget));
-	gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(widget), FALSE, FALSE, 5);
-	g_signal_connect(G_OBJECT(widget),
-			 "toggled",
-			 G_CALLBACK(bet_duration_button_clicked),
-			 GINT_TO_POINTER(bet_months_array[iduration]));
+        GtkWidget *widget;
+
+        if (previous == NULL)
+        {
+            widget = gtk_radio_button_new_with_label(NULL,
+                        _(bet_duration_array[iduration]));
+            previous = widget;
+        } 
+        else 
+        {
+            widget = gtk_radio_button_new_with_label_from_widget(
+                        GTK_RADIO_BUTTON(previous),
+                        _(bet_duration_array[iduration]));
+        }
+        gtk_widget_show(GTK_WIDGET(widget));
+        gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(widget), FALSE, FALSE, 5);
+        g_signal_connect(G_OBJECT(widget),
+                        "toggled",
+                        G_CALLBACK(bet_duration_button_clicked),
+                        GINT_TO_POINTER(bet_months_array[iduration]));
     }
 
     /****** Estimation array page ******/
-    widget = gtk_label_new(_("Estimate array"));
+    widget = gtk_label_new(_("Array"));
     gtk_widget_show(widget);
     vbox = gtk_vbox_new(FALSE, 5);
     gtk_widget_show(GTK_WIDGET(vbox));
@@ -246,7 +271,7 @@
 			     GTK_WIDGET(vbox), GTK_WIDGET(widget));
 
     /* create the title */
-    widget = gtk_label_new("Estimation array");
+    widget = gtk_label_new("Estimate array");
     gtk_widget_show(GTK_WIDGET(widget));
     gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(widget), FALSE, FALSE, 5);
     g_object_set_data (G_OBJECT(notebook), "bet_array_title", widget);
@@ -293,7 +318,7 @@
 						       NULL);
     gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view),
 				GTK_TREE_VIEW_COLUMN(column));
-    gtk_tree_view_column_set_min_width(GTK_TREE_VIEW_COLUMN(column), 160);
+    gtk_tree_view_column_set_min_width(GTK_TREE_VIEW_COLUMN(column), 150);
 
     /* Description column */
     cell = gtk_cell_renderer_text_new ();
@@ -314,7 +339,7 @@
 						       NULL);
     gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view),
 				GTK_TREE_VIEW_COLUMN(column));
-    gtk_tree_view_column_set_min_width(column, 150);
+    gtk_tree_view_column_set_min_width(column, 140);
     g_object_set(G_OBJECT(GTK_CELL_RENDERER(cell)), "xalign", 1.0, NULL );
     gtk_tree_view_column_set_alignment(column, 1);
     gtk_tree_view_column_set_expand(GTK_TREE_VIEW_COLUMN(column), FALSE);
@@ -328,15 +353,15 @@
 						       NULL);
     gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view),
 				GTK_TREE_VIEW_COLUMN(column));
-    gtk_tree_view_column_set_min_width(column, 150);
+    gtk_tree_view_column_set_min_width(column, 140);
     g_object_set(G_OBJECT(GTK_CELL_RENDERER(cell)), "xalign", 1.0, NULL );
     gtk_tree_view_column_set_alignment(column, 1);
     gtk_tree_view_column_set_expand(GTK_TREE_VIEW_COLUMN(column), FALSE);
 
-    /* Average column */
+    /* Balance column */
     cell = gtk_cell_renderer_text_new ();
     column = gtk_tree_view_column_new_with_attributes (
-						       _("Average"), cell,
+						       _("Balance"), cell,
 						       "text", SPP_ESTIMATE_TREE_BALANCE_COLUMN,
 						       NULL);
     gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view),
@@ -347,7 +372,7 @@
     gtk_tree_view_column_set_expand(GTK_TREE_VIEW_COLUMN(column), FALSE);
 
     /****** Estimation graph page ******/
-    widget = gtk_label_new(_("Estimation graph"));
+    widget = gtk_label_new(_("Graph"));
     gtk_widget_show(widget);
     vbox = gtk_vbox_new(FALSE, 5);
     gtk_widget_show(GTK_WIDGET(vbox));
@@ -374,47 +399,56 @@
  *
  * This function is called each time that "Balance estimate" is selected in the selection tree.
  */
-void bet_update_balance_estimate_tab(void)
+void bet_update_balance_estimate_tab ( void )
 {
-    /* find the selected account */
+    GtkWidget *tree_view;
+    GtkTreeModel *tree_model;
+    GtkTreeSelection* tree_selection;
     GtkTreeIter iter;
+    GSList *tmp_list;
     gchar* previous_account_name = NULL;
-    GtkWidget *tree_view = g_object_get_data (G_OBJECT(bet_container), "bet_account_treeview");
-    GtkTreeModel *tree_model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view));
-    GtkTreeSelection* tree_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
+
+    /* find the selected account */
+    tree_view = g_object_get_data (G_OBJECT(bet_container), "bet_account_treeview");
+    tree_model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view));
+    tree_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
+
     if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(tree_selection), &tree_model, &iter))
-	gtk_tree_model_get (tree_model, &iter, 0, &previous_account_name, -1);
+        gtk_tree_model_get (tree_model, &iter, 0, &previous_account_name, -1);
 
     /* fill the account list */
     gtk_tree_store_clear ( GTK_TREE_STORE (tree_model) );
-    GSList *tmp_list = gsb_data_account_get_list_accounts ();
+    tmp_list = gsb_data_account_get_list_accounts ();
     while ( tmp_list )
     {
-	gint i = gsb_data_account_get_no_account(tmp_list->data);
-	tmp_list = tmp_list->next;
-	if (gsb_data_account_get_closed_account(i))
-	    continue;
-	gchar* account_name = gsb_data_account_get_name(i);
-	gtk_tree_store_append (GTK_TREE_STORE(tree_model), &iter, NULL);
-	gtk_tree_store_set(GTK_TREE_STORE(tree_model), &iter,
-			   SPP_ACCOUNT_TREE_NAME_COLUMN, account_name, -1);
-	/* select the previous selected account */
-	if (previous_account_name && strcmp(account_name, previous_account_name) == 0)
-	    gtk_tree_selection_select_iter(GTK_TREE_SELECTION(tree_selection), &iter);
+        gint i;
+        gchar* account_name;
+
+        i = gsb_data_account_get_no_account(tmp_list->data);
+        tmp_list = tmp_list->next;
+        if (gsb_data_account_get_closed_account(i))
+            continue;
+        account_name = gsb_data_account_get_name(i);
+        gtk_tree_store_append (GTK_TREE_STORE(tree_model), &iter, NULL);
+        gtk_tree_store_set(GTK_TREE_STORE(tree_model), &iter,
+                   SPP_ACCOUNT_TREE_NAME_COLUMN, account_name, -1);
+        /* select the previous selected account */
+        if (previous_account_name && strcmp(account_name, previous_account_name) == 0)
+            gtk_tree_selection_select_iter(GTK_TREE_SELECTION(tree_selection), &iter);
     }
     g_free(previous_account_name);
 
     /* if no row is selected, select the first line (if it exists) of the account list */
     if (!gtk_tree_selection_get_selected(GTK_TREE_SELECTION(tree_selection), &tree_model, &iter))
     {
-	gtk_tree_model_get_iter_first(GTK_TREE_MODEL(tree_model), &iter);
-	gtk_tree_selection_select_iter(GTK_TREE_SELECTION(tree_selection), &iter);
+        gtk_tree_model_get_iter_first(GTK_TREE_MODEL(tree_model), &iter);
+        gtk_tree_selection_select_iter(GTK_TREE_SELECTION(tree_selection), &iter);
     }
 
     /* update the estimate array and graph (if account list is not empty) */
     /* TODO clear the graph and the account list if no account is selected */
     if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(tree_selection), &tree_model, &iter))
-	bet_estimate_refresh();
+        bet_estimate_refresh ();
 }
 
 /*
@@ -422,7 +456,10 @@
  * This function is called by the Tree Model to sort
  * two lines by date.
  */
-static gint bet_date_sort_function (GtkTreeModel *model, GtkTreeIter *itera, GtkTreeIter *iterb, gpointer user_data)
+static gint bet_date_sort_function ( GtkTreeModel *model,
+                        GtkTreeIter *itera,
+                        GtkTreeIter *iterb,
+                        gpointer user_data )
 {
     g_assert(itera != NULL && iterb != NULL);
 
@@ -460,7 +497,10 @@
  * to the balance of the previous line.
  * It calculates the minimum and the maximum values of the balance column.
  */
-static gboolean bet_update_average_column (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+static gboolean bet_update_average_column ( GtkTreeModel *model,
+                        GtkTreePath *path,
+                        GtkTreeIter *iter,
+                        gpointer data )
 {
     /* find the selected account */
     GtkTreeIter iter_account;
@@ -517,7 +557,10 @@
  * This function is called for each line of the estimate array and it updates
  * the graph.
  */
-static gboolean bet_update_graph (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+static gboolean bet_update_graph ( GtkTreeModel *model,
+                        GtkTreePath *path,
+                        GtkTreeIter *iter,
+                        gpointer data )
 {
     /* get balance */
     gsb_real balance;
@@ -548,232 +591,282 @@
  * This function is called when the refresh button is pressed and when
  * the balance estimate tab is selected.
  */
-static void bet_estimate_refresh()
+static void bet_estimate_refresh ( void )
 {
     /* find the selected account */
+    GtkWidget *widget;
+    GtkWidget *tree_view;
     GtkTreeIter iter;
-    GtkWidget *tree_view = g_object_get_data (G_OBJECT(bet_container), "bet_account_treeview");
-    GtkTreeModel *tree_model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view));
-    GtkTreeSelection* tree_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
+    GtkTreeModel *tree_model;
+    GtkTreeSelection *tree_selection;
+    gchar *account_name = NULL;
+    gchar *data;
+    gchar *str_date_min;
+    gchar *str_date_max;
+    gchar *str_current_balance;
+    gchar *title;
+    gint selected_account;
+    gint months;
+    GDate *date_min;
+    GDate *date_max;
+    gsb_real current_balance;
+    GSList* tmp_list;
+    struct bet_range tmp_range;
+
+    tree_view = g_object_get_data (G_OBJECT(bet_container), "bet_account_treeview");
+    tree_model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view));
+    tree_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
+
     if (!gtk_tree_selection_get_selected(GTK_TREE_SELECTION(tree_selection), &tree_model, &iter))
     {
-	/* no selection, select the first account
-	 * (no warning here because cause a conflict with the tree of navigation */
-	gtk_notebook_set_current_page ( GTK_NOTEBOOK (bet_container),
-				0 );
-	return;
+        /* no selection, select the first account
+         * (no warning here because cause a conflict with the tree of navigation */
+        gtk_notebook_set_current_page ( GTK_NOTEBOOK (bet_container), 0 );
+        return;
     }
 
-    gchar* account_name = NULL;
     gtk_tree_model_get (tree_model, &iter, 0, &account_name, -1);
-    gint selected_account = gsb_data_account_get_no_account_by_name(account_name);
-    g_assert(selected_account != -1);
+    selected_account = gsb_data_account_get_no_account_by_name ( account_name );
+    if ( selected_account == -1 )
+        return;;
 
-    /* calculate date_max with user choice */
-    gchar* data = g_object_get_data(G_OBJECT(bet_container), "bet_months");
-    gint months = (data) ? GPOINTER_TO_INT(data): 1;
-    GDate *date_min = gdate_today();
-    GDate *date_max = gdate_today();
-    g_date_add_months(date_max, months);
+    /* calculatextern gboolean balances_with_scheduled;e date_max with user choice */
+    data = g_object_get_data(G_OBJECT(bet_container), "bet_months");
+    months = ( data ) ? GPOINTER_TO_INT(data): 1;
+    date_min = gdate_today ();
+    date_max = gdate_today ();
+    g_date_add_months (date_max, months );
 
     /* set the graph title and the array title */
-    GtkWidget *widget;
-    gchar* str_date_min = gsb_format_gdate(date_min);
-    gchar* str_date_max = gsb_format_gdate(date_max);
-    gchar* title = g_strdup_printf(_("Balance estimate of the account \"%s\" from %s to %s"),
-				   account_name, str_date_min, str_date_max);
+    str_date_min = gsb_format_gdate (date_min);
+    str_date_max = gsb_format_gdate (date_max);
+    /* current balance may be in the future if there are transactions
+     * in the future in the account. So we need to calculate the balance
+     * of today */
+    if ( balances_with_scheduled )
+        current_balance = gsb_data_account_calculate_current_day_balance ( selected_account );
+    else
+        current_balance = gsb_data_account_get_current_balance ( selected_account );
+
+    str_current_balance = gsb_real_get_string_with_currency ( current_balance,
+                        gsb_data_account_get_currency ( selected_account ), TRUE );
+
+    title = g_strdup_printf (
+                    _("Balance estimate of the account \"%s\" from %s to %s "
+                    "balance beginning of period = %s"),
+				   account_name, str_date_min, str_date_max, str_current_balance );
     g_free(str_date_min);
     g_free(str_date_max);
-    widget = GTK_WIDGET(g_object_get_data(G_OBJECT(bet_container), "bet_array_title"));
-    gtk_label_set_label(GTK_LABEL(widget), title);
-    widget = GTK_WIDGET(g_object_get_data(G_OBJECT(bet_container), "bet_graph_title"));
-    gtk_label_set_label(GTK_LABEL(widget), title);
-    g_free(title);
-    g_free(account_name);
 
-    /* clear tree view */
-    tree_view = g_object_get_data (G_OBJECT(bet_container), "bet_estimate_treeview");
-    tree_model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view));
-    gtk_tree_store_clear(GTK_TREE_STORE (tree_model));
+    widget = GTK_WIDGET ( g_object_get_data ( G_OBJECT ( bet_container ), "bet_array_title") );
+    gtk_label_set_label ( GTK_LABEL ( widget ), title );
+    widget = GTK_WIDGET ( g_object_get_data ( G_OBJECT ( bet_container ), "bet_graph_title") );
+    gtk_label_set_label ( GTK_LABEL ( widget ), title );
+    g_free ( title );
+    g_free ( account_name );
 
-    /* current balance may be in the future if there are transactions
-     * in the future in the account. So we need to calculate the balance
-     * of today */
-    gsb_real current_balance = gsb_data_account_get_current_balance (selected_account);
+    /* clear tree view */
+    tree_view = g_object_get_data ( G_OBJECT ( bet_container ), "bet_estimate_treeview" );
+    tree_model = gtk_tree_view_get_model ( GTK_TREE_VIEW ( tree_view ) );
+    gtk_tree_store_clear(GTK_TREE_STORE ( tree_model ) );
 
     /* search transactions of the account which are in the future */
-    GSList* tmp_list = gsb_data_transaction_get_complete_transactions_list ();
-    while (tmp_list)
+    tmp_list = gsb_data_transaction_get_complete_transactions_list ( );
+
+    while ( tmp_list )
     {
-	gint transaction_number = gsb_data_transaction_get_transaction_number (tmp_list->data);
-	tmp_list = tmp_list -> next;
-	gint account_number =  gsb_data_transaction_get_account_number (transaction_number);
-	if (account_number != selected_account)
-	    continue;
+        gchar* str_amount;
+        gchar* str_debit = NULL;
+        gchar* str_credit = NULL;
+        const gchar* str_description;
+        gchar* str_date;
+        gint transaction_number;
+        gint account_number;
+        const GDate *date;
+        GValue date_value = {0, };
+        gsb_real amount;
 
-	/* ignore transaction which are before date_min (today) */
-	const GDate *date = gsb_data_transaction_get_date(transaction_number);
-	if (g_date_compare(date, date_min) <= 0)
-	    continue;
+        transaction_number = gsb_data_transaction_get_transaction_number ( tmp_list->data );
+        tmp_list = tmp_list -> next;
 
-	/* update the current_balance.
-	 * our target is to calculate the balance of date_min (today) */
-	gsb_real amount = gsb_data_transaction_get_amount(transaction_number);
-	current_balance = gsb_real_sub(current_balance, amount);
+        account_number =  gsb_data_transaction_get_account_number ( transaction_number );
+        if ( account_number != selected_account )
+            continue;
 
-	/* ignore transaction which are after date_max */
-	if (g_date_compare(date, date_max) > 0)
-	    continue;
+        /* ignore transaction which are before date_min (today) */
+        date = gsb_data_transaction_get_date ( transaction_number );
+        if ( g_date_compare ( date, date_min ) <= 0 )
+            continue;
 
-	gchar* str_value = gsb_real_get_string (amount);
-	gchar* str_debit = NULL;
-	gchar* str_credit = NULL;
-	if (amount.mantissa < 0)
-	    str_debit = gsb_real_get_string_with_currency (gsb_real_abs (amount),
-							   gsb_data_transaction_get_currency_number (transaction_number), TRUE);
-	else
-	    str_credit = gsb_real_get_string_with_currency (gsb_real_abs (amount),
-							    gsb_data_transaction_get_currency_number (transaction_number), TRUE);
+        /* ignore transaction which are after date_max */
+        if ( g_date_compare (date, date_max ) > 0 )
+            continue;
 
-	/* TODO add something else if description is empty (payee by example) */
-	const gchar* str_description = gsb_data_transaction_get_notes(transaction_number);
-	gchar* str_date = gsb_format_gdate(date);
+        amount = gsb_data_transaction_get_amount ( transaction_number );
+        str_amount = gsb_real_get_string ( amount );
 
-	if (!str_description || !strlen (str_description))
-	    str_description = gsb_data_payee_get_name (gsb_data_transaction_get_party_number (transaction_number), TRUE);
+        if (amount.mantissa < 0)
+            str_debit = gsb_real_get_string_with_currency ( gsb_real_abs ( amount ),
+                        gsb_data_transaction_get_currency_number ( transaction_number), TRUE );
+        else
+            str_credit = gsb_real_get_string_with_currency ( gsb_real_abs ( amount ),
+                                    gsb_data_transaction_get_currency_number (transaction_number), TRUE);
 
-	GValue date_value = {0, };
-	g_value_init (&date_value, G_TYPE_DATE);
-	g_value_set_boxed(&date_value, date);
+        /* TODO add something else if description is empty ( payee by example ) */
+        str_description = gsb_data_transaction_get_notes ( transaction_number );
+        str_date = gsb_format_gdate ( date );
 
-	/* add a line in the estimate array */
-	gtk_tree_store_append (GTK_TREE_STORE(tree_model), &iter, NULL);
-	gtk_tree_store_set_value(GTK_TREE_STORE(tree_model), &iter,
-				 SPP_ESTIMATE_TREE_SORT_DATE_COLUMN,
-				 &date_value);
-	gtk_tree_store_set(GTK_TREE_STORE(tree_model), &iter,
-			   SPP_ESTIMATE_TREE_DATE_COLUMN, str_date,
-			   SPP_ESTIMATE_TREE_DESC_COLUMN, str_description,
-			   SPP_ESTIMATE_TREE_DEBIT_COLUMN, str_debit,
-			   SPP_ESTIMATE_TREE_CREDIT_COLUMN, str_credit,
-			   SPP_ESTIMATE_TREE_AMOUNT_COLUMN, str_value,
-			   -1);
+        if (!str_description || !strlen (str_description))
+            str_description = gsb_data_payee_get_name (
+                        gsb_data_transaction_get_party_number ( transaction_number ), TRUE );
 
-	g_value_unset(&date_value);
-	g_free(str_date);
-	g_free(str_value);
-	if (str_debit)
-	    g_free (str_debit);
-	if (str_credit)
-	    g_free (str_credit);
+        g_value_init ( &date_value, G_TYPE_DATE );
+        g_value_set_boxed ( &date_value, date );
+
+        /* add a line in the estimate array */
+        gtk_tree_store_append ( GTK_TREE_STORE ( tree_model ), &iter, NULL );
+        gtk_tree_store_set_value (GTK_TREE_STORE ( tree_model ), &iter,
+                     SPP_ESTIMATE_TREE_SORT_DATE_COLUMN,
+                     &date_value);
+        gtk_tree_store_set(GTK_TREE_STORE(tree_model), &iter,
+                   SPP_ESTIMATE_TREE_DATE_COLUMN, str_date,
+                   SPP_ESTIMATE_TREE_DESC_COLUMN, str_description,
+                   SPP_ESTIMATE_TREE_DEBIT_COLUMN, str_debit,
+                   SPP_ESTIMATE_TREE_CREDIT_COLUMN, str_credit,
+                   SPP_ESTIMATE_TREE_AMOUNT_COLUMN, str_amount,
+                   -1);
+
+        g_value_unset ( &date_value );
+        g_free ( str_date );
+        g_free ( str_amount );
+        if ( str_debit )
+            g_free ( str_debit );
+        if ( str_credit )
+            g_free ( str_credit );
     }
 
     /* for each schedulded operation */
     tmp_list = gsb_data_scheduled_get_scheduled_list();
+
     while (tmp_list)
     {
-	gint scheduled_number = gsb_data_scheduled_get_scheduled_number(tmp_list->data);
-	tmp_list = tmp_list->next;
+        gchar *str_value;
+        gchar *str_debit = NULL;
+        gchar *str_credit = NULL;
+        const gchar *str_description;
+        gchar *str_date;
+        gint scheduled_number;
+        gint account_number;
+        //~ gint transfer_account_number;
+        GDate *date;
+        GValue date_value = {0, };
+        gsb_real amount;
 
-	/* ignore children scheduled operations */
-	if (gsb_data_scheduled_get_mother_scheduled_number(scheduled_number))
-	    continue;
+        scheduled_number = gsb_data_scheduled_get_scheduled_number ( tmp_list->data );
+        tmp_list = tmp_list->next;
 
-	/* ignore scheduled operations of other account */
-	gint account_number = gsb_data_scheduled_get_account_number(scheduled_number);
-	gint transfer_account_number =
-	    gsb_data_scheduled_get_account_number_transfer(scheduled_number);
-	if (account_number != selected_account &&
-	    transfer_account_number != selected_account)
-	    continue;
+        /* ignore children scheduled operations */
+        if (gsb_data_scheduled_get_mother_scheduled_number(scheduled_number))
+            continue;
 
-	const gchar* str_description = gsb_data_scheduled_get_notes(scheduled_number);
-	gsb_real amount = gsb_data_scheduled_get_amount(scheduled_number);
+        /* ignore scheduled operations of other account */
+        account_number = gsb_data_scheduled_get_account_number ( scheduled_number );
+       //~ transfer_account_number =
+            //~ gsb_data_scheduled_get_account_number_transfer( scheduled_number );
+        //~ if ( account_number != selected_account &&
+            //~ transfer_account_number != selected_account)
+            //~ continue;
+        if ( account_number != selected_account )
+            continue;
 
-	if (!str_description || !strlen (str_description))
-	    str_description = gsb_data_payee_get_name (gsb_data_scheduled_get_party_number (scheduled_number), TRUE);
+        str_description = gsb_data_scheduled_get_notes ( scheduled_number );
+        amount = gsb_data_scheduled_get_amount ( scheduled_number );
 
-	gchar* str_value = gsb_real_get_string (amount);
-	gchar* str_debit = NULL;
-	gchar* str_credit = NULL;
-	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);
-	else
-	    str_credit = gsb_real_get_string_with_currency (gsb_real_abs (amount),
-							    gsb_data_scheduled_get_currency_number (scheduled_number), TRUE);
+        if ( !str_description || !strlen (str_description))
+            str_description = gsb_data_payee_get_name (
+                        gsb_data_scheduled_get_party_number ( scheduled_number ), TRUE );
 
-	/* with transfer transactions, reverse debit and credit */
-	if (transfer_account_number == selected_account)
-	{
-	    gchar *tmpstr;
-	    tmpstr = str_debit;
-	    str_debit = str_credit;
-	    str_credit = tmpstr;
-	}
+        str_value = gsb_real_get_string ( amount );
+        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 );
+        else
+            str_credit = gsb_real_get_string_with_currency ( gsb_real_abs ( amount ),
+                        gsb_data_scheduled_get_currency_number ( scheduled_number ), TRUE );
 
-	/* calculate each instance of the scheduled operation
-	 * in the range from date_min (today) to date_max */
-	GDate *date = gsb_data_scheduled_get_date(scheduled_number);
-	while (date != NULL && g_date_valid(date))
-	{
-	    if (g_date_compare(date, date_max) > 0)
-		break;
-	    if (g_date_compare(date, date_min) < 0) {
-		date = gsb_scheduler_get_next_date(scheduled_number, date);
-		continue;
-	    }
-	    g_assert(g_date_valid (date));
-	    gchar* str_date = gsb_format_gdate(date);
+        /* with transfer transactions, reverse debit and credit */
+        //~ if (transfer_account_number == selected_account)
+        //~ {
+            //~ gchar *tmpstr;
+            //~ tmpstr = str_debit;
+            //~ str_debit = str_credit;
+            //~ str_credit = tmpstr;
+        //~ }
 
-	    GValue date_value = {0, };
-	    g_value_init (&date_value, G_TYPE_DATE);
-	    g_assert(date != NULL);
-	    g_value_set_boxed(&date_value, date);
+        /* calculate each instance of the scheduled operation
+         * in the range from date_min (today) to date_max */
+        date = gsb_data_scheduled_get_date ( scheduled_number );
 
-	    /* add a line in the estimate array */
-	    gtk_tree_store_append (GTK_TREE_STORE(tree_model), &iter, NULL);
-	    gtk_tree_store_set_value(GTK_TREE_STORE(tree_model), &iter,
-				     SPP_ESTIMATE_TREE_SORT_DATE_COLUMN,
-				     &date_value);
-	    gtk_tree_store_set(GTK_TREE_STORE(tree_model), &iter,
-			       SPP_ESTIMATE_TREE_DATE_COLUMN, str_date,
-			       SPP_ESTIMATE_TREE_DESC_COLUMN, str_description,
-			       SPP_ESTIMATE_TREE_DEBIT_COLUMN, str_debit,
-			       SPP_ESTIMATE_TREE_CREDIT_COLUMN, str_credit,
-			       SPP_ESTIMATE_TREE_AMOUNT_COLUMN, str_value,
-			       -1);
+        while (date != NULL && g_date_valid ( date ) )
+        {
+            if ( g_date_compare ( date, date_max ) > 0 )
+                break;
+            if ( g_date_compare ( date, date_min ) < 0 )
+            {
+                date = gsb_scheduler_get_next_date ( scheduled_number, date );
+                continue;
+            }
+            if ( g_date_valid ( date ) == FALSE )
+                return;
+            str_date = gsb_format_gdate ( date );
 
-	    g_value_unset(&date_value);
-	    g_free(str_date);
-	    date = gsb_scheduler_get_next_date(scheduled_number, date);
-	}
-	g_free(str_value);
-	if (str_credit)
-	    g_free (str_credit);
-	if (str_debit)
-	    g_free (str_debit);
+            g_value_init ( &date_value, G_TYPE_DATE );
+            if ( date == NULL )
+                return;
+            g_value_set_boxed ( &date_value, date ); 
+
+            /* add a line in the estimate array */
+            gtk_tree_store_append (GTK_TREE_STORE(tree_model), &iter, NULL);
+            gtk_tree_store_set_value(GTK_TREE_STORE(tree_model), &iter,
+                         SPP_ESTIMATE_TREE_SORT_DATE_COLUMN,
+                         &date_value);
+            gtk_tree_store_set(GTK_TREE_STORE(tree_model), &iter,
+                       SPP_ESTIMATE_TREE_DATE_COLUMN, str_date,
+                       SPP_ESTIMATE_TREE_DESC_COLUMN, str_description,
+                       SPP_ESTIMATE_TREE_DEBIT_COLUMN, str_debit,
+                       SPP_ESTIMATE_TREE_CREDIT_COLUMN, str_credit,
+                       SPP_ESTIMATE_TREE_AMOUNT_COLUMN, str_value,
+                       -1);
+
+            g_value_unset ( &date_value );
+            g_free ( str_date );
+            date = gsb_scheduler_get_next_date ( scheduled_number, date );
+        }
+
+        g_free ( str_value );
+        if ( str_credit )
+            g_free ( str_credit );
+        if ( str_debit )
+            g_free ( str_debit );
     }
-    g_free(date_min);
-    g_free(date_max);
+
+    g_free ( date_min );
+    g_free ( date_max );
 
     /* Calculate the balance column */
-    struct bet_range tmp_range;
     tmp_range.min_date = *date_min;
     tmp_range.max_date = *date_max;
-    gsb_real null_real = { 0 , 0 };
     tmp_range.min_balance = null_real;
     tmp_range.max_balance = null_real;
     tmp_range.current_balance = current_balance;
-    gtk_tree_model_foreach(GTK_TREE_MODEL(tree_model),
-			   bet_update_average_column, &tmp_range);
+    gtk_tree_model_foreach ( GTK_TREE_MODEL ( tree_model ),
+			   bet_update_average_column, &tmp_range );
 
     /* update graph */
-    widget = g_object_get_data (G_OBJECT(bet_container), "bet_graph_curve");
-    gtk_curve_reset(GTK_CURVE(widget));
-    gtk_tree_model_foreach(GTK_TREE_MODEL(tree_model),
-			   bet_update_graph, widget);
-
+    widget = g_object_get_data ( G_OBJECT ( bet_container ), "bet_graph_curve" );
+    gtk_curve_reset ( GTK_CURVE ( widget ) );
+    gtk_tree_model_foreach ( GTK_TREE_MODEL ( tree_model ),
+			   bet_update_graph, widget );
 }
 
 #endif /* ENABLE_BALANCE_ESTIMATE */

Index: main.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/main.c,v
retrieving revision 1.158
retrieving revision 1.159
diff -u -d -r1.158 -r1.159
--- main.c	26 Dec 2009 16:57:13 -0000	1.158
+++ main.c	6 Jan 2010 22:17:45 -0000	1.159
@@ -181,6 +181,22 @@
     init_variables ();
     register_import_formats ();
 
+    //~ /* test locale pour les nombres */
+    //~ struct lconv *conv = localeconv ( );
+    
+    //~ printf ("currency_symbol = %s\n"
+            //~ "mon_thousands_sep = \"%s\"\n"
+            //~ "mon_decimal_point = %s\n"
+            //~ "positive_sign = \"%s\"\n"
+            //~ "negative_sign = \"%s\"\n"
+            //~ "frac_digits = \"%d\"\n",
+            //~ conv->currency_symbol,
+            //~ g_locale_to_utf8 ( conv->mon_thousands_sep, -1, NULL, NULL, NULL ),
+            //~ g_locale_to_utf8 ( conv->mon_decimal_point, -1, NULL, NULL, NULL ),
+            //~ g_locale_to_utf8 ( conv->positive_sign, -1, NULL, NULL, NULL ),
+            //~ g_locale_to_utf8 ( conv->negative_sign, -1, NULL, NULL, NULL ),
+            //~ conv->frac_digits );
+
     /* firt use ? */
     if ( ! gsb_file_config_load_config () )
         first_use = TRUE;

Index: gsb_data_account.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_account.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- gsb_data_account.h	2 Oct 2009 21:35:04 -0000	1.38
+++ gsb_data_account.h	6 Jan 2010 22:17:45 -0000	1.39
@@ -23,6 +23,7 @@
 
 /* START_DECLARATION */
 gsb_real gsb_data_account_calculate_current_and_marked_balances ( gint account_number );
+gsb_real gsb_data_account_calculate_current_day_balance ( gint account_number );
 gsb_real gsb_data_account_calculate_waiting_marked_balance ( gint account_number );
 void gsb_data_account_change_account_icon ( GtkWidget *button, gpointer data );
 void gsb_data_account_colorize_current_balance ( gint account_number );



More information about the cvs mailing list