[grisbi-cvs] grisbi/src Makefile.am, 1.160, 1.161 balance_estimate_config.c, 1.1, 1.2 balance_estimate_tab.c, 1.33, 1.34 balance_estimate_tab.h, 1.4, 1.5 gsb_currency.c, 1.56, 1.57 parametres.c, 1.209, 1.210 parametres.h, 1.33, 1.34

Pierre Biava pbiava at users.sourceforge.net
Sun Jan 24 11:58:03 CET 2010


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

Modified Files:
	Makefile.am balance_estimate_config.c balance_estimate_tab.c 
	balance_estimate_tab.h gsb_currency.c parametres.c 
	parametres.h 
Log Message:
add balance_estimate_config files

Index: balance_estimate_config.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_config.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- balance_estimate_config.c	24 Jan 2010 10:47:30 -0000	1.1
+++ balance_estimate_config.c	24 Jan 2010 10:58:01 -0000	1.2
@@ -24,6 +24,8 @@
 #include "include.h"
 #include <config.h>
 
+#ifdef ENABLE_BALANCE_ESTIMATE
+
 /*START_INCLUDE*/
 #include "balance_estimate_config.h"
 #include "./balance_estimate_tab.h"
@@ -155,3 +157,4 @@
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */
+#endif /* ENABLE_BALANCE_ESTIMATE */

Index: parametres.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/parametres.c,v
retrieving revision 1.209
retrieving revision 1.210
diff -u -d -r1.209 -r1.210
--- parametres.c	26 Dec 2009 16:57:13 -0000	1.209
+++ parametres.c	24 Jan 2010 10:58:01 -0000	1.210
@@ -30,6 +30,7 @@
 
 /*START_INCLUDE*/
 #include "parametres.h"
+#include "./balance_estimate_config.h"
 #include "./menu.h"
 #include "./utils.h"
 #include "./dialog.h"
@@ -526,6 +527,26 @@
     gtk_box_pack_start ( GTK_BOX ( GTK_DIALOG(fenetre_preferences) -> vbox ),
                         hpaned, TRUE, TRUE, 0);
 
+#ifdef ENABLE_BALANCE_ESTIMATE 
+    /* balance estimate subtree */
+    gtk_tree_store_append (GTK_TREE_STORE (preference_tree_model), &iter, NULL);
+    gtk_tree_store_set (GTK_TREE_STORE (preference_tree_model),
+                        &iter,
+                        0, _("Balance estimate"),
+                        1, NOT_A_PAGE,
+                        2, 800,
+                        -1);
+
+    gtk_tree_store_append (GTK_TREE_STORE (preference_tree_model), &iter2, &iter);
+    gtk_tree_store_set (GTK_TREE_STORE (preference_tree_model),
+                        &iter2,
+                        0, _("General options"),
+                        1, BET_GENERAL_PAGE,
+                        2, 400,
+                        -1);
+    gtk_notebook_append_page (preference_frame, bet_estimate_config_create_page(), NULL);
+#endif
+
     /* select the page */
     if ( page >= 0 && page < NUM_PREFERENCES_PAGES )
         gtk_notebook_set_current_page ( GTK_NOTEBOOK (preference_frame), page );

Index: parametres.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/parametres.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- parametres.h	26 Dec 2009 16:57:13 -0000	1.33
+++ parametres.h	24 Jan 2010 10:58:01 -0000	1.34
@@ -28,6 +28,9 @@
     BANKS_PAGE,
     FINANCIAL_YEARS_PAGE,
     METHODS_OF_PAYMENT_PAGE,
+#ifdef ENABLE_BALANCE_ESTIMATE
+    BET_GENERAL_PAGE,
+#endif
     NUM_PREFERENCES_PAGES
 };
 

Index: balance_estimate_tab.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_tab.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- balance_estimate_tab.h	18 Jan 2010 19:13:40 -0000	1.4
+++ balance_estimate_tab.h	24 Jan 2010 10:58:01 -0000	1.5
@@ -20,22 +20,20 @@
 #ifndef _BALANCE_ESTIMATE_TAB_H
 #define _BALANCE_ESTIMATE_TAB_H
 
-#ifdef ENABLE_BALANCE_ESTIMATE 
 #include <gtk/gtk.h>
 
 /* START_INCLUDE_H */
-#include "./gsb_real.h"
 /* END_INCLUDE_H */
 
 typedef struct _bet_range           SBR;
 typedef struct _historical          SH;
 
 /* START_DECLARATION */
-GtkWidget *bet_create_balance_estimate_tab(void);
-void bet_update_balance_estimate_tab(void);
+GtkWidget *bet_create_balance_estimate_tab ( void );
+GtkWidget *bet_estimate_get_duration_widget ( GtkWidget *container );
+gboolean bet_fyear_create_combobox_store ( void );
+void bet_update_balance_estimate_tab ( void );
 /* END_DECLARATION */
 
-#endif /* ENABLE_BALANCE_ESTIMATE */
-
 #endif /*_BALANCE_ESTIMATE_TAB_H*/
 

Index: Makefile.am
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/Makefile.am,v
retrieving revision 1.160
retrieving revision 1.161
diff -u -d -r1.160 -r1.161
--- Makefile.am	23 Sep 2009 20:28:20 -0000	1.160
+++ Makefile.am	24 Jan 2010 10:58:01 -0000	1.161
@@ -145,6 +145,7 @@
 	utils_font.c		\
 	utils_operations.c	\
 	utils_str.c		\
+	balance_estimate_config.c\
 	balance_estimate_tab.c
 
 grisbi_INCLUDES =		\
@@ -153,6 +154,7 @@
 	affichage.h		\
 	affichage_liste.h	\
 	barre_outils.h		\
+        balance_estimate_config.h  \
         balance_estimate_tab.h  \
 	categories_onglet.h	\
 	classement_echeances.h	\

Index: balance_estimate_tab.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_tab.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- balance_estimate_tab.c	23 Jan 2010 19:35:10 -0000	1.33
+++ balance_estimate_tab.c	24 Jan 2010 10:58:01 -0000	1.34
@@ -91,6 +91,14 @@
 static void bet_estimate_refresh_historical_data ( GtkTreeModel *tab_model,
                         GDate *date_min,
                         GDate *date_max );
+static void bet_estimate_refresh_scheduled_data ( GtkTreeModel *tab_model,
+                        gint selected_account,
+                        GDate *date_min,
+                        GDate *date_max );
+static void bet_estimate_refresh_transactions_data ( GtkTreeModel *tab_model,
+                        gint selected_account,
+                        GDate *date_min,
+                        GDate *date_max );
 static gboolean bet_update_average_column (GtkTreeModel *model,
                         GtkTreePath *path,
                         GtkTreeIter *iter,
@@ -108,7 +116,7 @@
 static void bet_create_graph_page ( GtkWidget *notebook );
 static void bet_create_historical_data_page ( GtkWidget *notebook );
 static GtkWidget *bet_estimate_get_list_accounts ( GtkWidget *container );
-static GtkWidget *bet_estimate_get_duration_widget ( GtkWidget *container );
+//~ static GtkWidget *bet_estimate_get_duration_widget ( GtkWidget *container );
 static gboolean bet_duration_number_changed ( GtkWidget *spin_button, GtkWidget *togglebutton );
 static void bet_duration_period_clicked ( GtkWidget *togglebutton, GtkWidget *button );
 static GtkWidget *bet_estimate_get_historical_data ( GtkWidget *container );
@@ -120,7 +128,7 @@
 static void bet_estimate_populate_div_model ( gpointer key,
                         gpointer value,
                         gpointer user_data);
-static gboolean bet_fyear_create_combobox_store ( void );
+//~ static gboolean bet_fyear_create_combobox_store ( void );
 static gint bet_fyear_get_fyear_from_combobox ( GtkWidget *combo_box );
 static gint bet_estimate_get_account_selected ( void );
 static void bet_estimate_tab_add_new_line ( GtkTreeModel *tab_model,
@@ -204,13 +212,13 @@
  * this is a tree model filter with 3 columns :
  * the name, the number and a boolean to show it or not
  * */
-static GtkTreeModel *bet_fyear_model;
+GtkTreeModel *bet_fyear_model;
 
 /**
  * this is a tree model filter from fyear_model_filter wich
  * show only the financial years wich must be showed
  * */
-static GtkTreeModel *bet_fyear_model_filter;
+GtkTreeModel *bet_fyear_model_filter;
 
 
 /*
@@ -460,7 +468,6 @@
     GDate *date_min;
     GDate *date_max;
     gsb_real current_balance;
-    GSList* tmp_list;
     SBR *tmp_range;
     GValue date_value = {0, };
 
@@ -547,227 +554,23 @@
                    -1);
 
     g_value_unset ( &date_value );
-    g_free(str_date_min);
-    g_free(str_date_max);
+    g_free ( str_date_min );
+    g_free ( str_date_max );
 
+    /* search data from the past */
+    bet_estimate_refresh_historical_data ( tree_model, date_min, date_max );
+    
     /* search transactions of the account which are in the future */
-    tmp_list = gsb_data_transaction_get_transactions_list ( );
-
-    while ( tmp_list )
-    {
-        gchar* str_amount;
-        gchar* str_debit = NULL;
-        gchar* str_credit = NULL;
-        const gchar* str_description;
-        gchar* str_date;
-        gint transaction_number;
-        gint transfer_number;
-        gint account_number;
-        gint transfer_account_number;
-        const GDate *date;
-        gsb_real amount;
-
-        transaction_number = gsb_data_transaction_get_transaction_number ( tmp_list->data );
-        tmp_list = tmp_list -> next;
-
-        account_number =  gsb_data_transaction_get_account_number ( transaction_number );
-        if ( account_number != selected_account )
-            continue;
-
-        date = gsb_data_transaction_get_date ( transaction_number );
-        /* ignore transaction which are before date_min (today) */
-        if ( g_date_compare ( date, date_min ) <= 0 )
-            continue;
-        /* ignore transaction which are after date_max */
-        if ( g_date_compare (date, date_max ) > 0 )
-            continue;
-
-        /* ignore splitted transactions */
-        if ( gsb_data_transaction_get_mother_transaction_number (
-         transaction_number ) != 0 )
-            continue;
-
-        str_date = gsb_format_gdate ( date );
-        g_value_init ( &date_value, G_TYPE_DATE );
-        g_value_set_boxed ( &date_value, date );
-
-        amount = gsb_data_transaction_get_amount ( transaction_number );
-        str_amount = gsb_real_get_string ( amount );
-
-        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);
-
-        transfer_number =
-                        gsb_data_transaction_get_contra_transaction_number (
-                        transaction_number );
-        if ( transfer_number > 0 )
-        {
-            transfer_account_number = gsb_data_transaction_get_account_number (
-                        transfer_number );
-            str_description = g_strdup_printf ( _("Transfer between account: %s\n"
-                        "and account: %s"),
-                        gsb_data_account_get_name ( account_number ),
-                        gsb_data_account_get_name ( transfer_account_number ) );
-        }
-        else
-        {
-            str_description = gsb_data_transaction_get_notes ( transaction_number );
-
-            if (!str_description || !strlen (str_description))
-                str_description = gsb_data_payee_get_name (
-                            gsb_data_transaction_get_party_number ( transaction_number ), TRUE );
-        }
-
-        /* 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 );
-    }
+    bet_estimate_refresh_transactions_data ( tree_model,
+                        selected_account,
+                        date_min,
+                        date_max );
 
     /* for each schedulded operation */
-    tmp_list = gsb_data_scheduled_get_scheduled_list();
-
-    while (tmp_list)
-    {
-        gchar *str_value;
-        gchar *str_debit = NULL;
-        gchar *str_credit = NULL;
-        const gchar *str_description = NULL;
-        gchar *str_date;
-        gint scheduled_number;
-        gint account_number;
-        gint transfer_account_number;
-        GDate *date;
-        GValue date_value = {0, };
-        gsb_real amount;
-
-        scheduled_number = gsb_data_scheduled_get_scheduled_number ( tmp_list->data );
-
-        tmp_list = tmp_list->next;
-
-        /* ignore children scheduled operations */
-        if (gsb_data_scheduled_get_mother_scheduled_number ( scheduled_number ) )
-            continue;
-
-        /* ignore scheduled operations of other account */
-        account_number = gsb_data_scheduled_get_account_number ( scheduled_number );
-
-        if ( gsb_data_scheduled_is_transfer ( scheduled_number ) )
-        {
-            transfer_account_number = gsb_data_scheduled_get_account_number_transfer (
-                        scheduled_number );
-            if ( transfer_account_number == selected_account )
-            {
-                str_description = g_strdup_printf ( _("Transfer between account: %s\n"
-                        "and account: %s"),
-                        gsb_data_account_get_name ( transfer_account_number ),
-                        gsb_data_account_get_name ( account_number ) );
-            
-                amount = gsb_real_opposite ( gsb_data_scheduled_get_amount (
-                        scheduled_number ) );
-            }
-            else if ( account_number == selected_account )
-            {
-                str_description = g_strdup_printf ( _("Transfer between account: %s\n"
-                        "and account: %s"),
-                        gsb_data_account_get_name ( account_number ),
-                        gsb_data_account_get_name ( transfer_account_number ) );
-
-                amount = gsb_data_scheduled_get_amount ( scheduled_number );
-            }
-            else
-                continue;
-        }
-        else if ( account_number == selected_account )
-        {
-            str_description = gsb_data_scheduled_get_notes ( scheduled_number );
-
-            if ( !str_description || !strlen ( str_description ) )
-                str_description = gsb_data_payee_get_name (
-                            gsb_data_scheduled_get_party_number ( scheduled_number ), TRUE );
-
-            amount = gsb_data_scheduled_get_amount ( scheduled_number );
-        }
-        else
-            continue;
-
-        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 */
-        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;
-            }
-            if ( g_date_valid ( date ) == FALSE )
-                return;
-            str_date = gsb_format_gdate ( date );
-
-            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 );
-    }
-
-    /* search data from the past */
-    bet_estimate_refresh_historical_data ( tree_model, date_min, date_max );
+    bet_estimate_refresh_scheduled_data ( tree_model,
+                        selected_account,
+                        date_min,
+                        date_max );
 
     g_free ( date_min );
     g_free ( date_max );
@@ -1153,7 +956,7 @@
     g_object_set_data (G_OBJECT(notebook), "bet_account_treeview", tree_view);
 
     /* create duration selection */
-    vbox = bet_estimate_get_duration_widget ( vbox );
+    bet_estimate_get_duration_widget ( vbox );
 }
 
 
@@ -1401,6 +1204,7 @@
         gsb_fyear_hide_iter_by_name ( bet_fyear_model, str_year );
         g_free ( str_year );
     }
+
     /* création de la liste des données */
     tree_view = bet_estimate_get_historical_data ( page );
     g_object_set_data ( G_OBJECT ( notebook ), "bet_historical_treeview", tree_view );
@@ -1470,7 +1274,7 @@
     GtkWidget* main_vbox;
     GtkWidget *label;
     GtkWidget *spin_button, *button_1, *button_2, *button_3, *button_4;
-    GtkWidget *widget;
+    GtkWidget *widget = NULL;
     GtkWidget *hbox;
     GtkWidget *previous = NULL;
     GtkSizeGroup *size_group;
@@ -1548,7 +1352,6 @@
     gtk_box_pack_start ( GTK_BOX ( hbox ), button_3, FALSE, FALSE, 5) ;
     gtk_box_pack_start ( GTK_BOX ( hbox ), button_4, FALSE, FALSE, 5) ;
 
-    
     /* partie mensuelle */
     label = gtk_label_new ( _("Duration estimation") );
     gtk_box_pack_start ( GTK_BOX ( main_vbox ), label, FALSE, FALSE, 5) ;
@@ -2223,6 +2026,256 @@
         } while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &iter ) );
     }
 }
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+void bet_estimate_refresh_scheduled_data ( GtkTreeModel *tab_model,
+                        gint selected_account,
+                        GDate *date_min,
+                        GDate *date_max )
+{
+    GtkTreeIter iter;
+    GSList* tmp_list;
+
+    tmp_list = gsb_data_scheduled_get_scheduled_list();
+
+    while (tmp_list)
+    {
+        gchar *str_amount;
+        gchar *str_debit = NULL;
+        gchar *str_credit = NULL;
+        const gchar *str_description = NULL;
+        gchar *str_date;
+        gint scheduled_number;
+        gint account_number;
+        gint transfer_account_number;
+        GDate *date;
+        GValue date_value = {0, };
+        gsb_real amount;
+
+        scheduled_number = gsb_data_scheduled_get_scheduled_number ( tmp_list->data );
+
+        tmp_list = tmp_list->next;
+
+        /* ignore children scheduled operations */
+        if (gsb_data_scheduled_get_mother_scheduled_number ( scheduled_number ) )
+            continue;
+
+        /* ignore scheduled operations of other account */
+        account_number = gsb_data_scheduled_get_account_number ( scheduled_number );
+
+        if ( gsb_data_scheduled_is_transfer ( scheduled_number ) )
+        {
+            transfer_account_number = gsb_data_scheduled_get_account_number_transfer (
+                        scheduled_number );
+            if ( transfer_account_number == selected_account )
+            {
+                str_description = g_strdup_printf ( _("Transfer between account: %s\n"
+                        "and account: %s"),
+                        gsb_data_account_get_name ( transfer_account_number ),
+                        gsb_data_account_get_name ( account_number ) );
+            
+                amount = gsb_real_opposite ( gsb_data_scheduled_get_amount (
+                        scheduled_number ) );
+            }
+            else if ( account_number == selected_account )
+            {
+                str_description = g_strdup_printf ( _("Transfer between account: %s\n"
+                        "and account: %s"),
+                        gsb_data_account_get_name ( account_number ),
+                        gsb_data_account_get_name ( transfer_account_number ) );
+
+                amount = gsb_data_scheduled_get_amount ( scheduled_number );
+            }
+            else
+                continue;
+        }
+        else if ( account_number == selected_account )
+        {
+            str_description = gsb_data_scheduled_get_notes ( scheduled_number );
+
+            if ( !str_description || !strlen ( str_description ) )
+                str_description = gsb_data_payee_get_name (
+                            gsb_data_scheduled_get_party_number ( scheduled_number ), TRUE );
+
+            amount = gsb_data_scheduled_get_amount ( scheduled_number );
+        }
+        else
+            continue;
+
+        str_amount = 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 */
+        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;
+            }
+            if ( g_date_valid ( date ) == FALSE )
+                return;
+            str_date = gsb_format_gdate ( date );
+
+            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 ( tab_model ), &iter, NULL );
+            gtk_tree_store_set_value ( GTK_TREE_STORE ( tab_model ), &iter,
+                        SPP_ESTIMATE_TREE_SORT_DATE_COLUMN,
+                        &date_value );
+            gtk_tree_store_set ( GTK_TREE_STORE ( tab_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 );
+            date = gsb_scheduler_get_next_date ( scheduled_number, date );
+        }
+
+        g_free ( str_amount );
+        if ( str_credit )
+            g_free ( str_credit );
+        if ( str_debit )
+            g_free ( str_debit );
+    }
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+void bet_estimate_refresh_transactions_data ( GtkTreeModel *tab_model,
+                        gint selected_account,
+                        GDate *date_min,
+                        GDate *date_max )
+{
+    GtkTreeIter iter;
+    GSList* tmp_list;
+
+    /* search transactions of the account which are in the future */
+    tmp_list = gsb_data_transaction_get_transactions_list ( );
+
+    while ( tmp_list )
+    {
+        gchar* str_amount;
+        gchar* str_debit = NULL;
+        gchar* str_credit = NULL;
+        const gchar* str_description;
+        gchar* str_date;
+        gint transaction_number;
+        gint transfer_number;
+        gint account_number;
+        gint transfer_account_number;
+        const GDate *date;
+        GValue date_value = {0, };
+        gsb_real amount;
+
+        transaction_number = gsb_data_transaction_get_transaction_number ( tmp_list->data );
+        tmp_list = tmp_list -> next;
+
+        account_number =  gsb_data_transaction_get_account_number ( transaction_number );
+        if ( account_number != selected_account )
+            continue;
+
+        date = gsb_data_transaction_get_date ( transaction_number );
+        /* ignore transaction which are before date_min (today) */
+        if ( g_date_compare ( date, date_min ) <= 0 )
+            continue;
+        /* ignore transaction which are after date_max */
+        if ( g_date_compare (date, date_max ) > 0 )
+            continue;
+
+        /* ignore splitted transactions */
+        if ( gsb_data_transaction_get_mother_transaction_number (
+         transaction_number ) != 0 )
+            continue;
+
+        str_date = gsb_format_gdate ( date );
+        g_value_init ( &date_value, G_TYPE_DATE );
+        g_value_set_boxed ( &date_value, date );
+
+        amount = gsb_data_transaction_get_amount ( transaction_number );
+        str_amount = gsb_real_get_string ( amount );
+
+        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);
+
+        transfer_number =
+                        gsb_data_transaction_get_contra_transaction_number (
+                        transaction_number );
+        if ( transfer_number > 0 )
+        {
+            transfer_account_number = gsb_data_transaction_get_account_number (
+                        transfer_number );
+            str_description = g_strdup_printf ( _("Transfer between account: %s\n"
+                        "and account: %s"),
+                        gsb_data_account_get_name ( account_number ),
+                        gsb_data_account_get_name ( transfer_account_number ) );
+        }
+        else
+        {
+            str_description = gsb_data_transaction_get_notes ( transaction_number );
+
+            if (!str_description || !strlen (str_description))
+                str_description = gsb_data_payee_get_name (
+                            gsb_data_transaction_get_party_number ( transaction_number ), TRUE );
+        }
+
+        /* add a line in the estimate array */
+        gtk_tree_store_append ( GTK_TREE_STORE ( tab_model ), &iter, NULL );
+        gtk_tree_store_set_value ( GTK_TREE_STORE ( tab_model ), &iter,
+                        SPP_ESTIMATE_TREE_SORT_DATE_COLUMN,
+                        &date_value );
+        gtk_tree_store_set ( GTK_TREE_STORE ( tab_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 );
+    }
+}
+
+
 /**
  *
  *
@@ -2286,15 +2339,15 @@
         /* add a line in the estimate array */
         gtk_tree_store_append ( GTK_TREE_STORE ( tab_model ), &tab_iter, NULL );
         gtk_tree_store_set_value ( GTK_TREE_STORE ( tab_model ), &tab_iter,
-                     SPP_ESTIMATE_TREE_SORT_DATE_COLUMN,
-                     &date_value );
+                        SPP_ESTIMATE_TREE_SORT_DATE_COLUMN,
+                        &date_value );
         gtk_tree_store_set ( GTK_TREE_STORE ( tab_model ), &tab_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);
+                        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 );
@@ -2312,4 +2365,7 @@
  *
  *
  * */
+/* Local Variables: */
+/* c-basic-offset: 4 */
+/* End: */
 #endif /* ENABLE_BALANCE_ESTIMATE */

Index: gsb_currency.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_currency.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- gsb_currency.c	23 Jan 2010 19:35:10 -0000	1.56
+++ gsb_currency.c	24 Jan 2010 10:58:01 -0000	1.57
@@ -404,7 +404,6 @@
 }
 
 
-
 /**
  * Check if a transaction need an exchange rate and fees with its
  * account
@@ -506,6 +505,9 @@
     gint row = 0;
     gint link_number;
 
+    if ( account_currency_number == 0 || transaction_currency_number == 0 )
+        return;
+
     if ( !force
      &&
      ( cache = gsb_currency_config_get_cached_exchange (



More information about the cvs mailing list