[grisbi-cvs] grisbi/src gsb_assistant_archive.c, 1.34, 1.35 gsb_data_archive_store.c, 1.15, 1.16 gsb_transactions_list_sort.c, 1.14, 1.15 transaction_list.c, 1.47, 1.48

Pierre Biava pbiava at users.sourceforge.net
Sat Aug 22 17:34:54 CEST 2009


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

Modified Files:
	gsb_assistant_archive.c gsb_data_archive_store.c 
	gsb_transactions_list_sort.c transaction_list.c 
Log Message:
Fixes various bugs in the handling of archives

Index: gsb_assistant_archive.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_assistant_archive.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- gsb_assistant_archive.c	13 Aug 2009 19:24:49 -0000	1.34
+++ gsb_assistant_archive.c	22 Aug 2009 15:34:51 -0000	1.35
@@ -691,7 +691,7 @@
 {
     /* if we come here, we are sure that :
      * there is a own name to the archive
-     * there is some transasctions to be archived
+     * there is some transactions to be archived
      * all the necessary stuff is filled */
     GSList *tmp_list;
     gint archive_number;
@@ -754,14 +754,14 @@
     tmp_list = list_transaction_to_archive;
     while (tmp_list)
     {
-    gint transaction_number;
+        gint transaction_number;
 
-    transaction_number = gsb_data_transaction_get_transaction_number (tmp_list -> data);
-    gsb_data_transaction_set_archive_number ( transaction_number, archive_number );
-    /* On supprime l'opération dans le tree_view */
-    if ( gsb_data_transaction_get_mother_transaction_number ( transaction_number ) == 0 )
-        gsb_transactions_list_delete_transaction_from_tree_view ( transaction_number );
-    tmp_list = tmp_list -> next;
+        transaction_number = gsb_data_transaction_get_transaction_number (tmp_list -> data);
+        gsb_data_transaction_set_archive_number ( transaction_number, archive_number );
+        /* On supprime l'opération dans le tree_view */
+        if ( gsb_data_transaction_get_mother_transaction_number ( transaction_number ) == 0 )
+            gsb_transactions_list_delete_transaction_from_tree_view ( transaction_number );
+        tmp_list = tmp_list -> next;
     }
 
     /* on recrée la liste des archives par compte */
@@ -805,7 +805,7 @@
 
     /* On met à jour l'affichage de la liste si nécessaire */
     if ( ( account_nb = gsb_gui_navigation_get_current_account ( ) ) != -1 )
-        gsb_transactions_list_update_tree_view ( account_nb, FALSE );
+        gsb_transactions_list_update_tree_view ( account_nb, TRUE );
 
         
     return FALSE;

Index: gsb_transactions_list_sort.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_transactions_list_sort.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- gsb_transactions_list_sort.c	10 May 2009 13:06:56 -0000	1.14
+++ gsb_transactions_list_sort.c	22 Aug 2009 15:34:51 -0000	1.15
@@ -32,7 +32,7 @@
 /*START_INCLUDE*/
 #include "gsb_transactions_list_sort.h"
 #include "./gsb_data_account.h"
-#include "./gsb_data_archive.h"
+#include "./gsb_data_archive_store.h"
 #include "./gsb_data_budget.h"
 #include "./gsb_data_fyear.h"
 #include "./gsb_data_payee.h"
@@ -186,32 +186,34 @@
     if (record_1 -> what_is_line != IS_ARCHIVE
 	&&
 	record_2 -> what_is_line != IS_ARCHIVE)
-	return 0;
+        return 0;
 
     /* ok, there is at least 1 archive */
     if (record_1 -> what_is_line == IS_ARCHIVE)
     {
-	if (record_2 -> what_is_line == IS_ARCHIVE)
+        if (record_2 -> what_is_line == IS_ARCHIVE)
 	    /* the first and second line are archives, we return a comparison by number of archive
 	     * we can do better, by date or by financial year, but more complex because no check for now
 	     * that the date must be different, and problem when created by report
 	     * so we assume the user created the archive in the good order, if some complains about that
 	     * can change here later */
-	    return_value = gsb_data_archive_get_no_archive (record_1->transaction_pointer) -
-		gsb_data_archive_get_no_archive (record_2->transaction_pointer);
-	else
-	    /* the first line is an archive and not the second, so first line before */
-	    return_value = -1;
+            return_value = gsb_data_archive_store_get_archive_number (
+                        gsb_data_archive_store_get_number ( record_1->transaction_pointer ) )-
+            gsb_data_archive_store_get_archive_number (
+                        gsb_data_archive_store_get_number ( record_2->transaction_pointer ) );
+        else
+            /* the first line is an archive and not the second, so first line before */
+            return_value = -1;
     }
     else
     {
-	if (record_2 -> what_is_line == IS_ARCHIVE)
-	    /* the first line is not an archive but the second one is, so second line before */
-	    return_value = 1;
-	else
-	    /* we have 2 transactions, just return 0 here to make tests later
-	     * shouldn't come here */
-	    return 0;
+        if (record_2 -> what_is_line == IS_ARCHIVE)
+            /* the first line is not an archive but the second one is, so second line before */
+            return_value = 1;
+        else
+            /* we have 2 transactions, just return 0 here to make tests later
+             * shouldn't come here */
+            return 0;
     }
     return return_value;
 }

Index: transaction_list.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/transaction_list.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- transaction_list.c	13 Aug 2009 19:24:49 -0000	1.47
+++ transaction_list.c	22 Aug 2009 15:34:51 -0000	1.48
@@ -300,7 +300,6 @@
 
     /* get the new number of the first row in the complete list of row */
     pos = custom_list->num_rows;
-
     /* increase the table of pointer of struct CustomRecord,
      * 1 for the archive */
     custom_list->num_rows = custom_list -> num_rows + 1;
@@ -317,23 +316,24 @@
     archive_number = gsb_data_archive_store_get_archive_number (archive_store_number);
 
     newrecord -> visible_col[find_element_col (ELEMENT_DATE)] = gsb_format_gdate (
-										  gsb_data_archive_get_beginning_date (archive_number) );
+                        gsb_data_archive_get_beginning_date ( archive_number ) );
     newrecord -> visible_col[find_element_col (ELEMENT_PARTY)] = g_strdup_printf ( 
-										  _("archive %s (%d transactions)"),
-										  gsb_data_archive_get_name (archive_number),
-										  gsb_data_archive_store_get_transactions_number (archive_store_number) );
+                        _("archive %s (%d transactions)"),
+                        gsb_data_archive_get_name (archive_number),
+                        gsb_data_archive_store_get_transactions_number (
+                        archive_store_number ) );
     if ((gsb_data_archive_store_get_balance (archive_store_number)).mantissa < 0)
 	amount_col = find_element_col (ELEMENT_DEBIT);
     else
 	amount_col = find_element_col (ELEMENT_CREDIT);
 
     newrecord -> visible_col[amount_col] = gsb_real_get_string_with_currency (
-									      gsb_data_archive_store_get_balance (archive_store_number),
-									      gsb_data_account_get_currency (
-													     gsb_data_archive_store_get_account_number (archive_store_number)),
-									      TRUE);
+                        gsb_data_archive_store_get_balance (archive_store_number),
+                        gsb_data_account_get_currency (
+                        gsb_data_archive_store_get_account_number ( archive_store_number ) ),
+                        TRUE);
     newrecord -> transaction_pointer = gsb_data_archive_store_get_structure (
-									     archive_store_number);
+                        archive_store_number);
     newrecord -> what_is_line = IS_ARCHIVE;
     newrecord -> row_bg = &archive_background_color;
 
@@ -341,7 +341,6 @@
     custom_list->rows[pos] = newrecord;
     /* and the pos (number) of the row */
     newrecord->pos = pos;
-    pos++;
 }
 
 
@@ -530,12 +529,14 @@
         /* we are on a good archive store, delete it */
 
         /* delete the rows */
-        for (j=0 ; j<CUSTOM_MODEL_N_VISIBLES_COLUMN ; j++)
+        for ( j=0 ; j<CUSTOM_MODEL_N_VISIBLES_COLUMN ; j++ )
             if (record -> visible_col[j])
-            g_free (record -> visible_col[j]);
-
-        /* remove the row */
+                g_free (record -> visible_col[j]);
+        
+        /* remove the row. I decrement "i" because the next line of model is shifted
+         * and has  "i" for index. Otherwise we do not test. */
         custom_list -> num_rows--;
+        i--;
 
         for (j=record -> pos ; j < custom_list -> num_rows ; j++)
         {
@@ -850,11 +851,11 @@
     /* begin to fill the iter for later */
     iter.stamp = custom_list->stamp;
 
-    floating_point = gsb_data_currency_get_floating_point (gsb_data_account_get_currency (account_number));
+    floating_point = gsb_data_currency_get_floating_point (
+                        gsb_data_account_get_currency ( account_number ) );
 
     /* get the beginning balance */
-    current_total = solde_debut_affichage ( account_number,
-					    floating_point);
+    current_total = solde_debut_affichage ( account_number, floating_point);
 
     for (i=0 ; i < custom_list -> num_visibles_rows ; i++)
     {
@@ -874,12 +875,15 @@
 	switch (record -> what_is_line)
 	{
 	    case IS_ARCHIVE:
-		amount = gsb_data_archive_store_get_balance (gsb_data_archive_store_get_number (record -> transaction_pointer));
+		amount = gsb_data_archive_store_get_balance (
+                        gsb_data_archive_store_get_number (record -> transaction_pointer));
 		break;
 
 	    case IS_TRANSACTION:
-		amount = gsb_data_transaction_get_adjusted_amount (gsb_data_transaction_get_transaction_number (record -> transaction_pointer),
-								   floating_point);
+		amount = gsb_data_transaction_get_adjusted_amount (
+                        gsb_data_transaction_get_transaction_number (
+                        record -> transaction_pointer),
+                        floating_point);
 		/* go on the good row to set the amount */
 		record = record -> transaction_records[line_balance];
 		break;

Index: gsb_data_archive_store.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_archive_store.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- gsb_data_archive_store.c	21 May 2009 21:58:55 -0000	1.15
+++ gsb_data_archive_store.c	22 Aug 2009 15:34:51 -0000	1.16
@@ -41,6 +41,7 @@
 #include "./gsb_data_currency.h"
 #include "./gsb_data_transaction.h"
 #include "./gsb_real.h"
+#include "./transaction_list.h"
 #include "./gsb_real.h"
 /*END_INCLUDE*/
 
@@ -101,10 +102,15 @@
         GSList* tmp_list = archive_store_list;
         while ( tmp_list )
         {
-        struct_store_archive *archive;
-        archive = tmp_list -> data;
-        tmp_list = tmp_list -> next;
-        _gsb_data_archive_store_free ( archive );
+            struct_store_archive *archive;
+            gint archive_number;
+
+            archive = tmp_list -> data;
+            archive_number = gsb_data_archive_store_get_archive_number (
+                        archive -> archive_store_number );
+            transaction_list_remove_archive ( archive_number );
+            tmp_list = tmp_list -> next;
+            _gsb_data_archive_store_free ( archive );
         }
         g_slist_free ( archive_store_list );
     }
@@ -184,33 +190,34 @@
         struct_store_archive *archive;
         gint floating_point;
         gint account_number;
+
         account_number = gsb_data_transaction_get_account_number (transaction_number);
         floating_point = gsb_data_currency_get_floating_point (
                             gsb_data_account_get_currency (account_number) );
         archive = gsb_data_archive_store_find_struct ( archive_number, account_number);
         if (archive)
         {
-        /* there is already a struct_store_archive for the same archive and the same account,
-         * we increase the balance */
-        archive -> balance = gsb_real_add ( archive -> balance,
-                                gsb_data_transaction_get_adjusted_amount (transaction_number,
-                                floating_point));
-        archive -> nb_transactions++;
+            /* there is already a struct_store_archive for the same archive and the same account,
+             * we increase the balance */
+            archive -> balance = gsb_real_add ( archive -> balance,
+                                    gsb_data_transaction_get_adjusted_amount (transaction_number,
+                                    floating_point));
+            archive -> nb_transactions++;
         }
         else
         {
-        /* there is no struct_store_archive for that transaction, we make a new one 
-         * with the balance of the transaction as balance */
-        gint archive_store_number;
+            /* there is no struct_store_archive for that transaction, we make a new one 
+             * with the balance of the transaction as balance */
+            gint archive_store_number;
 
-        archive_store_number = gsb_data_archive_store_new ();
-        archive = gsb_data_archive_store_get_structure (archive_store_number);
+            archive_store_number = gsb_data_archive_store_new ();
+            archive = gsb_data_archive_store_get_structure (archive_store_number);
 
-        archive -> archive_number = archive_number;
-        archive -> account_number = account_number;
-        archive -> balance = gsb_data_transaction_get_adjusted_amount (
-                        transaction_number, floating_point);
-        archive -> nb_transactions = 1;
+            archive -> archive_number = archive_number;
+            archive -> account_number = account_number;
+            archive -> balance = gsb_data_transaction_get_adjusted_amount (
+                            transaction_number, floating_point);
+            archive -> nb_transactions = 1;
         }
     }
     tmp_list = tmp_list -> next;



More information about the cvs mailing list