[grisbi-cvs] grisbi/src balance_estimate_config.c, 1.16, 1.17 balance_estimate_data.c, 1.24, 1.25 balance_estimate_future.c, 1.10, 1.11 balance_estimate_future.h, 1.6, 1.7 balance_estimate_tab.c, 1.67, 1.68 gsb_data_account.c, 1.104, 1.105 gsb_form.c, 1.163, 1.164 traitement_variables.c, 1.194, 1.195

Pierre Biava pbiava at users.sourceforge.net
Tue May 4 22:38:21 CEST 2010


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

Modified Files:
	balance_estimate_config.c balance_estimate_data.c 
	balance_estimate_future.c balance_estimate_future.h 
	balance_estimate_tab.c gsb_data_account.c gsb_form.c 
	traitement_variables.c 
Log Message:
Work on the budget module

Index: balance_estimate_config.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_config.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- balance_estimate_config.c	4 May 2010 12:27:52 -0000	1.16
+++ balance_estimate_config.c	4 May 2010 20:38:18 -0000	1.17
@@ -526,7 +526,7 @@
     gpointer data;
     gint account_number;
     gint months;
-devel_debug (NULL);
+
     name = gtk_widget_get_name ( GTK_WIDGET ( togglebutton ) );
     data = g_object_get_data ( G_OBJECT ( spin_button ), "bet_origin_signal");
 
@@ -534,10 +534,9 @@
         account_number = bet_config_get_account ( );
     else
         account_number = gsb_gui_navigation_get_current_account ( );
-printf ("account_number = %d\n", account_number);
+
     if ( g_strcmp0 ( name, "Year" ) == 0 )
     {
-        printf ("param = 1\n");
         gsb_data_account_set_bet_spin_range ( account_number, 1 );
         gtk_spin_button_set_range ( GTK_SPIN_BUTTON ( spin_button ), 1.0, 20.0 );
         months = gsb_data_account_get_bet_months ( account_number );
@@ -551,7 +550,6 @@
     }
     else
     {
-        printf ("param = 0\n");
         gsb_data_account_set_bet_spin_range ( account_number, 0 );
         gsb_data_account_set_bet_months ( account_number,
                         gtk_spin_button_get_value_as_int (
@@ -577,12 +575,12 @@
 {
     gint account_number;
     gint months;
-devel_debug (NULL);
+
     if ( GPOINTER_TO_INT ( data ) == 0 )
         account_number = bet_config_get_account ( );
     else
         account_number = gsb_gui_navigation_get_current_account ( );
-printf ("account_number = %d\n", account_number);
+
     months = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON ( spin_button ) );
     if ( gsb_data_account_get_bet_spin_range ( account_number ) == 1 )
         months *= 12;

Index: traitement_variables.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/traitement_variables.c,v
retrieving revision 1.194
retrieving revision 1.195
diff -u -d -r1.194 -r1.195
--- traitement_variables.c	4 May 2010 12:27:53 -0000	1.194
+++ traitement_variables.c	4 May 2010 20:38:18 -0000	1.195
@@ -30,6 +30,7 @@
 /*START_INCLUDE*/
 #include "traitement_variables.h"
 #include "./balance_estimate_data.h"
+#include "./balance_estimate_future.h"
 #include "./gsb_currency.h"
 #include "./gsb_data_account.h"
 #include "./gsb_data_archive.h"
@@ -388,6 +389,8 @@
 #ifdef ENABLE_BALANCE_ESTIMATE
     /* création de la liste des données à utiliser dans le tableau de résultats */
     bet_data_init_variables ( );
+    /* initialisation des boites de dialogues */
+    bet_future_initialise_dialog ( );
 #endif /* ENABLE_BALANCE_ESTIMATE */
     etat.bet_deb_period = 1;
 }

Index: gsb_form.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form.c,v
retrieving revision 1.163
retrieving revision 1.164
diff -u -d -r1.163 -r1.164
--- gsb_form.c	1 May 2010 21:09:23 -0000	1.163
+++ gsb_form.c	4 May 2010 20:38:18 -0000	1.164
@@ -1198,9 +1198,6 @@
 
     /* 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
 	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.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- gsb_data_account.c	4 May 2010 12:27:53 -0000	1.104
+++ gsb_data_account.c	4 May 2010 20:38:18 -0000	1.105
@@ -1393,7 +1393,7 @@
  * 
  * \param account_number no of the account
  * 
- * \return last number of reconcile or 0 if the account doesn't exist
+ * \return currency or 0 if the account doesn't exist
  * */
 gint gsb_data_account_get_currency ( gint account_number )
 {
@@ -3145,7 +3145,15 @@
     g_date_add_months ( tmp_date, 1 );
 
     if ( g_date_compare ( date_jour, tmp_date ) >= 0 )
-        gsb_data_account_set_bet_start_date ( account_number, tmp_date );
+    {
+        if ( g_date_get_month ( date_jour ) == g_date_get_month ( tmp_date ) )
+            gsb_data_account_set_bet_start_date ( account_number, tmp_date );
+        else
+        {
+            g_date_set_day ( date_jour, g_date_get_day ( tmp_date ) );
+            gsb_data_account_set_bet_start_date ( account_number, date_jour );
+        }
+    }
 
     g_date_free ( tmp_date );
 

Index: balance_estimate_future.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_future.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- balance_estimate_future.h	4 May 2010 12:27:52 -0000	1.6
+++ balance_estimate_future.h	4 May 2010 20:38:18 -0000	1.7
@@ -10,6 +10,7 @@
 
 
 /* START_DECLARATION */
+void bet_future_initialise_dialog ( void );
 gboolean bet_future_modify_line ( gint account_number,
                         gint number,
                         gint mother_row );

Index: balance_estimate_data.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_data.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- balance_estimate_data.c	4 May 2010 18:13:57 -0000	1.24
+++ balance_estimate_data.c	4 May 2010 20:38:18 -0000	1.25
@@ -1375,6 +1375,8 @@
     if ( etat.modification_fichier == 0 )
         modification_fichier ( TRUE );
 
+    bet_data_set_maj ( account_number, BET_MAJ_ESTIMATE );
+
     return FALSE;
 }
 
@@ -1598,6 +1600,8 @@
     if ( etat.modification_fichier == 0 )
         modification_fichier ( TRUE );
 
+    bet_data_set_maj ( account_number, BET_MAJ_ESTIMATE );
+
     return FALSE;
 }
 

Index: balance_estimate_tab.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_tab.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- balance_estimate_tab.c	4 May 2010 12:27:52 -0000	1.67
+++ balance_estimate_tab.c	4 May 2010 20:38:18 -0000	1.68
@@ -104,9 +104,12 @@
                         GtkTreeSelection *tree_selection );
 static void bet_array_list_redo_menu ( GtkWidget *menu_item,
                         GtkTreeSelection *tree_selection );
+static gboolean bet_array_list_replace_planned_line_by_transfert ( GtkTreeModel *tab_model,
+                        struct_transfert_data *transfert );
 static gint bet_array_list_schedule_line ( gint origine, gint account_number, gint number );
 static void bet_array_list_schedule_selected_line ( GtkWidget *menu_item,
                         GtkTreeSelection *tree_selection );
+static gboolean bet_array_list_select_path ( GtkWidget *tree_view, const gchar *str_path );
 static gboolean bet_array_list_set_background_color ( GtkWidget *tree_view );
 static void bet_array_list_traite_double_click ( GtkTreeView *tree_view );
 static void bet_array_list_update_balance ( GtkTreeModel *model );
@@ -146,6 +149,7 @@
 extern gint mise_a_jour_liste_echeances_auto_accueil;
 extern GtkWidget *notebook_general;
 extern gsb_real null_real;
+extern gint valeur_echelle_recherche_date_import;
 /*END_EXTERN*/
 
 enum bet_estimation_tree_columns {
@@ -487,6 +491,7 @@
                         bet_array_update_average_column, tmp_range );
 
     bet_array_list_set_background_color ( tree_view );
+    bet_array_list_select_path ( tree_view, "0" );
 }
 
 
@@ -720,10 +725,6 @@
 		                G_CALLBACK ( bet_array_list_button_press ),
 		                NULL );
 
-    gtk_widget_grab_focus ( tree_view );
-    gtk_tree_selection_select_path ( gtk_tree_view_get_selection ( GTK_TREE_VIEW ( tree_view ) ),
-                        gtk_tree_path_new_from_string ( "0" ) );
-
     gtk_widget_show_all ( page );
 
     return page;
@@ -1563,6 +1564,8 @@
                         SPP_ESTIMATE_TREE_SUB_DIV_COLUMN, &sub_div_nb,
                         -1 );
         bet_data_remove_div_hist ( account_number, number, sub_div_nb );
+        gtk_tree_store_remove ( GTK_TREE_STORE ( model ), &iter );
+
         bet_data_set_maj ( account_number, BET_MAJ_HISTORICAL );
     }
     else if ( origine == SPP_ORIGIN_FUTURE )
@@ -1574,8 +1577,6 @@
         bet_data_transfert_remove_line ( gsb_gui_navigation_get_current_account ( ), number );
     }
 
-    gtk_tree_store_remove ( GTK_TREE_STORE ( model ), &iter );
-
     tree_view = gtk_tree_selection_get_tree_view ( tree_selection );
     bet_array_list_set_background_color ( GTK_WIDGET ( tree_view ) );
     bet_array_list_update_balance ( model );
@@ -1734,7 +1735,6 @@
 
             if ( tmp_div_number == 0 || tmp_div_number != div_number )
                 continue;
-            //~ printf ("ligne analysée div_number = %d, sub_div_number = %d\n", tmp_div_number, tmp_sub_div_nb);
 
             if ( tmp_sub_div_nb == 0 || tmp_sub_div_nb == sub_div_nb )
             {
@@ -1897,10 +1897,20 @@
     gint account_number;
     GDate *date;
 
-    devel_debug (NULL);
+    devel_debug (gtk_entry_get_text ( GTK_ENTRY ( entry ) ));
     gtk_editable_select_region ( GTK_EDITABLE ( entry ), 0, 0 );
     account_number = gsb_gui_navigation_get_current_account ( );
+
     date = gsb_parse_date_string ( gtk_entry_get_text ( GTK_ENTRY ( entry ) ) );
+    if ( gsb_data_account_get_bet_auto_inc_month (  account_number ) )
+    {
+        GDate *old_date;
+
+        old_date = gsb_data_account_get_bet_start_date ( account_number );
+        if ( g_date_compare ( date, old_date ) != 0 )
+            gsb_data_account_set_bet_auto_inc_month ( account_number, FALSE );
+    }
+    
     gsb_data_account_set_bet_start_date ( account_number, date );
 
     if ( etat.modification_fichier == 0 )
@@ -1913,6 +1923,30 @@
 
 
 /**
+ * select the paths of the list
+ *
+ * \param tree_view, str_path
+ *
+ * \return FALSE
+ * */
+gboolean bet_array_list_select_path ( GtkWidget *tree_view, const gchar *str_path )
+{
+    GtkTreePath *path;
+    GtkTreeSelection *selection;
+
+    path = gtk_tree_path_new_from_string ( str_path );
+    selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW ( tree_view ) );
+
+    gtk_widget_grab_focus ( tree_view );
+    gtk_tree_selection_select_path ( selection, path );
+
+    gtk_tree_path_free ( path );
+
+    return FALSE;
+}
+
+
+/**
  * set the background colors of the list
  *
  * \param tree_view
@@ -2387,15 +2421,23 @@
 {
     gint account_number;
     gboolean value;
+    gint auto_inc_month;
     
     devel_debug_int (gtk_toggle_button_get_active ( togglebutton ));
 
     account_number = gsb_gui_navigation_get_current_account ( );
-    if ( ( value = gtk_toggle_button_get_active ( togglebutton ) ) !=
-        gsb_data_account_get_bet_auto_inc_month ( account_number ) )
+    auto_inc_month = gsb_data_account_get_bet_auto_inc_month ( account_number );
+
+    if ( ( value = gtk_toggle_button_get_active ( togglebutton ) ) != auto_inc_month )
     {
         gsb_data_account_set_bet_auto_inc_month ( account_number, value );
 
+        if ( value )
+        {
+            gsb_data_account_bet_update_initial_date_if_necessary ( account_number );
+            bet_data_set_maj ( account_number, BET_MAJ_ESTIMATE );
+        }
+
         if ( etat.modification_fichier == 0 )
             modification_fichier ( TRUE );
     }
@@ -2485,6 +2527,7 @@
                         SPP_ESTIMATE_TREE_AMOUNT_COLUMN, str_amount,
                         -1);
 
+        bet_array_list_replace_planned_line_by_transfert ( tab_model, transfert );
         g_value_unset ( &date_value );
         g_free ( str_date );
         g_free ( str_description );
@@ -2505,6 +2548,108 @@
  *
  *
  * */
+gboolean bet_array_list_replace_planned_line_by_transfert ( GtkTreeModel *tab_model,
+                        struct_transfert_data *transfert )
+{
+    GtkTreeIter iter;
+
+    if ( gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( tab_model ), &iter ) )
+    {
+        GtkTreeIter *tmp_iter = NULL;
+        gchar* str_date;
+        GDate *date_debut_comparaison;
+        GDate *date_fin_comparaison;
+        GDate *date;
+        gint scheduled_number;
+        gint origine;
+
+        date_debut_comparaison = g_date_new_dmy ( g_date_get_day ( transfert -> date ),
+                    g_date_get_month ( transfert -> date ),
+                    g_date_get_year ( transfert -> date ));
+        g_date_subtract_days ( date_debut_comparaison,
+                    valeur_echelle_recherche_date_import );
+
+        date_fin_comparaison = g_date_new_dmy ( g_date_get_day ( transfert -> date ),
+                    g_date_get_month ( transfert -> date ),
+                    g_date_get_year ( transfert -> date ));
+        g_date_add_days ( date_fin_comparaison,
+                    valeur_echelle_recherche_date_import );
+
+        do
+        {
+            gtk_tree_model_get ( GTK_TREE_MODEL ( tab_model ),
+                        &iter,
+                        SPP_ESTIMATE_TREE_ORIGIN_DATA, &origine,
+                        SPP_ESTIMATE_TREE_DIVISION_COLUMN, &scheduled_number,
+                        SPP_ESTIMATE_TREE_DATE_COLUMN, &str_date,
+                        -1 );
+
+            if ( origine != SPP_ORIGIN_SCHEDULED )
+                continue;
+
+            date = gsb_parse_date_string ( str_date );
+            if ( g_date_compare ( date, date_debut_comparaison ) < 0 )
+                continue;
+
+            if ( g_date_compare ( date, date_fin_comparaison ) > 0 )
+            {
+                if ( tmp_iter )
+                    gtk_tree_store_remove ( GTK_TREE_STORE ( tab_model ), tmp_iter );
+                break;
+            }
+
+            if ( transfert -> category_number )
+            {
+                /* on cherche une opération par sa catégorie */
+                gint tmp_category_number;
+                gint tmp_sub_category_number;
+
+                tmp_category_number = gsb_data_scheduled_get_category_number ( scheduled_number );
+                if ( transfert -> sub_category_number )
+                    tmp_sub_category_number = gsb_data_scheduled_get_sub_category_number (
+                                                    scheduled_number );
+
+                if ( transfert -> category_number == tmp_category_number
+                 &&
+                    transfert -> sub_category_number == tmp_sub_category_number )
+                {
+                    if ( g_date_compare ( date, transfert -> date ) == 0 )
+                    {
+                        gtk_tree_store_remove ( GTK_TREE_STORE ( tab_model ), &iter );
+                        break;
+                    }
+                    tmp_iter = gtk_tree_iter_copy ( &iter );
+                }
+            }
+            else if ( transfert -> budgetary_number )
+            {
+                /* on cherche une opération par son IB */
+                gint tmp_budget_number;
+                gint tmp_sub_budget_number;
+
+                tmp_budget_number = gsb_data_scheduled_get_budgetary_number ( scheduled_number );
+                if ( transfert -> sub_budgetary_number )
+                    tmp_sub_budget_number = gsb_data_scheduled_get_sub_budgetary_number (
+                                                    scheduled_number );
+
+                if ( transfert -> budgetary_number == tmp_budget_number
+                 &&
+                    transfert -> sub_budgetary_number == tmp_sub_budget_number )
+                {
+                    if ( g_date_compare ( date, transfert -> date ) == 0 )
+                    {
+                        gtk_tree_store_remove ( GTK_TREE_STORE ( tab_model ), &iter );
+                        break;
+                    }
+                    tmp_iter = gtk_tree_iter_copy ( &iter );
+                }
+            }
+        }
+        while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( tab_model ), &iter ) );
+    }
+
+    return FALSE;
+}
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */

Index: balance_estimate_future.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_future.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- balance_estimate_future.c	4 May 2010 12:27:52 -0000	1.10
+++ balance_estimate_future.c	4 May 2010 20:38:18 -0000	1.11
@@ -135,6 +135,28 @@
  *
  *
  * */
+void bet_future_initialise_dialog ( void )
+ {
+    if ( bet_futur_dialog != NULL )
+    {
+        gtk_widget_destroy ( bet_futur_dialog );
+        bet_futur_dialog = NULL;
+    }
+
+    if ( bet_transfert_dialog != NULL )
+    {
+        gtk_widget_destroy ( bet_transfert_dialog );
+        bet_transfert_dialog = NULL;
+    }
+ }
+
+ 
+/**
+ *
+ *
+ *
+ *
+ * */
 gboolean bet_future_new_line_dialog ( GtkTreeModel *tab_model,
                         gchar *str_date )
 {
@@ -2249,7 +2271,10 @@
     gint replace_currency;
 
     currency = gsb_data_account_get_currency ( transfert -> account_number );
-    replace_currency = gsb_data_partial_balance_get_currency ( transfert -> replace_account );
+    if ( transfert -> type == 0 )
+        replace_currency = gsb_data_account_get_currency ( transfert -> replace_account );
+    else
+        replace_currency = gsb_data_partial_balance_get_currency ( transfert -> replace_account );
 
     if ( currency == replace_currency || amount.mantissa == 0 )
         string = gsb_real_get_string_with_currency ( amount, currency, TRUE );



More information about the cvs mailing list