[grisbi-cvs] grisbi/src gsb_data_payee.c, 1.39, 1.40 gsb_file_config.c, 1.69, 1.70 metatree.c, 1.126, 1.127 tiers_onglet.c, 1.144, 1.145 utils_str.c, 1.61, 1.62 utils_str.h, 1.39, 1.40

Pierre Biava pbiava at users.sourceforge.net
Sun Feb 1 22:39:03 CET 2009


Update of /cvsroot/grisbi/grisbi/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10953/src

Modified Files:
	gsb_data_payee.c gsb_file_config.c metatree.c tiers_onglet.c 
	utils_str.c utils_str.h 
Log Message:
Fixed bug 463 and resumption of calculating the amount of the splitted transactions that were counted twice

Index: gsb_data_payee.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_payee.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- gsb_data_payee.c	28 Oct 2008 00:30:05 -0000	1.39
+++ gsb_data_payee.c	1 Feb 2009 21:39:00 -0000	1.40
@@ -710,9 +710,10 @@
     }
 
     payee -> payee_nb_transactions ++;
-    payee -> payee_balance = gsb_real_add ( payee -> payee_balance,
-					    gsb_data_transaction_get_adjusted_amount_for_currency ( transaction_number,
-												    payee_tree_currency (), -1));
+    if ( ! gsb_data_transaction_get_split_of_transaction ( transaction_number ) )
+        payee -> payee_balance = gsb_real_add ( payee -> payee_balance,
+					    gsb_data_transaction_get_adjusted_amount_for_currency 
+                        ( transaction_number, payee_tree_currency (), -1));
 }
 
 

Index: metatree.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/metatree.c,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -d -r1.126 -r1.127
--- metatree.c	31 Jan 2009 19:27:05 -0000	1.126
+++ metatree.c	1 Feb 2009 21:39:00 -0000	1.127
@@ -262,8 +262,6 @@
     if ( type != META_TREE_DIV && type != META_TREE_INVALID )
 	return;
 
-    devel_debug_int (division);
-
     string_tmp = iface -> div_name (division);
     number_transactions = iface -> div_nb_transactions (division);
 
@@ -400,8 +398,6 @@
     if ( ! metatree_model_is_displayed ( model ) )
 	return;
 
-    devel_debug_int (transaction_number);
-
     path = gtk_tree_model_get_path ( model, iter );
     type = metatree_get_row_type ( model, path );
     gtk_tree_path_free (path);

Index: utils_str.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/utils_str.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- utils_str.h	31 Jan 2009 20:11:04 -0000	1.39
+++ utils_str.h	1 Feb 2009 21:39:01 -0000	1.40
@@ -12,6 +12,7 @@
 					      gchar *delimiter );
 GSList *gsb_string_get_string_list_from_string ( const gchar *string,
 						 gchar *delimiter );
+gchar * gsb_string_remplace_string ( gchar * str, gchar *old_str, gchar *new_str );
 gchar * gsb_string_truncate ( gchar * string );
 gchar * latin2utf8 ( const gchar * inchar);
 gchar *limit_string ( gchar *string,

Index: tiers_onglet.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/tiers_onglet.c,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -d -r1.144 -r1.145
--- tiers_onglet.c	31 Jan 2009 20:11:04 -0000	1.144
+++ tiers_onglet.c	1 Feb 2009 21:39:00 -0000	1.145
@@ -43,6 +43,7 @@
 #include "./utils_editables.h"
 #include "./gsb_form_widget.h"
 #include "./gsb_status.h"
+#include "./utils_str.h"
 #include "./gtk_combofix.h"
 #include "./traitement_variables.h"
 #include "./utils.h"
@@ -64,6 +65,9 @@
 			       GtkSelectionData * selection_data );
 static gboolean payee_remove_unused ( GtkWidget *button,
 			       gpointer null );
+static void payee_tree_update_transactions ( GtkTreeModel * model, 
+                        MetatreeInterface * iface, GtkTreeIter * iter,
+                        gint division, gchar * old_payee );
 static gboolean popup_payee_view_mode_menu ( GtkWidget * button );
 /*END_STATIC*/
 
@@ -480,6 +484,7 @@
     gint no_division = -1;
     gint payee_number = 0;
     gchar * title;
+    gchar * old_payee;
     GtkTreeIter *div_iter;
 
     devel_debug (NULL);
@@ -488,23 +493,23 @@
     if ( selection && gtk_tree_selection_get_selected(selection, &model, &iter))
     {
 	gtk_tree_model_get ( model, &iter,
-			     META_TREE_POINTER_COLUMN, &payee_number,
-			     META_TREE_NO_DIV_COLUMN, &no_division,
-			     -1 );
+                        META_TREE_POINTER_COLUMN, &payee_number,
+                        META_TREE_NO_DIV_COLUMN, &no_division,
+                        -1 );
     }
 
     if ( !selection || no_division <= 0 )
-	return FALSE;
+        return FALSE;
 
-    title = g_strdup_printf ( _("Properties for %s"), gsb_data_payee_get_name(payee_number,
-									      TRUE));
+    old_payee = g_strdup ( gsb_data_payee_get_name ( payee_number, TRUE ) );
+    title = g_strdup_printf ( _("Properties for %s"), old_payee );
 
     dialog = gtk_dialog_new_with_buttons ( title,
-					   GTK_WINDOW ( window ),
-					   GTK_DIALOG_MODAL,
-					   GTK_STOCK_CANCEL, GTK_RESPONSE_NO,
-					   GTK_STOCK_APPLY, GTK_RESPONSE_OK,
-					   NULL );
+                        GTK_WINDOW ( window ),
+                        GTK_DIALOG_MODAL,
+                        GTK_STOCK_CANCEL, GTK_RESPONSE_NO,
+                        GTK_STOCK_APPLY, GTK_RESPONSE_OK,
+                        NULL );
 
     gtk_window_set_position ( GTK_WINDOW ( dialog ), GTK_WIN_POS_CENTER_ON_PARENT );
     gtk_window_set_resizable ( GTK_WINDOW ( dialog ), FALSE );
@@ -525,12 +530,12 @@
     label = gtk_label_new ( _("Name"));
     gtk_misc_set_alignment ( GTK_MISC ( label ), 0.0, 0.5 );
     gtk_table_attach ( GTK_TABLE(table), label, 0, 1, 0, 1,
-		       GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0 );
+                        GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0 );
 
     entry_name = gtk_entry_new ();
     gtk_entry_set_text ( GTK_ENTRY ( entry_name ),
 			 gsb_data_payee_get_name(payee_number,
-						 TRUE));
+                        TRUE));
     gtk_widget_set_size_request ( entry_name, 400, -1 );
     gtk_table_attach ( GTK_TABLE(table), entry_name, 1, 2, 0, 1, GTK_EXPAND|GTK_FILL, 0, 0, 0 );
 
@@ -538,36 +543,37 @@
     label = gtk_label_new ( _("Description"));
     gtk_misc_set_alignment ( GTK_MISC ( label ), 0.0, 0.5 );
     gtk_table_attach ( GTK_TABLE(table), label, 0, 1, 1, 2,
-		       GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0 );
+                        GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0 );
 
     entry_description = gsb_editable_text_view_new (gsb_data_payee_get_description (payee_number));
     scrolled_window = gtk_scrolled_window_new ( NULL, NULL );
     gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW ( scrolled_window ),
-				     GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
+                        GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
     gtk_scrolled_window_set_shadow_type ( GTK_SCROLLED_WINDOW(scrolled_window),
-					  GTK_SHADOW_IN );
+                        GTK_SHADOW_IN );
     gtk_container_add ( GTK_CONTAINER ( scrolled_window ), entry_description );
     gtk_table_attach ( GTK_TABLE(table), scrolled_window,
-		       1, 2, 1, 2, GTK_EXPAND|GTK_FILL, 0, 0, 0 );
+                        1, 2, 1, 2, GTK_EXPAND|GTK_FILL, 0, 0, 0 );
 
     gtk_widget_show_all ( dialog );
-    g_free ( title );
 
     while ( 1 )
     {
 	if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) != GTK_RESPONSE_OK )
 	{
 	    gtk_widget_destroy ( GTK_WIDGET ( dialog ) );
+        g_free ( title );
+
 	    return FALSE;
 	}
 
 	if ( ! gsb_data_payee_get_number_by_name ( gtk_entry_get_text ( GTK_ENTRY ( entry_name ) ),
-						   FALSE ) ||
+                        FALSE ) ||
 	     gsb_data_payee_get_number_by_name ( gtk_entry_get_text ( GTK_ENTRY ( entry_name ) ),
-						 FALSE ) == payee_number )
+                        FALSE ) == payee_number )
 	{
 	    gsb_data_payee_set_name ( payee_number,
-				      gtk_entry_get_text ( GTK_ENTRY (entry_name)));
+                        gtk_entry_get_text ( GTK_ENTRY (entry_name)));
 	    break;
 	}
 	else
@@ -575,9 +581,9 @@
 	    gchar * message;
 
 	    message = g_strdup_printf ( _("You tried to rename current payee to '%s' "
-					  "but this payee already exists.  Please "
-					  "choose another name."),
-					gtk_entry_get_text ( GTK_ENTRY ( entry_name ) ) );
+                        "but this payee already exists.  Please "
+                        "choose another name."),
+                        gtk_entry_get_text ( GTK_ENTRY ( entry_name ) ) );
 	    dialogue_warning_hint ( message, _("Payee already exists") );
 	    g_free ( message );
 	}
@@ -591,18 +597,45 @@
 
     div_iter = get_iter_from_div ( model, payee_number, 0 );
     fill_division_row ( model, payee_interface,
-			div_iter, payee_number );
+                        div_iter, payee_number );
+    payee_tree_update_transactions ( model, payee_interface,
+                        div_iter, payee_number, old_payee );
     gtk_tree_iter_free (div_iter);
+    g_free ( title );
 
     /* update the transactions list */
     transaction_list_update_element (ELEMENT_PARTY);
-
     modification_fichier (TRUE);
     return FALSE;
 }
 
 
+void payee_tree_update_transactions ( GtkTreeModel * model, 
+                        MetatreeInterface * iface, GtkTreeIter * iter,
+                        gint division, gchar * old_payee )
+{
+    GtkTreeIter child_iter;
+    gchar *name;
+    gint number_transactions;
+    gint transaction_number;
+    gint i = 0;
+
+    number_transactions = iface -> div_nb_transactions (division);
 
+    for ( i = 0; i < number_transactions; i++ )
+    {
+        gtk_tree_model_iter_nth_child ( model, &child_iter, iter, i );
+        gtk_tree_model_get ( model, &child_iter, META_TREE_TEXT_COLUMN, &name, -1 );
+        if ( !name )
+            return;
+        gtk_tree_model_get ( model, &child_iter, META_TREE_NO_TRANSACTION_COLUMN, 
+                        &transaction_number, -1 );
+        name = gsb_string_remplace_string ( name, old_payee, (gchar *) 
+                        gsb_data_payee_get_name ( division, FALSE ) );
+        gtk_tree_store_set ( GTK_TREE_STORE(model), &child_iter, 
+                        META_TREE_TEXT_COLUMN, name, -1 );
+    }
+}
 
 /* Local Variables: */
 /* c-basic-offset: 4 */

Index: utils_str.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/utils_str.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- utils_str.c	10 Jan 2009 18:56:11 -0000	1.61
+++ utils_str.c	1 Feb 2009 21:39:01 -0000	1.62
@@ -28,6 +28,7 @@
 /*START_INCLUDE*/
 #include "utils_str.h"
 #include "./include.h"
+#include "./erreur.h"
 #include "./gsb_data_report.h"
 /*END_INCLUDE*/
 
@@ -167,7 +168,7 @@
 /* Fonction my_strtod (string to decimal)                                    */
 /* Convertie une chaine de caractères en un nombre                            */
 /* Paramètres d'entrée :                                                      */
-/*   - nptr : pointeur sur la chaine de caractÚres à convertir                */
+/*   - nptr : pointeur sur la chaine de caractères à convertir                */
 /*   - endptr : n'est pas utilisé, alors à quoi peut-il bien servir ?         */
 /* Valeur de retour :                                                         */
 /*   - resultat : le résultat de la conversion                                */
@@ -732,6 +733,20 @@
     }
 }
 
+gchar * gsb_string_remplace_string ( gchar * str, gchar *old_str, gchar *new_str )
+{
+    gchar *ptr_debut;
+    gint long_old;
+    gchar *chaine;
+
+    ptr_debut = g_strstr_len ( str, -1, old_str);
+    long_old = g_utf8_strlen ( old_str, -1 );
+    chaine = g_strndup ( str, (ptr_debut - str) );
+    chaine = g_strconcat ( chaine, new_str, ( ptr_debut + long_old ), NULL );
+    devel_debug ( chaine );
+    return g_strdup ( chaine );
+}
+
 /**
  * all the gtk_entry_set_text in grisbi should be my_gtk_entry_set_text which just
  * check if the text is not NULL, and if NULL, erase the entry

Index: gsb_file_config.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_file_config.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- gsb_file_config.c	31 Jan 2009 20:11:04 -0000	1.69
+++ gsb_file_config.c	1 Feb 2009 21:39:00 -0000	1.70
@@ -39,6 +39,7 @@
 #include "./utils_files.h"
 #include "./print_config.h"
 #include "./structures.h"
+#include "./utils_str.h"
 #include "./utils_buttons.h"
 #include "./print_config.h"
 #include "./include.h"



More information about the cvs mailing list