[grisbi-cvs] grisbi/src Makefile.am, 1.161, 1.162 balance_estimate_config.c, 1.4, 1.5 balance_estimate_data.c, 1.1, 1.2 balance_estimate_data.h, 1.1, 1.2 balance_estimate_tab.c, 1.37, 1.38 balance_estimate_tab.h, 1.6, 1.7 gsb_file_load.c, 1.205, 1.206 gsb_file_save.c, 1.147, 1.148 traitement_variables.c, 1.184, 1.185

Pierre Biava pbiava at users.sourceforge.net
Sun Jan 31 21:47:26 CET 2010


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

Modified Files:
	Makefile.am balance_estimate_config.c balance_estimate_data.c 
	balance_estimate_data.h balance_estimate_tab.c 
	balance_estimate_tab.h gsb_file_load.c gsb_file_save.c 
	traitement_variables.c 
Log Message:
adding functionality to the module estimation: data backup. Module EXPERMENTAL

Index: balance_estimate_config.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_config.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- balance_estimate_config.c	30 Jan 2010 17:04:12 -0000	1.4
+++ balance_estimate_config.c	31 Jan 2010 20:47:24 -0000	1.5
@@ -28,6 +28,7 @@
 
 /*START_INCLUDE*/
 #include "balance_estimate_config.h"
+#include "./balance_estimate_data.h"
 #include "./balance_estimate_tab.h"
 #include "./parametres.h"
 #include "./menu.h"
@@ -94,7 +95,7 @@
     paddingbox = new_paddingbox_with_title ( vbox_pref, FALSE,
                         _("Calculation of period") );
 
-    bet_estimate_get_duration_widget ( paddingbox, TRUE );
+    bet_parameter_get_duration_widget ( paddingbox, TRUE );
 
     /* Sources of historical data */
     paddingbox = new_paddingbox_with_title ( vbox_pref, FALSE,
@@ -115,11 +116,11 @@
  * */
 GtkWidget *bet_config_select_historical_data ( GtkWidget *container )
 {
-    GtkWidget *widget;
+    //~ GtkWidget *widget;
     GtkWidget *hbox;
     GtkWidget *button_1, *button_2;
-    gchar *str_year;
-    gint year;
+    //~ gchar *str_year;
+    //~ gint year;
 
     /* Choix des données sources */
     hbox = gtk_hbox_new ( FALSE, 5 );
@@ -133,24 +134,44 @@
                         GTK_RADIO_BUTTON ( button_1 ),
                         _("Budgetary lines") );
     gtk_widget_set_name ( button_2, "button_2" );
+    g_signal_connect (G_OBJECT ( button_2 ),
+                        "released",
+                        G_CALLBACK ( bet_historical_data_clicked ),
+                        NULL );
 
     gtk_box_pack_start ( GTK_BOX ( hbox ), button_1, FALSE, FALSE, 5) ;
     gtk_box_pack_start ( GTK_BOX ( hbox ), button_2, FALSE, FALSE, 5) ;
 
     /* création du sélecteur de périod */
-    if ( bet_fyear_create_combobox_store ( ) )
-    {
-        widget = gsb_fyear_make_combobox_new ( bet_fyear_model_filter, TRUE );
-        gtk_widget_set_tooltip_text ( GTK_WIDGET ( widget ),
-                          SPACIFY(_("Choose the financial year or 12 months rolling") ) );
-        gtk_box_pack_start ( GTK_BOX ( hbox ), widget, FALSE, FALSE, 5);
+    //~ if ( bet_fyear_create_combobox_store ( ) )
+    //~ {
+        //~ widget = gsb_fyear_make_combobox_new ( bet_fyear_model_filter, TRUE );
+        //~ gtk_widget_set_name ( GTK_WIDGET ( widget ), "fyear_combo" );
+        //~ gtk_widget_set_tooltip_text ( GTK_WIDGET ( widget ),
+                          //~ SPACIFY(_("Choose the financial year or 12 months rolling") ) );
+        //~ g_signal_connect ( G_OBJECT ( widget ),
+                        //~ "changed",
+                        //~ G_CALLBACK (bet_historical_fyear_clicked),
+                        //~ NULL );
 
-        /* hide the present financial year */
-        year = g_date_get_year ( gdate_today ( ) );
-        str_year = utils_str_itoa ( year );
-        gsb_fyear_hide_iter_by_name ( bet_fyear_model, str_year );
-        g_free ( str_year );
-    }
+        //~ gtk_box_pack_start ( GTK_BOX ( hbox ), widget, FALSE, FALSE, 5);
+
+        //~ /* hide the present financial year */
+        //~ year = g_date_get_year ( gdate_today ( ) );
+        //~ str_year = utils_str_itoa ( year );
+        //~ gsb_fyear_hide_iter_by_name ( bet_fyear_model, str_year );
+        //~ g_free ( str_year );
+
+        //~ /* show the old choice */
+        //~ if ( etat.bet_hist_fyear > 0 )
+        //~ {
+            //~ gsb_fyear_select_iter_by_number ( widget,
+                        //~ bet_fyear_model,
+                        //~ bet_fyear_model_filter,
+                        //~ etat.bet_hist_fyear );
+        //~ }
+
+    //~ }
     return hbox;
 }
 

Index: balance_estimate_tab.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_tab.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- balance_estimate_tab.h	28 Jan 2010 20:25:12 -0000	1.6
+++ balance_estimate_tab.h	31 Jan 2010 20:47:24 -0000	1.7
@@ -25,13 +25,12 @@
 /* START_INCLUDE_H */
 /* END_INCLUDE_H */
 
-typedef struct _bet_range           SBR;
-typedef struct _historical          SH;
-
 /* START_DECLARATION */
 GtkWidget *bet_create_balance_estimate_tab ( void );
-GtkWidget *bet_estimate_get_duration_widget ( GtkWidget *container, gboolean config );
+void bet_historical_fyear_clicked ( GtkWidget *combo, gpointer data );
 gboolean bet_fyear_create_combobox_store ( void );
+void bet_historical_data_clicked ( GtkWidget *togglebutton, gpointer data );
+GtkWidget *bet_parameter_get_duration_widget ( GtkWidget *container, gboolean config );
 void bet_update_balance_estimate_tab ( void );
 /* END_DECLARATION */
 

Index: traitement_variables.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/traitement_variables.c,v
retrieving revision 1.184
retrieving revision 1.185
diff -u -d -r1.184 -r1.185
--- traitement_variables.c	28 Jan 2010 20:25:12 -0000	1.184
+++ traitement_variables.c	31 Jan 2010 20:47:24 -0000	1.185
@@ -376,9 +376,9 @@
     categ_tree_model = NULL;
 
     /* initializes the variables for the estimate balance module */
-     etat.bet_deb_period = 1;
+    etat.bet_deb_period = 1;
     etat.bet_end_period = 1;
-    etat.bet_spin_range = 1;
+    etat.bet_spin_range = 0;
     etat.bet_months = 1;
     etat.bet_hist_data = 0;
     etat.bet_hist_fyear = 0;

Index: gsb_file_save.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_file_save.c,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -d -r1.147 -r1.148
--- gsb_file_save.c	29 Jan 2010 18:21:06 -0000	1.147
+++ gsb_file_save.c	31 Jan 2010 20:47:24 -0000	1.148
@@ -83,6 +83,9 @@
 static gulong gsb_file_save_bank_part ( gulong iterator,
                         gulong *length_calculated,
                         gchar **file_content );
+static gulong gsb_file_save_bet_part ( gulong iterator,
+                        gulong *length_calculated,
+                        gchar **file_content );
 static gulong gsb_file_save_color_part ( gulong iterator,
                         gulong *length_calculated,
                         gchar **file_content,
@@ -119,7 +122,6 @@
                         gulong *length_calculated,
                         gchar **file_content,
                         gint archive_number );
-//~ static gchar *gsb_file_save_real_to_string ( gsb_real number );
 static gulong gsb_file_save_reconcile_part ( gulong iterator,
                         gulong *length_calculated,
                         gchar **file_content );
@@ -200,6 +202,7 @@
     gint import_rule_part;
     gint partial_balance_part;
     gint logo_part;
+    gint bet_part;
 
     struct stat buf;
 
@@ -246,6 +249,7 @@
     import_rule_part = 50;
     partial_balance_part = 50;
     logo_part = 65536;
+    bet_part = 250;
     
     length_calculated = general_part
 	+ account_part * gsb_data_account_get_accounts_amount ()
@@ -264,6 +268,10 @@
     + partial_balance_part * g_slist_length ( gsb_data_partial_balance_get_list ())
     + logo_part;
 
+#ifdef ENABLE_BALANCE_ESTIMATE
+    length_calculated += bet_part;
+#endif /* ENABLE_BALANCE_ESTIMATE */
+
     iterator = 0;
     file_content = g_malloc0 ( length_calculated );
 
@@ -353,6 +361,12 @@
 						&length_calculated,
 						&file_content );
 
+#ifdef ENABLE_BALANCE_ESTIMATE
+    iterator = gsb_file_save_bet_part ( iterator,
+                        &length_calculated,
+                        &file_content );
+#endif /* ENABLE_BALANCE_ESTIMATE */
+
     iterator = gsb_file_save_report_part ( iterator,
 					   &length_calculated,
 					   &file_content,
@@ -2571,6 +2585,48 @@
 }
 
 
+/**
+ * save the balance estimate part
+ *
+ * \param iterator the current iterator
+ * \param length_calculated a pointer to the variable lengh_calculated
+ * \param file_content a pointer to the variable file_content
+ *
+ * \return the new iterator
+ * */
+gulong gsb_file_save_bet_part ( gulong iterator,
+                        gulong *length_calculated,
+                        gchar **file_content )
+{
+    gchar *new_string;
+
+    /* save the general informations */
+    new_string = g_markup_printf_escaped ( "\t<Bet\n"
+                        "\t\tAc=\"%d\"\n"
+                        "\t\tBdte=\"%d\"\n"
+                        "\t\tEdte=\"%d\"\n"
+                        "\t\tNbre=\"%d\"\n"
+                        "\t\tUT=\"%d\"\n"
+                        "\t\tSD=\"%d\"\n"
+                        "\t\tFi=\"%d\" />\n",
+    etat.bet_last_account,
+    etat.bet_deb_period,
+    etat.bet_end_period,
+    etat.bet_months,
+    etat.bet_spin_range,
+    etat.bet_hist_data,
+    etat.bet_hist_fyear );
+
+    /* append the new string to the file content
+     * and return the new iterator */
+
+    return gsb_file_save_append_part ( iterator,
+				       length_calculated,
+				       file_content,
+				       new_string );
+}
+
+
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */

Index: balance_estimate_data.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_data.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- balance_estimate_data.h	31 Jan 2010 07:50:15 -0000	1.1
+++ balance_estimate_data.h	31 Jan 2010 20:47:24 -0000	1.2
@@ -4,14 +4,44 @@
 #include <gtk/gtk.h>
 
 /* START_INCLUDE_H */
+#include "./gsb_real.h"
 /* END_INCLUDE_H */
 
 
 typedef struct _bet_range           SBR;
 typedef struct _historical          SH;
 
+struct _bet_range
+{
+    gboolean first_pass;
+    GDate *min_date;
+    GDate *max_date;
+    gsb_real min_balance;
+    gsb_real max_balance;
+    gsb_real current_balance;
+};
+
+struct _historical
+{
+    gint div;
+	gint account_nb;
+    SBR	*sbr;
+	GHashTable *list_sub_div;
+};
+
 
 /* START_DECLARATION */
+gchar *bet_data_get_div_name (gint div_num,
+                        gint sub_div,
+                        const gchar *return_value_error );
+gboolean bet_data_populate_div ( gint transaction_number,
+                        GHashTable  *list_div );
+gboolean bet_data_set_div_ptr ( gint type_div );
+
+SBR *initialise_struct_bet_range ( void );
+SH *initialise_struct_historical ( void );
+void free_struct_bet_range ( SBR *sbr );
+void free_struct_historical ( SH *sh );
 
 /* END_DECLARATION */
 

Index: Makefile.am
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/Makefile.am,v
retrieving revision 1.161
retrieving revision 1.162
diff -u -d -r1.161 -r1.162
--- Makefile.am	24 Jan 2010 10:58:01 -0000	1.161
+++ Makefile.am	31 Jan 2010 20:47:24 -0000	1.162
@@ -70,7 +70,7 @@
 	gsb_data_fyear.c	\
 	gsb_data_import_rule.c	\
 	gsb_data_mix.c		\
-    gsb_data_partial_balance.c   \
+        gsb_data_partial_balance.c   \
 	gsb_data_payee.c	\
 	gsb_data_payment.c		\
 	gsb_data_print_config.c		\
@@ -145,7 +145,8 @@
 	utils_font.c		\
 	utils_operations.c	\
 	utils_str.c		\
-	balance_estimate_config.c\
+	balance_estimate_config.c \
+        balance_estimate_data.c \
 	balance_estimate_tab.c
 
 grisbi_INCLUDES =		\
@@ -154,30 +155,31 @@
 	affichage.h		\
 	affichage_liste.h	\
 	barre_outils.h		\
-        balance_estimate_config.h  \
+        balance_estimate_config.h \
+        balance_estimate_data.h \
         balance_estimate_tab.h  \
 	categories_onglet.h	\
 	classement_echeances.h	\
 	comptes_onglet.h	\
-    csv_parse.h             \
+        csv_parse.h             \
 	custom_list.h		\
-    etats_affiche.h         \
-    etats_csv.h             \
-    etats_html.h            \
-    export.h                \
-    export_csv.h            \
-    go-charmap-sel.h        \
-    go-optionmenu.h         \
+        etats_affiche.h         \
+        etats_csv.h             \
+        etats_html.h            \
+        export.h                \
+        export_csv.h            \
+        go-charmap-sel.h        \
+        go-optionmenu.h         \
 	gsb_account.h		\
 	gsb_account_property.h	\
 	gsb_archive_config.h	\
 	gsb_assistant.h		\
 	gsb_assistant_account.h		\
 	gsb_assistant_archive.h		\
-	gsb_assistant_archive_export.h		\
+	gsb_assistant_archive_export.h \
 	gsb_assistant_file.h		\
 	gsb_assistant_first.h		\
-	gsb_assistant_reconcile_config.h		\
+	gsb_assistant_reconcile_config.h \
 	gsb_autofunc.h		\
 	gsb_automem.h		\
 	gsb_bank.h		\
@@ -185,7 +187,7 @@
 	gsb_combo_box.h		\
 	gsb_calendar.h		\
 	gsb_calendar_entry.h	\
-    gsb_currency.h		\
+        gsb_currency.h		\
 	gsb_currency_config.h	\
 	gsb_currency_link_config.h	\
 	gsb_data_account.h	\
@@ -200,7 +202,7 @@
 	gsb_data_fyear.h	\
 	gsb_data_import_rule.h	\
 	gsb_data_mix.h		\
-    gsb_data_partial_balance.h   \
+        gsb_data_partial_balance.h   \
 	gsb_data_payee.h	\
 	gsb_data_payment.h		\
 	gsb_data_print_config.h		\
@@ -226,14 +228,14 @@
 	gsb_fyear_config.h	\
 	gsb_payment_method.h	\
 	gsb_payment_method_config.h	\
-    gsb_plugins.h           \
+        gsb_plugins.h           \
 	gsb_real.h		\
 	gsb_reconcile.h		\
 	gsb_reconcile_config.h	\
 	gsb_reconcile_list.h	\
 	gsb_reconcile_sort_config.h	\
 	gsb_report.h		\
-    gsb_status.h            \
+        gsb_status.h            \
 	gsb_select_icon.h 	\
 	gsb_scheduler.h		\
 	gsb_scheduler_list.h	\
@@ -260,11 +262,11 @@
 	main.h			\
 	main_cunit.h			\
 	menu.h			\
-    meta_budgetary.h        \
-    meta_categories.h       \
-    meta_payee.h            \
-    metatree.h              \
-    mouse.h                 \
+        meta_budgetary.h        \
+        meta_categories.h       \
+        meta_payee.h            \
+        metatree.h              \
+        mouse.h                 \
 	navigation.h		\
 	parametres.h		\
 	parse_cmdline.h		\

Index: gsb_file_load.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_file_load.c,v
retrieving revision 1.205
retrieving revision 1.206
diff -u -d -r1.205 -r1.206
--- gsb_file_load.c	23 Jan 2010 19:35:10 -0000	1.205
+++ gsb_file_load.c	31 Jan 2010 20:47:24 -0000	1.206
@@ -88,6 +88,8 @@
                         const gchar **attribute_values );
 static void gsb_file_load_bank ( const gchar **attribute_names,
                         const gchar **attribute_values );
+static void gsb_file_load_bet_part ( const gchar **attribute_names,
+                        const gchar **attribute_values );
 static gboolean gsb_file_load_check_new_structure ( gchar *file_content );
 static void gsb_file_load_color_part ( const gchar **attribute_names,
                         const gchar **attribute_values );
@@ -619,6 +621,14 @@
     return;
     }
 
+#ifdef ENABLE_BALANCE_ESTIMATE
+    if ( !strcmp ( element_name, "Bet" ) )
+    {
+        gsb_file_load_bet_part ( attribute_names, attribute_values );
+        return;
+    }
+#endif /* ENABLE_BALANCE_ESTIMATE */
+
     if ( !strcmp ( element_name,
                         "Report" ))
     {
@@ -3561,6 +3571,88 @@
 
 
 /**
+ * load the balance estimate part in the grisbi file
+ *
+ * \param attribute_names
+ * \param attribute_values
+ *
+ * */
+void gsb_file_load_bet_part ( const gchar **attribute_names,
+                        const gchar **attribute_values )
+{
+    gint i=0;
+
+    if ( !attribute_names[i] )
+    return;
+
+    do
+    {
+    /*     we test at the beginning if the attribute_value is NULL, if yes, */
+    /*        go to the next */
+    if ( !strcmp ( attribute_values[i], "(null)") )
+    {
+        i++;
+        continue;
+    }
+
+    if ( !strcmp ( attribute_names[i], "Ac" ) )
+    {
+        etat.bet_last_account = utils_str_atoi ( attribute_values[i] );
+        i++;
+        continue;
+    }
+
+    if ( !strcmp ( attribute_names[i], "Bdte" ) )
+    {
+        etat.bet_deb_period = utils_str_atoi ( attribute_values[i] );
+        i++;
+        continue;
+    }
+
+    if ( !strcmp ( attribute_names[i], "Edte" ) )
+    {
+        etat.bet_end_period = utils_str_atoi ( attribute_values[i] );
+        i++;
+        continue;
+    }
+
+    if ( !strcmp ( attribute_names[i], "Nbre" ) )
+    {
+        etat.bet_months = utils_str_atoi ( attribute_values[i] );
+        i++;
+        continue;
+    }
+
+    if ( !strcmp ( attribute_names[i], "UT" ) )
+    {
+        etat.bet_spin_range = utils_str_atoi ( attribute_values[i] );
+        i++;
+        continue;
+    }
+
+    if ( !strcmp ( attribute_names[i], "SD" ) )
+    {
+        etat.bet_hist_data = utils_str_atoi ( attribute_values[i] );
+        i++;
+        continue;
+    }
+
+    if ( !strcmp ( attribute_names[i], "Fi" ) )
+    {
+        etat.bet_hist_fyear = utils_str_atoi ( attribute_values[i] );
+        i++;
+        continue;
+    }
+
+    /* normally, shouldn't come here */
+    i++;
+    }
+
+    while ( attribute_names[i] );
+}
+
+
+/**
  * load the report structure in the grisbi file
  *
  * \param attribute_names

Index: balance_estimate_tab.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_tab.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- balance_estimate_tab.c	30 Jan 2010 17:04:12 -0000	1.37
+++ balance_estimate_tab.c	31 Jan 2010 20:47:24 -0000	1.38
@@ -40,7 +40,7 @@
 
 /*START_INCLUDE*/
 #include "balance_estimate_tab.h"
-//~ #include "balance_estimate_config.h"
+#include "./balance_estimate_data.h"
 #include "./utils_dates.h"
 #include "./gsb_data_account.h"
 #include "./gsb_data_budget.h"
@@ -54,6 +54,7 @@
 #include "./gsb_scheduler.h"
 #include "./gsb_transactions_list_sort.h"
[...1364 lines suppressed...]
+    {
+        gchar *str_current_balance;
+        gsb_real current_balance;
+        SBR *tmp_range;
+
+        gtk_tree_model_get ( model, &iter,
+                        SPP_ESTIMATE_TREE_AMOUNT_COLUMN, &str_current_balance, -1 ); 
+        current_balance = gsb_real_get_from_string ( str_current_balance );
+
+        tmp_range = initialise_struct_bet_range ( );
+        tmp_range -> first_pass = TRUE;
+        tmp_range -> current_balance = current_balance;
+
+        gtk_tree_model_foreach ( GTK_TREE_MODEL ( model ),
+                        bet_update_average_column, tmp_range );
+    }
+}
 /**
  *
  *

Index: balance_estimate_data.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_data.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- balance_estimate_data.c	31 Jan 2010 07:51:12 -0000	1.1
+++ balance_estimate_data.c	31 Jan 2010 20:47:24 -0000	1.2
@@ -37,7 +37,6 @@
 #include "./gsb_data_scheduled.h"
 #include "./gsb_data_transaction.h"
 #include "./gsb_fyear.h"
-#include "./gsb_real.h"
 #include "./gsb_scheduler.h"
 #include "./gsb_transactions_list_sort.h"
 #include "./main.h"
@@ -49,30 +48,9 @@
 /*END_INCLUDE*/
 
 
-struct _bet_range
-{
-    gboolean first_pass;
-    GDate *min_date;
-    GDate *max_date;
-    gsb_real min_balance;
-    gsb_real max_balance;
-    gsb_real current_balance;
-};
-
-struct _historical
-{
-    gint div;
-	gint account_nb;
-    SBR	*sbr;
-	GHashTable *list_sub_div;
-};
-
-
 /*START_STATIC*/
-static SBR *initialise_struct_bet_range ( void );
-static SH *initialise_struct_historical ( void );
-static void free_struct_bet_range ( SBR *sbr );
-static void free_struct_historical ( SH *sh );
+static gboolean bet_data_update_div ( SH *sh, gint transaction_number,
+                        gint sub_div );
 /*END_STATIC*/
 
 /*START_EXTERN*/
@@ -82,6 +60,116 @@
 /*END_EXTERN*/
 
 
+/* pointeurs définis en fonction du type de données catégories ou IB */
+gint (*ptr_div) ( gint transaction_num );
+gint (*ptr_sub_div) ( gint transaction_num );
+gchar* (*ptr_div_name) ( gint div_num, gint sub_div, const gchar *return_value_error );
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+gboolean bet_data_set_div_ptr ( gint type_div )
+{
+    if ( type_div == 0 )
+    {
+        ptr_div = &gsb_data_transaction_get_category_number;
+        ptr_sub_div = &gsb_data_transaction_get_sub_category_number;
+        ptr_div_name = &gsb_data_category_get_name;
+    }
+    else
+    {
+        ptr_div = &gsb_data_transaction_get_budgetary_number;
+        ptr_sub_div = &gsb_data_transaction_get_sub_budgetary_number;
+        ptr_div_name = &gsb_data_budget_get_name;
+    }
+
+    return FALSE;
+}
+/**
+ *
+ *
+ *
+ *
+ * */
+gchar *bet_data_get_div_name (gint div_num,
+                        gint sub_div,
+                        const gchar *return_value_error )
+{
+    return g_strdup ( ptr_div_name ( div_num, sub_div, FALSE ) );
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+gboolean bet_data_populate_div ( gint transaction_number,
+                        GHashTable  *list_div )
+{
+    gint div = 0;
+    gint sub_div = 0;
+    SH *sh = NULL;
+
+    div = ptr_div ( transaction_number );
+    if ( div > 0 )
+        sub_div = ptr_sub_div ( transaction_number );
+    else
+        return FALSE;
+    
+    if ( (sh = g_hash_table_lookup ( list_div, utils_str_itoa ( div ) ) ) )
+        bet_data_update_div ( sh, transaction_number, sub_div );
+    else
+    {
+        sh = initialise_struct_historical ( );
+        sh -> div = div;
+        sh -> account_nb = gsb_data_transaction_get_account_number ( transaction_number );
+        bet_data_update_div ( sh, transaction_number, sub_div );
+        g_hash_table_insert ( list_div, utils_str_itoa ( div ), sh );
+    }
+
+    return FALSE;
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+gboolean bet_data_update_div ( SH *sh, gint transaction_number, gint sub_div )
+{
+    SBR *sbr = ( SBR*) sh -> sbr;
+    gsb_real amount;
+    SH *tmp_sh = NULL;
+
+    amount = gsb_data_transaction_get_amount ( transaction_number );
+    sbr-> current_balance = gsb_real_add ( sbr -> current_balance, amount );
+
+    if ( sub_div == -1 )
+        return FALSE;
+
+    if ( ( tmp_sh = g_hash_table_lookup ( sh -> list_sub_div, utils_str_itoa ( sub_div ) ) ) )
+        bet_data_update_div ( tmp_sh, transaction_number, -1 );
+    else
+    {
+        tmp_sh = initialise_struct_historical ( );
+        tmp_sh -> div = sub_div;
+        tmp_sh -> account_nb = gsb_data_transaction_get_account_number ( transaction_number );
+        bet_data_update_div ( tmp_sh, transaction_number, -1 );
+        g_hash_table_insert ( sh -> list_sub_div, utils_str_itoa ( sub_div ), tmp_sh );
+    }
+
+    return FALSE;
+}
+
+
 /**
  *
  *
@@ -128,7 +216,7 @@
 	sh = g_malloc ( sizeof ( SH ) );
     sh -> sbr = initialise_struct_bet_range ( );
     sh -> list_sub_div = g_hash_table_new_full ( g_int_hash,
-                        g_int_equal,
+                        g_str_equal,
                         NULL,
                         (GDestroyNotify) free_struct_historical );
 	return sh;



More information about the cvs mailing list