[grisbi-cvs] [SCM] grisbi branch, master, updated. 96beb52e67166ee37b205ebec29acb377662c048

Pierre Biava nobody at users.sourceforge.net
Sat Jul 31 23:52:59 CEST 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grisbi".

The branch, master has been updated
       via  96beb52e67166ee37b205ebec29acb377662c048 (commit)
      from  ca8e28314c44880c1998ec14ec77397cbf46478e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 96beb52e67166ee37b205ebec29acb377662c048
Author: pbiava <pierre.biava at nerim.net>
Date:   Sat Jul 31 23:52:34 2010 +0200

    Fixed a bug in excess of historical data in the table estimates

-----------------------------------------------------------------------

Changes:
diff --git a/src/bet_data.c b/src/bet_data.c
index 5c690da..5e747aa 100644
--- a/src/bet_data.c
+++ b/src/bet_data.c
@@ -51,7 +51,7 @@
 
 /*START_STATIC*/
 static GDate *bet_data_futur_get_next_date ( struct_futur_data *scheduled,
-				        const GDate *date,
+                        const GDate *date,
                         const GDate *date_max );
 static struct_futur_data *bet_data_future_copy_struct ( struct_futur_data *scheduled );
 static void bet_data_future_set_max_number ( gint number );
@@ -74,6 +74,7 @@ extern gsb_real null_real;
 /* pointeurs définis en fonction du type de données catégories ou IB */
 gint (*ptr_div) ( gint transaction_num, gboolean is_transaction );
 gint (*ptr_sub_div) ( gint transaction_num, gboolean is_transaction );
+gint (*ptr_type) ( gint no_div );
 gchar* (*ptr_div_name) ( gint div_num, gint sub_div, const gchar *return_value_error );
 
 
@@ -447,12 +448,14 @@ gboolean bet_data_set_div_ptr ( gint type_div )
     {
         ptr_div = &gsb_data_mix_get_category_number;
         ptr_sub_div = &gsb_data_mix_get_sub_category_number;
+        ptr_type = &gsb_data_category_get_type;
         ptr_div_name = &gsb_data_category_get_name;
     }
     else
     {
         ptr_div = &gsb_data_mix_get_budgetary_number;
         ptr_sub_div = &gsb_data_mix_get_sub_budgetary_number;
+        ptr_type = &gsb_data_budget_get_type;
         ptr_div_name = &gsb_data_budget_get_name;
     }
 
@@ -488,6 +491,18 @@ gint bet_data_get_sub_div_nb ( gint transaction_number, gboolean is_transaction
  *
  *
  * */
+gint bet_data_get_div_type ( gint div_number )
+{
+    return ptr_type ( div_number );
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
 gchar *bet_data_get_div_name ( gint div_num,
                         gint sub_div,
                         const gchar *return_value_error )
@@ -1226,7 +1241,7 @@ GHashTable *bet_data_future_get_list ( void )
  * \return a newly allocated date, the next date or NULL if over the limit
  * */
 GDate *bet_data_futur_get_next_date ( struct_futur_data *scheduled,
-				        const GDate *date,
+                        const GDate *date,
                         const GDate *date_max )
 {
     GDate *return_date;
diff --git a/src/bet_data.h b/src/bet_data.h
index 60c84f9..1c34987 100644
--- a/src/bet_data.h
+++ b/src/bet_data.h
@@ -101,6 +101,7 @@ gchar *bet_data_get_div_name ( gint div_num,
                         gint sub_div,
                         const gchar *return_value_error );
 gint bet_data_get_div_number ( gint transaction_number, gboolean is_transaction );
+gint bet_data_get_div_type ( gint div_number );
 gint bet_data_get_selected_currency ( void );
 GPtrArray *bet_data_get_strings_to_save ( void );
 gint bet_data_get_sub_div_nb ( gint transaction_number, gboolean is_transaction );
diff --git a/src/bet_tab.c b/src/bet_tab.c
index 38dcc94..0a25bc5 100644
--- a/src/bet_tab.c
+++ b/src/bet_tab.c
@@ -579,13 +579,13 @@ GtkWidget *bet_array_create_tree_view ( void )
                     G_TYPE_INT,         /* SPP_ESTIMATE_TREE_ORIGIN_DATA */
                     G_TYPE_INT,         /* SPP_ESTIMATE_TREE_DIVISION_COLUMN */
                     G_TYPE_INT,         /* SPP_ESTIMATE_TREE_SUB_DIV_COLUMN */
-				    G_TYPE_STRING,      /* SPP_ESTIMATE_TREE_DATE_COLUMN */
-				    G_TYPE_STRING,      /* SPP_ESTIMATE_TREE_DESC_COLUMN */
-				    G_TYPE_STRING,      /* SPP_ESTIMATE_TREE_DEBIT_COLUMN */
-				    G_TYPE_STRING,      /* SPP_ESTIMATE_TREE_CREDIT_COLUMN */
-				    G_TYPE_STRING,      /* SPP_ESTIMATE_TREE_BALANCE_COLUMN */
-				    G_TYPE_DATE,        /* SPP_ESTIMATE_TREE_SORT_DATE_COLUMN */
-				    G_TYPE_STRING,      /* SPP_ESTIMATE_TREE_AMOUNT_COLUMN */
+                    G_TYPE_STRING,      /* SPP_ESTIMATE_TREE_DATE_COLUMN */
+                    G_TYPE_STRING,      /* SPP_ESTIMATE_TREE_DESC_COLUMN */
+                    G_TYPE_STRING,      /* SPP_ESTIMATE_TREE_DEBIT_COLUMN */
+                    G_TYPE_STRING,      /* SPP_ESTIMATE_TREE_CREDIT_COLUMN */
+                    G_TYPE_STRING,      /* SPP_ESTIMATE_TREE_BALANCE_COLUMN */
+                    G_TYPE_DATE,        /* SPP_ESTIMATE_TREE_SORT_DATE_COLUMN */
+                    G_TYPE_STRING,      /* SPP_ESTIMATE_TREE_AMOUNT_COLUMN */
                     G_TYPE_STRING,      /* SPP_ESTIMATE_TREE_BALANCE_COLOR */
                     GDK_TYPE_COLOR );   /* SPP_ESTIMATE_TREE_BACKGROUND_COLOR */
 
@@ -595,31 +595,32 @@ GtkWidget *bet_array_create_tree_view ( void )
     /* sort by date */
     sortable = gtk_tree_model_sort_new_with_model ( GTK_TREE_MODEL ( tree_model ) );
     gtk_tree_sortable_set_sort_func ( GTK_TREE_SORTABLE ( tree_model ),
-				      SPP_ESTIMATE_TREE_SORT_DATE_COLUMN,
-				      (GtkTreeIterCompareFunc) bet_array_date_sort_function,
-				      NULL, NULL );
+                        SPP_ESTIMATE_TREE_SORT_DATE_COLUMN,
+                        (GtkTreeIterCompareFunc) bet_array_date_sort_function,
+                        NULL,
+                        NULL );
     gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(tree_model),
-					 SPP_ESTIMATE_TREE_SORT_DATE_COLUMN, GTK_SORT_DESCENDING);
+                        SPP_ESTIMATE_TREE_SORT_DATE_COLUMN, GTK_SORT_DESCENDING);
 
     scrolled_window = gtk_scrolled_window_new ( NULL, NULL );
     gtk_widget_show ( scrolled_window );
     gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW ( scrolled_window ),
-				        GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC );
+                        GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC );
     gtk_container_add ( GTK_CONTAINER ( scrolled_window ), tree_view );
     gtk_widget_show ( scrolled_window );
 
     /* Date column */
     cell = gtk_cell_renderer_text_new ();
     column = gtk_tree_view_column_new_with_attributes (
-					    _("Date"), cell,
-					    "text", SPP_ESTIMATE_TREE_DATE_COLUMN,
+                        _("Date"), cell,
+                        "text", SPP_ESTIMATE_TREE_DATE_COLUMN,
                         "cell-background-gdk", SPP_ESTIMATE_TREE_BACKGROUND_COLOR,
                         NULL);
     g_object_set (cell, "xalign", 0.5, NULL);
 
     gtk_tree_view_column_set_alignment ( column, 0.5 );
     gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view),
-				GTK_TREE_VIEW_COLUMN(column));
+                        GTK_TREE_VIEW_COLUMN(column));
     gtk_tree_view_column_set_resizable ( column, TRUE );
 
     /* Description column */
@@ -1710,76 +1711,75 @@ void bet_array_adjust_hist_amount ( gint div_number,
             if ( tmp_sub_div_nb == 0 || tmp_sub_div_nb == sub_div_nb )
             {
                 div_name = bet_data_get_div_name ( tmp_div_number, tmp_sub_div_nb, FALSE );
-				//~ printf ("div_number = %d, sub_div_number = %d div_name = %s str_desc = %s\n",
-                         //~ tmp_div_number, tmp_sub_div_nb, div_name, str_desc );
+
                 date = gsb_parse_date_string ( str_date );
                 date_today = gdate_today ( );
                 if ( g_date_get_month ( date ) - g_date_get_month ( date_today ) == 0 )
                 {
                     number = gsb_real_import_from_string ( str_amount );
-                    if ( number .mantissa < 0 )
-                        sign = -1;
-                    number = gsb_real_sub ( number, amount );
-                    if ( number.mantissa == 0 )
-                        gtk_tree_store_remove ( GTK_TREE_STORE ( model ), &iter );
-                    else
+                    if ( number.mantissa != 0 )
                     {
+                        sign = bet_data_get_div_type ( div_number );
+                        number = gsb_real_sub ( number, amount );
+
                         if ( str_amount )
                             g_free ( str_amount );
                         if ( str_desc )
                             g_free ( str_desc );
-
-                        str_amount = gsb_real_save_real_to_string ( number, 2 );
-                        if ( number.mantissa < 0 && sign < 0 )
+                        if ( sign == 1 )
                         {
-                            str_debit = gsb_real_get_string_with_currency (
-                                        gsb_real_abs ( number ),
-                                        bet_data_get_selected_currency ( ),
-                                        TRUE );
-                            str_desc = g_strconcat ( div_name, _(" (still available)"), NULL);
-                        }
-                        else if ( number.mantissa > 0 && sign > 0 )
-                        {
-                            str_credit = gsb_real_get_string_with_currency (
-                                        gsb_real_abs ( number ),
-                                        bet_data_get_selected_currency ( ),
-                                        TRUE );
-                            str_desc = g_strconcat ( div_name, _(" (yet to receive)"), NULL);
-                        }
-                        else if ( sign == -1 )
-                        {
-                            str_debit = gsb_real_get_string_with_currency (
-                                        null_real,
-                                        bet_data_get_selected_currency ( ),
-                                        TRUE );
-                            if ( str_amount )
-                                g_free ( str_amount );
-                            str_amount = g_strdup ( "0.00" );
-                            str_desc = g_strconcat ( div_name, _(" (budget exceeded)"), NULL);
+                            if ( number.mantissa < 0 )
+                            {
+                                str_amount = gsb_real_save_real_to_string ( number, 2 );
+                                str_debit = gsb_real_get_string_with_currency (
+                                            gsb_real_abs ( number ),
+                                            bet_data_get_selected_currency ( ),
+                                            TRUE );
+                                str_desc = g_strconcat ( div_name, _(" (still available)"), NULL);
+                            }
+                            else
+                            {
+                                str_debit = gsb_real_get_string_with_currency (
+                                            null_real,
+                                            bet_data_get_selected_currency ( ),
+                                            TRUE );
+                                str_amount = g_strdup ( "0.00" );
+                                str_desc = g_strconcat ( div_name, _(" (budget exceeded)"), NULL);
+                            }
                         }
                         else
                         {
-                            str_credit = gsb_real_get_string_with_currency (
-                                        null_real,
-                                        bet_data_get_selected_currency ( ),
-                                        TRUE );
-                            if ( str_amount )
-                                g_free ( str_amount );
-                            str_amount = g_strdup ( "0.00" );
-                            str_desc = g_strconcat ( div_name, _(" (budget exceeded)"), NULL);
+                            if ( number.mantissa > 0 )
+                            {
+                                str_amount = gsb_real_save_real_to_string ( number, 2 );
+                                str_credit = gsb_real_get_string_with_currency (
+                                            gsb_real_abs ( number ),
+                                            bet_data_get_selected_currency ( ),
+                                            TRUE );
+                                str_desc = g_strconcat ( div_name, _(" (yet to receive)"), NULL);
+                            }
+                            else
+                            {
+                                str_credit = gsb_real_get_string_with_currency (
+                                            null_real,
+                                            bet_data_get_selected_currency ( ),
+                                            TRUE );
+                                str_amount = g_strdup ( "0.00" );
+                                str_desc = g_strconcat ( div_name, _(" (budget exceeded)"), NULL);
+                            }
                         }
 
                         gtk_tree_store_set ( GTK_TREE_STORE ( model ), &iter,
-                                        SPP_ESTIMATE_TREE_DESC_COLUMN, str_desc,
-                                        SPP_ESTIMATE_TREE_DEBIT_COLUMN, str_debit,
-                                        SPP_ESTIMATE_TREE_CREDIT_COLUMN, str_credit,
-                                        SPP_ESTIMATE_TREE_AMOUNT_COLUMN, str_amount,
-                                        -1 );
-
-                        g_free ( str_desc );
-                        g_free ( str_credit );
-                        g_free ( str_debit );
-                        g_free ( str_amount );
+                                            SPP_ESTIMATE_TREE_DESC_COLUMN, str_desc,
+                                            SPP_ESTIMATE_TREE_DEBIT_COLUMN, str_debit,
+                                            SPP_ESTIMATE_TREE_CREDIT_COLUMN, str_credit,
+                                            SPP_ESTIMATE_TREE_AMOUNT_COLUMN, str_amount,
+                                            -1 );
+
+                            g_free ( str_desc );
+                            g_free ( str_credit );
+                            g_free ( str_debit );
+                            g_free ( str_amount );
                     }
                     g_free ( str_date );
                     g_free ( div_name );


hooks/post-receive
-- 
grisbi


More information about the cvs mailing list