[grisbi-cvs] [SCM] grisbi branch, master, updated. 1b99c73947c147df5383c75f38152abbfae43079

Pierre Biava nobody at users.sourceforge.net
Sun Aug 1 00:06:54 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  1b99c73947c147df5383c75f38152abbfae43079 (commit)
      from  2ac26ab7f70eed840f43942050b4818295bb02cf (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 1b99c73947c147df5383c75f38152abbfae43079
Author: pbiava <pierre.biava at nerim.net>
Date:   Sun Aug 1 00:06:14 2010 +0200

    Added amortization table for liability accounts

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

Changes:
diff --git a/src/bet_config.c b/src/bet_config.c
index 209b84a..e4913c2 100644
--- a/src/bet_config.c
+++ b/src/bet_config.c
@@ -29,21 +29,25 @@
 /*START_INCLUDE*/
 #include "bet_config.h"
 #include "bet_data.h"
+#include "bet_finance_ui.h"
 #include "bet_hist.h"
 #include "bet_tab.h"
-#include "utils_dates.h"
+#include "dialog.h"
 #include "gsb_account.h"
 #include "gsb_automem.h"
+#include "gsb_calendar_entry.h"
+#include "gsb_currency.h"
 #include "gsb_data_account.h"
+#include "gsb_data_currency.h"
+#include "gsb_form_widget.h"
 #include "gsb_fyear.h"
+#include "include.h"
 #include "navigation.h"
-#include "dialog.h"
+#include "structures.h"
 #include "traitement_variables.h"
 #include "utils.h"
+#include "utils_dates.h"
 #include "utils_str.h"
-#include "bet_data.h"
-#include "structures.h"
-#include "include.h"
 #include "erreur.h"
 /*END_INCLUDE*/
 
@@ -52,19 +56,24 @@
 static gboolean bet_config_change_account ( GtkWidget *combo );
 static gint bet_config_get_account_from_combo ( void );
 static GtkWidget *bet_config_general_get_period_widget ( GtkWidget *container );
+static GtkWidget *bet_config_account_get_finance_data ( gchar *title );
+static GtkWidget *bet_config_get_finance_widget ( GtkWidget *parent );
 static GtkWidget *bet_config_account_get_forecast_data ( gchar *title );
 static GtkWidget *bet_config_account_get_select_account ( gchar *title );
 static GtkWidget *bet_config_account_get_select_historical_data ( gchar *title );
+static void bet_config_finance_apply_clicked ( GtkButton *button, GtkWidget *parent );
 static GtkWidget *bet_config_get_select_labels_widget ( GtkWidget *container );
 static void bet_config_period_clicked ( GtkWidget *togglebutton, GtkWidget *button );
 static gboolean bet_config_select_label_changed ( GtkWidget *checkbutton,
-					    gpointer data );
+                        gpointer data );
 static GtkWidget *bet_config_get_select_historical_data ( GtkWidget *container,
                         GtkWidget *notebook );
 static void bet_config_sensitive_account_parameters ( gint account_number, gboolean sensitive );
 static void bet_config_use_budget_toggle ( GtkToggleButton *button, GtkWidget *notebook );
 static void bet_config_initialise_duration_widget ( gint account_number,
                         GtkWidget *notebook );
+static void bet_config_initialise_finance_widget ( gint account_number,
+                        GtkWidget *notebook );
 static void bet_config_initialise_select_historical_data ( gint account_number,
                         GtkWidget *notebook );
 /*END_STATIC*/
@@ -231,9 +240,16 @@ GtkWidget *bet_config_account_create_account_page ( void )
     gtk_box_pack_start ( GTK_BOX ( vbox ), widget, FALSE, FALSE, 0 );
 
     /* Data for the account of type GSB_TYPE_LIABILITIES */
-    //~ vbox = gtk_vbox_new ( FALSE, 0 );
-    //~ gtk_notebook_append_page ( GTK_NOTEBOOK ( notebook ), vbox, NULL );
+    vbox = gtk_vbox_new ( FALSE, 0 );
+    gtk_notebook_append_page ( GTK_NOTEBOOK ( notebook ), vbox, NULL );
+    gtk_widget_show ( vbox );
+
+    /* Data for the credit */
+    widget = bet_config_account_get_finance_data ( _("Credit Data") );
+    g_object_set_data ( G_OBJECT ( account_page ), "Data_for_credit", widget );
+    gtk_box_pack_start ( GTK_BOX ( vbox ), widget, FALSE, FALSE, 0 );
 
+    /* mettre à jour les données du compte */
     widget = g_object_get_data ( G_OBJECT ( account_page ), "account_combo" );
     bet_config_change_account ( widget );
 
@@ -953,8 +969,9 @@ gboolean bet_config_change_account ( GtkWidget *combo )
             bet_config_initialise_select_historical_data ( account_number, account_page );
             break;
         case GSB_TYPE_LIABILITIES:
-            //~ gtk_notebook_set_current_page ( GTK_NOTEBOOK ( notebook ), 1 ); 
-            //~ break;
+            gtk_notebook_set_current_page ( GTK_NOTEBOOK ( notebook ), 1 );
+            bet_config_initialise_finance_widget ( account_number, account_page );
+            break;
         case GSB_TYPE_ASSET:
             break;
     }
@@ -990,7 +1007,7 @@ gint bet_config_get_account_from_combo ( void )
  * \return FALSE
  * */
 gboolean bet_config_select_label_changed ( GtkWidget *checkbutton,
-						   gpointer data )
+                        gpointer data )
 {
     gint value;
     gint origine;
@@ -1024,7 +1041,7 @@ gboolean bet_config_select_label_changed ( GtkWidget *checkbutton,
 void bet_config_sensitive_account_parameters ( gint account_number, gboolean sensitive )
 {
     GtkWidget *widget = NULL;
-printf ("account_number = %d sensitive = %d\n", account_number, sensitive);
+
     if ( sensitive )
     {
         kind_account kind;
@@ -1037,19 +1054,32 @@ printf ("account_number = %d sensitive = %d\n", account_number, sensitive);
             gtk_widget_show_all ( widget );
             widget = g_object_get_data ( G_OBJECT ( account_page ), "Data_for_historical" );
             gtk_widget_show_all ( widget );
+            widget = g_object_get_data ( G_OBJECT ( account_page ), "Data_for_credit" );
+            gtk_widget_hide_all ( widget );
             break;
         case GSB_TYPE_CASH:
             widget = g_object_get_data ( G_OBJECT ( account_page ), "Data_for_forecast" );
             gtk_widget_hide_all ( widget );
             widget = g_object_get_data ( G_OBJECT ( account_page ), "Data_for_historical" );
             gtk_widget_show_all ( widget );
+            widget = g_object_get_data ( G_OBJECT ( account_page ), "Data_for_credit" );
+            gtk_widget_hide_all ( widget );
             break;
         case GSB_TYPE_LIABILITIES:
+            widget = g_object_get_data ( G_OBJECT ( account_page ), "Data_for_forecast" );
+            gtk_widget_hide_all ( widget );
+            widget = g_object_get_data ( G_OBJECT ( account_page ), "Data_for_historical" );
+            gtk_widget_hide_all ( widget );
+            widget = g_object_get_data ( G_OBJECT ( account_page ), "Data_for_credit" );
+            gtk_widget_show_all ( widget );
+            break;
         case GSB_TYPE_ASSET:
             widget = g_object_get_data ( G_OBJECT ( account_page ), "Data_for_forecast" );
             gtk_widget_hide_all ( widget );
             widget = g_object_get_data ( G_OBJECT ( account_page ), "Data_for_historical" );
             gtk_widget_hide_all ( widget );
+            widget = g_object_get_data ( G_OBJECT ( account_page ), "Data_for_credit" );
+            gtk_widget_hide_all ( widget );
             break;
         }
     }
@@ -1104,6 +1134,298 @@ void bet_config_use_budget_toggle ( GtkToggleButton *button, GtkWidget *combo )
  *
  *
  * */
+GtkWidget *bet_config_account_get_finance_data ( gchar *title )
+{
+    GtkWidget *vbox;
+    GtkWidget *widget;
+    GtkWidget *paddingbox;
+
+    vbox = gtk_vbox_new ( FALSE, 0 );
+    paddingbox = new_paddingbox_with_title ( vbox, FALSE, _(title) );
+
+    /* Data of credit */
+    widget = bet_config_get_finance_widget ( vbox );
+    gtk_box_pack_start ( GTK_BOX ( paddingbox ), widget, FALSE, FALSE, 0);
+
+    return vbox;
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+GtkWidget *bet_config_get_finance_widget ( GtkWidget *parent )
+{
+    GtkWidget *vbox;
+    GtkWidget *hbox;
+    GtkWidget *label;
+    GtkWidget *widget;
+    GtkWidget *spin_button = NULL;
+    GtkWidget *button_1, *button_2;
+    GtkWidget *button;
+
+    vbox = gtk_vbox_new ( FALSE, 5 );
+
+    /* Loan Capital */
+    hbox = gtk_hbox_new ( FALSE, 5 );
+    gtk_box_pack_start ( GTK_BOX ( vbox ), hbox, FALSE, FALSE, 5);
+
+    label = gtk_label_new ( COLON( _("Loan Capital") ) );
+    gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
+    gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
+
+    widget = gtk_entry_new ( );
+    gtk_widget_set_size_request ( widget, 90, -1 );
+    g_object_set_data ( G_OBJECT ( parent ), "bet_config_capital", widget );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), widget, FALSE, FALSE, 5 );
+    g_signal_connect ( G_OBJECT ( widget ),
+                        "changed",
+                        G_CALLBACK ( gsb_form_widget_amount_entry_changed ),
+                        NULL );
+
+    label = gtk_label_new ( NULL );
+    g_object_set_data ( G_OBJECT ( parent ), "bet_config_capital_devise", label );
+    gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
+
+    /* Duration */
+    label = gtk_label_new ( COLON( _("Duration") ) );
+    gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
+    gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
+
+    spin_button = gtk_spin_button_new_with_range ( 1.0, 30, 1.0);
+    g_object_set_data ( G_OBJECT ( parent ), "bet_config_duree", spin_button );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), spin_button, FALSE, FALSE, 0 );
+
+    label = gtk_label_new ( _("year") );
+    g_object_set_data ( G_OBJECT ( parent ), "bet_config_unit_duree", label );
+    gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
+
+    /* Date of first Repayment */
+    hbox = gtk_hbox_new ( FALSE, 5 );
+    gtk_box_pack_start ( GTK_BOX ( vbox ), hbox, FALSE, FALSE, 5);
+
+    label = gtk_label_new ( COLON( _("Date of first Repayment") ) );
+    gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
+    gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
+
+    widget = gsb_calendar_entry_new ( FALSE );
+    g_object_set_data ( G_OBJECT ( parent ), "bet_config_start_date", widget );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), widget, FALSE, FALSE, 5 );
+
+    /* Annuel rate interest */
+    hbox = gtk_hbox_new ( FALSE, 5 );
+    gtk_box_pack_start ( GTK_BOX ( vbox ), hbox, FALSE, FALSE, 5);
+
+    label = gtk_label_new ( COLON( _("Annuel rate interest") ) );
+    gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
+    gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
+
+    spin_button = gtk_spin_button_new_with_range ( 0.0, 100, 0.01);
+    g_object_set_data ( G_OBJECT ( parent ), "bet_config_taux", spin_button );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), spin_button, FALSE, FALSE, 0 );
+
+    label = gtk_label_new ( _("%") );
+    gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
+
+    /* frais */
+    hbox = gtk_hbox_new ( FALSE, 5 );
+    gtk_box_pack_start ( GTK_BOX ( vbox ), hbox, FALSE, FALSE, 5);
+
+    label = gtk_label_new ( COLON( _("Fees per month") ) );
+    gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
+    gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
+
+    widget = gtk_entry_new ( );
+    gtk_widget_set_size_request ( widget, 50, -1 );
+    g_object_set_data ( G_OBJECT ( parent ), "bet_config_montant_frais", widget );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), widget, FALSE, FALSE, 5 );
+    g_signal_connect ( G_OBJECT ( widget ),
+                        "changed",
+                        G_CALLBACK ( gsb_form_widget_amount_entry_changed ),
+                        NULL );
+
+    label = gtk_label_new ( NULL );
+    g_object_set_data ( G_OBJECT ( parent ), "bet_config_frais_devise", label );
+    gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
+
+    /* Rate Type */
+    hbox = gtk_hbox_new ( FALSE, 5 );
+    gtk_box_pack_start ( GTK_BOX ( vbox ), hbox, FALSE, FALSE, 5);
+
+    label = gtk_label_new ( COLON( _("Rate Type") ) );
+    gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
+    gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
+    button_1 = gtk_radio_button_new_with_label ( NULL, _("CAGR") );
+    gtk_widget_set_sensitive ( button_1, FALSE );
+
+    button_2 = gtk_radio_button_new_with_label_from_widget ( GTK_RADIO_BUTTON ( button_1 ),
+                        _("Proportional rate") );
+    gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( button_2 ), TRUE );
+    g_object_set_data ( G_OBJECT ( parent ), "bet_config_type_taux", button_2 );
+    gtk_widget_set_sensitive ( button_2, FALSE );
+
+    gtk_box_pack_start ( GTK_BOX ( hbox ), button_1, FALSE, FALSE, 5) ;
+    gtk_box_pack_start ( GTK_BOX ( hbox ), button_2, FALSE, FALSE, 5) ;
+    //~ g_signal_connect ( button_1,
+                        //~ "released",
+                        //~ G_CALLBACK ( bet_finance_type_taux_changed ),
+                        //~ parent );
+    //~ g_signal_connect ( button_2,
+                        //~ "released",
+                        //~ G_CALLBACK ( bet_finance_type_taux_changed ),
+                        //~ parent );
+
+    button = gtk_button_new_with_label ( _("Apply") );
+    gtk_button_set_relief ( GTK_BUTTON ( button ), GTK_RELIEF_NONE );
+    g_signal_connect ( G_OBJECT ( button ),
+                        "clicked",
+                        G_CALLBACK ( bet_config_finance_apply_clicked ),
+                        parent );
+    gtk_box_pack_start ( GTK_BOX ( vbox ), button, FALSE, FALSE, 5);
+    return vbox;
+}
+/**
+ *
+ *
+ *
+ *
+ * */
+void bet_config_initialise_finance_widget ( gint account_number,
+                        GtkWidget *notebook )
+{
+    GtkWidget *parent;
+    GtkWidget *widget;
+    GtkWidget *button = NULL;
+    gchar *code_devise;
+    gint devise;
+    gint nbre_ans;
+    gdouble taux;
+
+    //~ devel_debug (NULL);
+    parent = g_object_get_data ( G_OBJECT ( notebook ), "Data_for_credit" );
+    /* get devise */
+    devise = gsb_data_account_get_currency ( account_number );
+    code_devise = gsb_data_currency_get_code_or_isocode ( devise );
+
+    /* set devise labels */
+    widget = g_object_get_data ( G_OBJECT ( parent ), "bet_config_capital_devise" );
+    gtk_label_set_label ( GTK_LABEL ( widget ), code_devise );
+
+    widget = g_object_get_data ( G_OBJECT ( parent ), "bet_config_frais_devise" );
+    gtk_label_set_label ( GTK_LABEL ( widget ), code_devise );
+
+    /* set capital */
+    widget = g_object_get_data ( G_OBJECT ( parent ), "bet_config_capital" );
+    gtk_entry_set_text ( GTK_ENTRY ( widget ),
+                        gsb_real_get_string_with_currency (
+                        gsb_real_double_to_real (
+                        gsb_data_account_get_bet_finance_capital ( account_number ) ),
+                        devise, FALSE ) );
+
+    /* set duration */
+    nbre_ans = gsb_data_account_get_bet_months ( account_number ) / 12;
+    button = g_object_get_data ( G_OBJECT ( parent ), "bet_config_duree" );
+    gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( button ), nbre_ans );
+    widget = g_object_get_data ( G_OBJECT ( parent ), "bet_config_unit_duree" );
+    if ( nbre_ans == 1 )
+        gtk_label_set_label ( GTK_LABEL ( widget ), _("year") );
+    else
+        gtk_label_set_label ( GTK_LABEL ( widget ), _("years") );
+
+    /* set start_date */
+    widget = g_object_get_data ( G_OBJECT ( parent ), "bet_config_start_date" );
+    gsb_calendar_entry_set_date ( widget,
+                        gsb_data_account_get_bet_start_date ( account_number ) );
+
+    /* set taux */
+    button = g_object_get_data ( G_OBJECT ( parent ), "bet_config_taux" );
+    taux = gsb_data_account_get_bet_finance_taux_annuel ( account_number );
+    gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( button ), taux );
+
+    /* set frais */
+    widget = g_object_get_data ( G_OBJECT ( parent ), "bet_config_montant_frais" );
+    gtk_entry_set_text ( GTK_ENTRY ( widget ),
+                        gsb_real_get_string_with_currency (
+                        gsb_real_double_to_real (
+                        gsb_data_account_get_bet_finance_frais ( account_number ) ),
+                        devise, FALSE ) );
+
+    /* set type taux */
+    button = g_object_get_data ( G_OBJECT ( parent ), "bet_config_type_taux" );
+    gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( button ),
+                        gsb_data_account_get_bet_finance_type_taux ( account_number ) );
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+void bet_config_finance_apply_clicked ( GtkButton *button, GtkWidget *parent )
+{
+    GtkWidget *bouton;
+    gdouble number;
+    gint type_taux;
+    gint account_number;
+
+    account_number = bet_config_get_account_from_combo ( );
+
+    /* capital */
+    number = bet_finance_get_number_from_string ( parent, "bet_config_capital" );
+    gsb_data_account_set_bet_finance_capital ( account_number, number );
+
+    if ( number == 0 )
+    {
+        gchar *tmp_str;
+
+        tmp_str = g_strdup ( _("You must enter at least one value for the capital") );
+        dialogue_error ( tmp_str );
+        g_free ( tmp_str );
+        return;
+    }
+
+    /* Duration */
+    number = bet_finance_get_number_from_string ( parent, "bet_config_duree" );
+    gsb_data_account_set_bet_months ( account_number, number * 12 );
+
+    /* rate */
+    number = bet_finance_get_number_from_string ( parent, "bet_config_taux" );
+    gsb_data_account_set_bet_finance_taux_annuel ( account_number, number );
+
+    /* frais */
+    number = bet_finance_get_number_from_string ( parent, "bet_config_montant_frais" );
+    gsb_data_account_set_bet_finance_frais ( account_number, number );
+
+    /* type de taux */
+    bouton = g_object_get_data ( G_OBJECT ( parent ), "bet_config_type_taux" );
+    type_taux = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( bouton ) );
+    gsb_data_account_set_bet_finance_type_taux ( account_number, type_taux );
+
+    bet_finance_ui_update_amortization_tab ( account_number );
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */
diff --git a/src/bet_data.c b/src/bet_data.c
index 5e747aa..451a8a6 100644
--- a/src/bet_data.c
+++ b/src/bet_data.c
@@ -120,32 +120,39 @@ void bet_data_select_bet_pages ( gint account_number )
         bet_array_list_select_path ( tree_view, NULL );
         page = gtk_notebook_get_nth_page ( GTK_NOTEBOOK ( account_page ), GSB_HISTORICAL_PAGE );
         gtk_widget_show ( page );
+        page = gtk_notebook_get_nth_page ( GTK_NOTEBOOK ( account_page ), GSB_FINANCE_PAGE );
+        gtk_widget_hide ( page );
         bet_historical_g_signal_unblock_tree_view ( );
         gsb_data_account_set_bet_maj ( account_number, BET_MAJ_ALL );
         if ( current_page < GSB_PROPERTIES_PAGE 
          && 
          gsb_data_account_get_bet_use_budget ( account_number ) == FALSE )
             gtk_notebook_set_current_page ( GTK_NOTEBOOK ( account_page ), GSB_TRANSACTIONS_PAGE );
+        if ( current_page == GSB_FINANCE_PAGE )
+            gtk_notebook_set_current_page ( GTK_NOTEBOOK ( account_page ), GSB_ESTIMATE_PAGE );
         break;
     case GSB_TYPE_CASH:
         page = gtk_notebook_get_nth_page ( GTK_NOTEBOOK ( account_page ), GSB_ESTIMATE_PAGE );
         gtk_widget_hide ( page );
         page = gtk_notebook_get_nth_page ( GTK_NOTEBOOK ( account_page ), GSB_HISTORICAL_PAGE );
         gtk_widget_show ( page );
-        if ( current_page == GSB_ESTIMATE_PAGE )
+        page = gtk_notebook_get_nth_page ( GTK_NOTEBOOK ( account_page ), GSB_FINANCE_PAGE );
+        gtk_widget_hide ( page );
+        if ( current_page == GSB_ESTIMATE_PAGE || current_page == GSB_FINANCE_PAGE )
             gtk_notebook_set_current_page ( GTK_NOTEBOOK ( account_page ), GSB_HISTORICAL_PAGE );
         bet_historical_g_signal_block_tree_view ( );
         gsb_data_account_set_bet_maj ( account_number, BET_MAJ_HISTORICAL );
         break;
     case GSB_TYPE_LIABILITIES:
         page = gtk_notebook_get_nth_page ( GTK_NOTEBOOK ( account_page ), GSB_ESTIMATE_PAGE );
-        gtk_widget_show ( page );
+        gtk_widget_hide ( page );
         bet_array_list_select_path ( tree_view, NULL );
-        if ( current_page == GSB_HISTORICAL_PAGE )
-            gtk_notebook_set_current_page ( GTK_NOTEBOOK ( account_page ), GSB_ESTIMATE_PAGE );
         page = gtk_notebook_get_nth_page ( GTK_NOTEBOOK ( account_page ), GSB_HISTORICAL_PAGE );
         gtk_widget_hide ( page );
-        gsb_data_account_set_bet_maj ( account_number, BET_MAJ_ESTIMATE );
+        page = gtk_notebook_get_nth_page ( GTK_NOTEBOOK ( account_page ), GSB_FINANCE_PAGE );
+        gtk_widget_show ( page );
+        if ( current_page == GSB_ESTIMATE_PAGE || current_page == GSB_HISTORICAL_PAGE )
+            gtk_notebook_set_current_page ( GTK_NOTEBOOK ( account_page ), GSB_FINANCE_PAGE );
         break;
     case GSB_TYPE_ASSET:
         if ( current_page < GSB_PROPERTIES_PAGE )
@@ -154,6 +161,8 @@ void bet_data_select_bet_pages ( gint account_number )
         gtk_widget_hide ( page );
         page = gtk_notebook_get_nth_page ( GTK_NOTEBOOK ( account_page ), GSB_HISTORICAL_PAGE );
         gtk_widget_hide ( page );
+        page = gtk_notebook_get_nth_page ( GTK_NOTEBOOK ( account_page ), GSB_FINANCE_PAGE );
+        gtk_widget_hide ( page );
         break;
     }
 }
diff --git a/src/bet_data_finance.c b/src/bet_data_finance.c
index 9b2d500..45de4ee 100644
--- a/src/bet_data_finance.c
+++ b/src/bet_data_finance.c
@@ -25,6 +25,7 @@
 /*START_INCLUDE*/
 #include "bet_data_finance.h"
 #include "bet_finance_ui.h"
+#include "utils_dates.h"
 #include "utils_str.h"
 #include "erreur.h"
 /*END_INCLUDE*/
@@ -37,7 +38,7 @@
 /*END_EXTERN*/
 
 /**
- *
+ * retourne l'échéance hors frais
  *
  *
  *
@@ -62,9 +63,12 @@ gdouble bet_data_finance_get_echeance ( gdouble capital,
 
 
 /**
+ * Calcule le taux périodique d'un intérêt
  *
+ * /param taux d'intérêt
+ * /param type de taux : actuariel ou proportionnel
  *
- *
+ * /return a double
  *
  * */
 gdouble bet_data_finance_get_taux_periodique ( gdouble taux, gint type_taux )
@@ -82,7 +86,7 @@ gdouble bet_data_finance_get_taux_periodique ( gdouble taux, gint type_taux )
 
 
 /**
- *
+ * Calcule le montant des frais par échéances ( en général des assurances)
  *
  *
  *
@@ -101,7 +105,7 @@ gdouble bet_data_finance_get_frais_par_echeance ( gdouble capital,
 
 
 /**
- *
+ * Calcule les intérêts par période
  *
  *
  *
@@ -118,7 +122,7 @@ gdouble bet_data_finance_get_interets ( gdouble capital_du, gdouble taux_periodi
 
 
 /**
- *
+ * retourne le capital remboursé
  *
  *
  *
@@ -137,7 +141,7 @@ gdouble bet_data_finance_get_principal ( gdouble echeance,
 
 
 /**
- *
+ * Calcule la dernière échéance du prêt
  *
  *
  *
@@ -156,30 +160,48 @@ gdouble number;
 
 
 /**
+ * arrondit à la précision demandée
  *
+ * /param nombre à arrondir
+ * /param nombre de chiffres significatifs
  *
- *
+ * /return a double number
  *
  * */
 gdouble bet_data_finance_troncate_number ( gdouble number, gint nbre_decimal )
 {
-    gchar buffer[256];
     gchar *str_number;
-    gchar *format;
-    gint nbre_char;
     gdouble result;
 
-    format = g_strconcat ( "%.", utils_str_itoa ( nbre_decimal ), "f", NULL );
-
-    nbre_char = g_sprintf ( buffer, format, number );
-    str_number = g_strndup ( buffer, nbre_char + 1 );
-
+    str_number = utils_str_dtostr ( number, nbre_decimal, FALSE );
     result =  my_strtod ( str_number, NULL );
 
+    g_free ( str_number );
+
     return result;
 }
 
+GDate *bet_data_finance_get_date_last_installment_paid ( GDate *date_depart )
+{
+    GDate *date_jour;
+    GDateDay jour;
+
+    date_jour = gdate_today ( );
+    jour = g_date_get_day ( date_depart );
+
+    if ( g_date_get_day ( date_jour ) < jour )
+        g_date_subtract_months  ( date_jour, 1 );
+    
+    g_date_set_day ( date_jour, jour );
 
+    return date_jour;
+}
+/**
+ *
+ *
+ *
+ *
+ * */
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */
diff --git a/src/bet_data_finance.h b/src/bet_data_finance.h
index 81bab81..459438a 100644
--- a/src/bet_data_finance.h
+++ b/src/bet_data_finance.h
@@ -9,6 +9,7 @@
 
 
 /* START_DECLARATION */
+GDate *bet_data_finance_get_date_last_installment_paid ( GDate *date_depart );
 gdouble bet_data_finance_get_last_echeance ( gdouble capital_du,
                         gdouble interets,
                         gdouble frais );
diff --git a/src/bet_finance_ui.c b/src/bet_finance_ui.c
index 576e16e..e9cd706 100644
--- a/src/bet_finance_ui.c
+++ b/src/bet_finance_ui.c
@@ -29,11 +29,13 @@
 #include "fenetre_principale.h"
 #include "gsb_combo_box.h"
 #include "gsb_currency.h"
+#include "gsb_data_account.h"
 #include "gsb_form_widget.h"
 #include "gsb_real.h"
 #include "mouse.h"
+#include "navigation.h"
 #include "structures.h"
-#include "utils.h"
+#include "utils_dates.h"
 #include "erreur.h"
 /*END_INCLUDE*/
 
@@ -51,6 +53,7 @@
 
 /* structure amortissement */
  typedef struct {
+    gint origin;
     gint num_echeance;
     gint devise;
     gdouble taux_periodique;
@@ -59,13 +62,16 @@
     gdouble principal;
     gdouble frais;
     gdouble echeance;
+    gchar *str_date;
+    gchar *str_echeance;
+    gchar *str_frais;
 }  struct_amortissement;
 
 /*START_STATIC*/
 static void bet_finance_activate_expander ( GtkWidget *expander, GtkWidget *widget );
 static void bet_finance_calculer_clicked ( GtkButton *button, GtkWidget *widget );
 static GtkWidget *bet_finance_create_amortization_page ( void );
-static GtkWidget *bet_finance_create_amortization_tree_view ( GtkWidget *container );
+static GtkWidget *bet_finance_create_amortization_tree_view ( GtkWidget *container, gint origin );
 static GtkWidget *bet_finance_create_data_tree_view ( GtkWidget *container );
 static GtkWidget *bet_finance_create_duration_widget ( GtkWidget *parent );
 static GtkWidget *bet_finance_create_saisie_widget ( GtkWidget *parent );
@@ -81,11 +87,12 @@ static void bet_finance_fill_amortization_ligne ( GtkTreeModel *model,
                         struct_amortissement *s_amortissement );
 static void bet_finance_fill_data_ligne ( GtkTreeModel *model, struct_echeance *s_echeance );
 static gboolean bet_finance_list_set_background_color ( GtkWidget *tree_view, gint color_column );
-static gdouble bet_finance_get_number_from_string ( GtkWidget *parent, const gchar *name );
+static void bet_finance_ui_struct_amortization_free ( struct_amortissement *s_amortissement );
 static void bet_finance_type_taux_changed ( GtkWidget *togglebutton, GtkWidget *widget );
 /*END_STATIC*/
 
 /*START_EXTERN*/
+extern GtkWidget *account_page;
 extern GdkColor couleur_fond[2];
 /*END_EXTERN*/
 
@@ -115,6 +122,7 @@ static GtkWidget *finance_notebook;
  enum bet_finance_amortization_columns
 {
     BET_AMORTIZATION_NUMBER_COLUMN,
+    BET_AMORTIZATION_DATE_COLUMN,
     BET_AMORTIZATION_CAPITAL_DU_COLUMN,
     BET_AMORTIZATION_INTERETS_COLUMN,
     BET_AMORTIZATION_PRINCIPAL_COLUMN,
@@ -183,6 +191,7 @@ GtkWidget *bet_finance_create_simulator_page ( void )
     GtkWidget *button;
     GtkWidget *tree_view;
     GtkWidget *expander;
+    GtkEntryCompletion *completion;
 
     devel_debug (NULL);
 
@@ -203,13 +212,17 @@ GtkWidget *bet_finance_create_simulator_page ( void )
     gtk_container_add ( GTK_CONTAINER ( align ), hbox );
 
     /* capital */
-    label = gtk_label_new ( COLON( _("Montant emprunté") ) );
+    label = gtk_label_new ( COLON( _("Loan capital") ) );
     gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
     gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
     gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
 
+    completion = gtk_entry_completion_new ( );
     widget = gtk_entry_new ( );
-    //~ gtk_entry_set_text ( GTK_ENTRY ( widget ), "10000" );
+    gtk_entry_set_completion ( GTK_ENTRY ( widget ), completion );
+    //~ printf ("nbre de caractères avant completion =%d\n",
+        //~ gtk_entry_completion_get_minimum_key_length (completion));
+    gtk_entry_set_text ( GTK_ENTRY ( widget ), "177000" );
     g_object_set_data ( G_OBJECT ( page ), "capital", widget );
     gtk_box_pack_start ( GTK_BOX ( hbox ), widget, FALSE, FALSE, 5 );
     g_signal_connect ( G_OBJECT ( widget ),
@@ -223,22 +236,22 @@ GtkWidget *bet_finance_create_simulator_page ( void )
     gtk_box_pack_start ( GTK_BOX ( hbox ), widget, FALSE, FALSE, 0 );
 
     /* taux */
-    label = gtk_label_new ( COLON( _("Taux d'intérêt annuel") ) );
+    label = gtk_label_new ( COLON( _("Annual interest") ) );
     gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
     gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
     gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
 
     spin_button = gtk_spin_button_new_with_range ( 0.0, 100, 0.01);
-    //~ gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( spin_button ), 5.00);
+    gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( spin_button ), 3.80);
     g_object_set_data ( G_OBJECT ( page ), "taux", spin_button );
     gtk_box_pack_start ( GTK_BOX ( hbox ), spin_button, FALSE, FALSE, 0 );
 
-    label = gtk_label_new ( COLON( _("%") ) );
+    label = gtk_label_new ( _("%") );
     gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
     gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
 
-    /* durée */
-    label = gtk_label_new ( COLON( _("Durée") ) );
+    /* Duration */
+    label = gtk_label_new ( COLON( _("Duration") ) );
     gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
     gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
     gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
@@ -253,10 +266,10 @@ GtkWidget *bet_finance_create_simulator_page ( void )
 
     hbox = gtk_hbox_new ( FALSE, 5 );
     gtk_box_pack_start ( GTK_BOX ( vbox ), hbox, FALSE, FALSE, 5);
-    expander = gtk_expander_new ( _("Saisie détaillée") );
+    expander = gtk_expander_new ( _("Entering Detailed") );
     gtk_box_pack_start ( GTK_BOX ( hbox ), expander, TRUE, TRUE, 5 );
 
-    button = gtk_button_new_with_label ( _("Calculer") );
+    button = gtk_button_new_with_label ( _("Calculate") );
     g_signal_connect ( G_OBJECT ( button ),
                         "clicked",
                         G_CALLBACK ( bet_finance_calculer_clicked ),
@@ -292,8 +305,8 @@ GtkWidget *bet_finance_create_duration_widget ( GtkWidget *parent )
 {
     GtkWidget *combobox;
     gchar *text_duration [] = {
-    _("Entre 1 et 15 ans"),
-    _("Entre 15 et 30 ans"),
+    _("Between 1 and 15 years"),
+    _("Between 15 and 30 years"),
     NULL};
 
     combobox = gsb_combo_box_new_with_index ( text_duration,
@@ -348,17 +361,17 @@ GtkWidget *bet_finance_create_saisie_widget ( GtkWidget *parent )
     hbox = gtk_hbox_new ( FALSE, 5 );
     gtk_container_add ( GTK_CONTAINER ( align ), hbox );
 
-    label = gtk_label_new ( COLON( _("Frais") ) );
+    label = gtk_label_new ( COLON( _("Fees") ) );
     gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
     gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
     gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
 
     spin_button = gtk_spin_button_new_with_range ( 0.0, 100, 0.01 );
-    //~ gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( spin_button ), 0.35 );
+    gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( spin_button ), 6.96 );
     g_object_set_data ( G_OBJECT ( parent ), "frais", spin_button );
     gtk_box_pack_start ( GTK_BOX ( hbox ), spin_button, FALSE, FALSE, 0 );
 
-    label = gtk_label_new ( _("% du capital emprunté") );
+    label = gtk_label_new ( _("% of borrowed capital") );
     gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
     gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
 
@@ -369,15 +382,15 @@ GtkWidget *bet_finance_create_saisie_widget ( GtkWidget *parent )
     hbox = gtk_hbox_new ( FALSE, 5 );
     gtk_container_add ( GTK_CONTAINER ( align ), hbox );
 
-    label = gtk_label_new ( COLON( _("Type de taux") ) );
+    label = gtk_label_new ( COLON( _("Rate Type") ) );
     gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
     gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
     gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
-    button_1 = gtk_radio_button_new_with_label ( NULL, _("Taux actuariel") );
+    button_1 = gtk_radio_button_new_with_label ( NULL, _("CAGR") );
     gtk_widget_set_sensitive ( button_1, FALSE );
 
     button_2 = gtk_radio_button_new_with_label_from_widget ( GTK_RADIO_BUTTON ( button_1 ),
-                        _("Taux proportionnel") );
+                        _("Proportional rate") );
     gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( button_2 ), TRUE );
     g_object_set_data ( G_OBJECT ( parent ), "type_taux", button_2 );
     gtk_widget_set_sensitive ( button_2, FALSE );
@@ -437,8 +450,9 @@ GtkWidget *bet_finance_create_data_tree_view ( GtkWidget *container )
     g_object_unref ( G_OBJECT ( tree_model ) );
 
     /* create columns */
-    /* durée */
-    title = g_strdup ( _("Durée") );
+
+    /* Duration */
+    title = g_strdup ( _("Duration") );
     cell = gtk_cell_renderer_text_new ( );
     g_object_set ( G_OBJECT ( cell ), "xalign", 0.5, NULL );
 
@@ -454,8 +468,8 @@ GtkWidget *bet_finance_create_data_tree_view ( GtkWidget *container )
     gtk_tree_view_column_set_alignment ( column, 0.5 );
     g_free ( title );
 
-    /* Nombre d'échéances */
-    title = g_strdup ( _("Nombre\nd'échéances") );
+    /* Number of periods */
+    title = g_strdup ( _("Number\nof periods") );
     cell = gtk_cell_renderer_text_new ( );
     g_object_set ( G_OBJECT ( cell ), "xalign", 0.5, NULL );
 
@@ -471,8 +485,8 @@ GtkWidget *bet_finance_create_data_tree_view ( GtkWidget *container )
     gtk_tree_view_column_set_alignment ( column, 0.5 );
     g_free ( title );
 
-    /* Capital emprunté */
-    title = g_strdup ( _("Capital\nemprunté") );
+    /* Loan capital */
+    title = g_strdup ( _("Loan\ncapital") );
     cell = gtk_cell_renderer_text_new ( );
     g_object_set ( G_OBJECT ( cell ), "xalign", 0.5, NULL );
 
@@ -488,8 +502,8 @@ GtkWidget *bet_finance_create_data_tree_view ( GtkWidget *container )
     gtk_tree_view_column_set_alignment ( column, 0.5 );
     g_free ( title );
 
-    /* Taux d'emprunt */
-    title = g_strdup ( _("Taux\nd'emprunt") );
+    /* Annuel rate interest */
+    title = g_strdup ( _("Annuel\nrate interest") );
     cell = gtk_cell_renderer_text_new ( );
     g_object_set ( G_OBJECT ( cell ), "xalign", 0.5, NULL );
 
@@ -505,8 +519,8 @@ GtkWidget *bet_finance_create_data_tree_view ( GtkWidget *container )
     gtk_tree_view_column_set_alignment ( column, 0.5 );
     g_free ( title );
 
-    /* Echéance hors frais*/
-    title = g_strdup ( _("Echéance\nhors frais") );
+    /* Amount without fees */
+    title = g_strdup ( _("Amount\nwithout fees") );
     cell = gtk_cell_renderer_text_new ( );
     g_object_set ( G_OBJECT ( cell ), "xalign", 0.5, NULL );
 
@@ -522,8 +536,8 @@ GtkWidget *bet_finance_create_data_tree_view ( GtkWidget *container )
     gtk_tree_view_column_set_alignment ( column, 0.5 );
     g_free ( title );
 
-    /* Frais */
-    title = g_strdup ( _("Frais") );
+    /* Fees */
+    title = g_strdup ( _("Fees") );
     cell = gtk_cell_renderer_text_new ( );
     g_object_set ( G_OBJECT ( cell ), "xalign", 0.5, NULL );
 
@@ -539,8 +553,8 @@ GtkWidget *bet_finance_create_data_tree_view ( GtkWidget *container )
     gtk_tree_view_column_set_alignment ( column, 0.5 );
     g_free ( title );
 
-    /* Montant de l'échéance */
-    title = g_strdup ( _("Echéance\ntotale") );
+    /* Monthly paid */
+    title = g_strdup ( _("Monthly paid") );
     cell = gtk_cell_renderer_text_new ( );
     g_object_set ( G_OBJECT ( cell ), "xalign", 0.5, NULL );
 
@@ -610,16 +624,16 @@ void bet_finance_calculer_clicked ( GtkButton *button, GtkWidget *widget )
     {
         gchar *tmp_str;
 
-        tmp_str = g_strdup ( _(" Vous devez au moins entrer une valeur pour le capital") );
+        tmp_str = g_strdup ( _("You must enter at least one value for the capital") );
         dialogue_error ( tmp_str );
         g_free ( tmp_str );
         return;
     }
 
-    /* taux */
+    /* rate */
     s_echeance -> taux = bet_finance_get_number_from_string ( widget, "taux" );
 
-    /* durée */
+    /* Duration */
     combobox = g_object_get_data ( G_OBJECT ( widget ), "duree" );
     if ( combobox )
         index = gsb_combo_box_get_index ( combobox );
@@ -708,11 +722,13 @@ gdouble bet_finance_get_number_from_string ( GtkWidget *parent, const gchar *nam
 
             combobox = g_object_get_data ( G_OBJECT ( parent ), "devise" );
             if ( combobox )
+            {
                 devise = gsb_currency_get_currency_from_combobox ( combobox );
-            tmp_str = gsb_real_get_string_with_currency (
-                        gsb_real_double_to_real ( number ), devise, FALSE );
-            gtk_entry_set_text ( GTK_ENTRY ( widget ), tmp_str );
-            g_free ( tmp_str );
+                tmp_str = gsb_real_get_string_with_currency (
+                                gsb_real_double_to_real ( number ), devise, FALSE );
+                gtk_entry_set_text ( GTK_ENTRY ( widget ), tmp_str );
+                g_free ( tmp_str );
+            }
         }
     }
     else if ( GTK_IS_SPIN_BUTTON  ( widget ) )
@@ -742,9 +758,9 @@ void bet_finance_fill_data_ligne ( GtkTreeModel *model, struct_echeance *s_echea
     gint nbre_char;
 
     if ( s_echeance -> duree == 1 )
-        str_duree = g_strconcat ( utils_str_itoa ( s_echeance -> duree ), " an", NULL );
+        str_duree = g_strconcat ( utils_str_itoa ( s_echeance -> duree ), _(" year "), NULL );
     else
-        str_duree = g_strconcat ( utils_str_itoa ( s_echeance -> duree ), " ans", NULL );
+        str_duree = g_strconcat ( utils_str_itoa ( s_echeance -> duree ), _(" years "), NULL );
 
     str_capital = gsb_real_get_string_with_currency (
                         gsb_real_double_to_real ( s_echeance -> capital ),
@@ -912,7 +928,7 @@ void bet_finance_data_list_context_menu ( GtkWidget *tree_view, gint page_num )
 
     if ( page_num == 0 )
     {
-        menu_item = gtk_image_menu_item_new_with_label ( _("Afficher le tableau d'amortissement") );
+        menu_item = gtk_image_menu_item_new_with_label ( _("View amortization table") );
         g_signal_connect ( G_OBJECT ( menu_item ),
                         "activate",
                         G_CALLBACK ( bet_finance_fill_amortization_array ),
@@ -920,7 +936,7 @@ void bet_finance_data_list_context_menu ( GtkWidget *tree_view, gint page_num )
     }
     else
     {
-        menu_item = gtk_image_menu_item_new_with_label ( _("Afficher le simulateur de crédits") );
+        menu_item = gtk_image_menu_item_new_with_label ( _("View credits simulator") );
         g_signal_connect ( G_OBJECT ( menu_item ),
                         "activate",
                         G_CALLBACK ( bet_finance_switch_simulator_page ),
@@ -938,7 +954,7 @@ void bet_finance_data_list_context_menu ( GtkWidget *tree_view, gint page_num )
 
 
 /**
- * Create the array page
+ * Create the amortization page
  *
  *
  *
@@ -959,7 +975,7 @@ GtkWidget *bet_finance_create_amortization_page ( void )
     align = gtk_alignment_new (0.5, 0.0, 0.0, 0.0);
     gtk_box_pack_start ( GTK_BOX ( page ), align, FALSE, FALSE, 5);
  
-    label = gtk_label_new ( _("Tableau d'ammortissement") );
+    label = gtk_label_new ( _("Amortization Table") );
     gtk_container_add ( GTK_CONTAINER ( align ), label );
 
     /* Choix des données sources */
@@ -970,7 +986,7 @@ GtkWidget *bet_finance_create_amortization_page ( void )
     gtk_container_add ( GTK_CONTAINER ( align ), hbox );
 
     /* capital */
-    label = gtk_label_new ( COLON( _("Montant emprunté") ) );
+    label = gtk_label_new ( COLON( _("Loan amount") ) );
     gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
     gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
     gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
@@ -980,7 +996,7 @@ GtkWidget *bet_finance_create_amortization_page ( void )
     gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
 
     /* taux */
-    label = gtk_label_new ( COLON( _("Taux d'intérêt annuel") ) );
+    label = gtk_label_new ( COLON( _("Annuel rate interest") ) );
     gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
     gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
     gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
@@ -989,12 +1005,12 @@ GtkWidget *bet_finance_create_amortization_page ( void )
     g_object_set_data ( G_OBJECT ( page ), "taux", label );
     gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 0 );
 
-    label = gtk_label_new ( COLON( _("%") ) );
+    label = gtk_label_new ( _("%") );
     gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
     gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
 
-    /* durée */
-    label = gtk_label_new ( COLON( _("Durée") ) );
+    /* Duration */
+    label = gtk_label_new ( COLON( _("Duration") ) );
     gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
     gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
     gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
@@ -1004,7 +1020,7 @@ GtkWidget *bet_finance_create_amortization_page ( void )
     gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 0 );
 
     /* création de la liste des données */
-    tree_view = bet_finance_create_amortization_tree_view ( page );
+    tree_view = bet_finance_create_amortization_tree_view ( page, 0 );
     g_object_set_data ( G_OBJECT ( page ), "tree_view", tree_view );
 
     gtk_widget_show_all ( page );
@@ -1019,7 +1035,7 @@ GtkWidget *bet_finance_create_amortization_page ( void )
  *
  *
  * */
-GtkWidget *bet_finance_create_amortization_tree_view ( GtkWidget *container )
+GtkWidget *bet_finance_create_amortization_tree_view ( GtkWidget *container, gint origin )
 {
     GtkWidget *scrolled_window;
     GtkWidget *tree_view;
@@ -1034,27 +1050,43 @@ GtkWidget *bet_finance_create_amortization_tree_view ( GtkWidget *container )
 
     /* Create the tree store */
     tree_model = gtk_tree_store_new ( BET_AMORTIZATION_NBRE_COLUMNS,
-                        G_TYPE_INT,         /* BET_AMORTIZATION_NUMBER_COLUMN          */
-                        G_TYPE_STRING,      /* BET_AMORTIZATION_CAPITAL_DU_COLUMN,     */
-                        G_TYPE_STRING,      /* BET_AMORTIZATION_INTERETS_COLUMN        */
-                        G_TYPE_STRING,      /* BET_AMORTIZATION_PRINCIPAL_COLUMN       */
-                        G_TYPE_STRING,      /* BET_AMORTIZATION_FRAIS_COLUMN           */
-                        G_TYPE_STRING,      /* BET_AMORTIZATION_ECHEANCE_COLUMN        */
-                        GDK_TYPE_COLOR );   /* BET_AMORTIZATION_BACKGROUND_COLOR       */
+                        G_TYPE_INT,         /* BET_AMORTIZATION_NUMBER_COLUMN       */
+                        G_TYPE_STRING,      /* BET_AMORTIZATION_DATE_COLUMN         */
+                        G_TYPE_STRING,      /* BET_AMORTIZATION_CAPITAL_DU_COLUMN,  */
+                        G_TYPE_STRING,      /* BET_AMORTIZATION_INTERETS_COLUMN     */
+                        G_TYPE_STRING,      /* BET_AMORTIZATION_PRINCIPAL_COLUMN    */
+                        G_TYPE_STRING,      /* BET_AMORTIZATION_FRAIS_COLUMN        */
+                        G_TYPE_STRING,      /* BET_AMORTIZATION_ECHEANCE_COLUMN     */
+                        GDK_TYPE_COLOR );   /* BET_AMORTIZATION_BACKGROUND_COLOR    */
     gtk_tree_view_set_model ( GTK_TREE_VIEW ( tree_view ), GTK_TREE_MODEL ( tree_model ) );
     g_object_unref ( G_OBJECT ( tree_model ) );
 
     /* create columns */
-    /* numéro de l'échéance */
-    title = g_strdup ( _("Numéro") );
+    /* numéro ou date de l'échéance */
     cell = gtk_cell_renderer_text_new ( );
     g_object_set ( G_OBJECT ( cell ), "xalign", 0.5, NULL );
 
-    column = gtk_tree_view_column_new_with_attributes ( title,
+    if ( origin == SPP_ORIGIN_FINANCE )
+    {
+        title = g_strdup ( _("Date") );
+
+        column = gtk_tree_view_column_new_with_attributes ( title,
+                        cell,
+                        "text", BET_AMORTIZATION_DATE_COLUMN,
+                        "cell-background-gdk", BET_AMORTIZATION_BACKGROUND_COLOR,
+                        NULL);
+    }
+    else
+    {
+        title = g_strdup ( _("Number") );
+
+        column = gtk_tree_view_column_new_with_attributes ( title,
                         cell,
                         "text", BET_AMORTIZATION_NUMBER_COLUMN,
                         "cell-background-gdk", BET_AMORTIZATION_BACKGROUND_COLOR,
                         NULL);
+    }
+
     gtk_tree_view_append_column ( GTK_TREE_VIEW ( tree_view ),
                         GTK_TREE_VIEW_COLUMN ( column ) );
     gtk_tree_view_column_set_expand ( GTK_TREE_VIEW_COLUMN ( column ), TRUE );
@@ -1063,7 +1095,7 @@ GtkWidget *bet_finance_create_amortization_tree_view ( GtkWidget *container )
     g_free ( title );
 
     /* Capital restant dû */
-    title = g_strdup ( _("Capital restant dû") );
+    title = g_strdup ( _("Capital remaining") );
     cell = gtk_cell_renderer_text_new ( );
     g_object_set ( G_OBJECT ( cell ), "xalign", 0.5, NULL );
 
@@ -1079,8 +1111,8 @@ GtkWidget *bet_finance_create_amortization_tree_view ( GtkWidget *container )
     gtk_tree_view_column_set_alignment ( column, 0.5 );
     g_free ( title );
 
-    /* Capital emprunté */
-    title = g_strdup ( _("Intérêts") );
+    /* Interests */
+    title = g_strdup ( _("Interests") );
     cell = gtk_cell_renderer_text_new ( );
     g_object_set ( G_OBJECT ( cell ), "xalign", 0.5, NULL );
 
@@ -1096,8 +1128,8 @@ GtkWidget *bet_finance_create_amortization_tree_view ( GtkWidget *container )
     gtk_tree_view_column_set_alignment ( column, 0.5 );
     g_free ( title );
 
-    /* Capital remboursé */
-    title = g_strdup ( _("Principal") );
+    /* Capital repaid */
+    title = g_strdup ( _("Capital repaid") );
     cell = gtk_cell_renderer_text_new ( );
     g_object_set ( G_OBJECT ( cell ), "xalign", 0.5, NULL );
 
@@ -1113,8 +1145,8 @@ GtkWidget *bet_finance_create_amortization_tree_view ( GtkWidget *container )
     gtk_tree_view_column_set_alignment ( column, 0.5 );
     g_free ( title );
 
-    /* Frais*/
-    title = g_strdup ( _("Frais") );
+    /* Fees*/
+    title = g_strdup ( _("Insurance") );
     cell = gtk_cell_renderer_text_new ( );
     g_object_set ( G_OBJECT ( cell ), "xalign", 0.5, NULL );
 
@@ -1130,8 +1162,8 @@ GtkWidget *bet_finance_create_amortization_tree_view ( GtkWidget *container )
     gtk_tree_view_column_set_alignment ( column, 0.5 );
     g_free ( title );
 
-    /* Montant de l'échéance */
-    title = g_strdup ( _("Echéance") );
+    /* Monthly paid */
+    title = g_strdup ( _("Monthly paid") );
     cell = gtk_cell_renderer_text_new ( );
     g_object_set ( G_OBJECT ( cell ), "xalign", 0.5, NULL );
 
@@ -1147,7 +1179,8 @@ GtkWidget *bet_finance_create_amortization_tree_view ( GtkWidget *container )
     gtk_tree_view_column_set_alignment ( column, 0.5 );
     g_free ( title );
 
-    g_signal_connect ( G_OBJECT ( tree_view ),
+    if ( origin != SPP_ORIGIN_FINANCE )
+        g_signal_connect ( G_OBJECT ( tree_view ),
                         "button-press-event",
                         G_CALLBACK ( bet_finance_data_list_button_press ),
                         container );
@@ -1208,7 +1241,9 @@ void bet_finance_fill_amortization_array ( GtkWidget *menu_item,
                         BET_FINANCE_CAPITAL_DOUBLE, &s_amortissement -> capital_du,
                         BET_FINANCE_TAUX_COLUMN, &str_taux,
                         BET_FINANCE_TAUX_PERIODIQUE_DOUBLE, &taux_periodique,
+                        BET_FINANCE_FRAIS_COLUMN, &s_amortissement -> str_frais,
                         BET_FINANCE_FRAIS_DOUBLE, &s_amortissement -> frais,
+                        BET_FINANCE_ECHEANCE_COLUMN, &s_amortissement -> str_echeance,
                         BET_FINANCE_ECHEANCE_DOUBLE, &s_amortissement -> echeance,
                         -1 );
 
@@ -1242,6 +1277,10 @@ void bet_finance_fill_amortization_array ( GtkWidget *menu_item,
                         s_amortissement -> capital_du,
                         s_amortissement -> interets,
                         s_amortissement -> frais );
+            g_free ( s_amortissement -> str_echeance );
+            s_amortissement -> str_echeance = gsb_real_get_string_with_currency (
+                        gsb_real_double_to_real ( s_amortissement -> echeance ),
+                        s_amortissement ->  devise, TRUE );
             s_amortissement -> principal = s_amortissement -> capital_du;
         }
         else
@@ -1272,8 +1311,6 @@ void bet_finance_fill_amortization_ligne ( GtkTreeModel *model,
     gchar *str_capital_du = NULL;
     gchar *str_interets = NULL;
     gchar *str_principal = NULL;
-    gchar *str_frais = NULL;
-    gchar *str_echeance = NULL;
 
     str_capital_du = gsb_real_get_string_with_currency (
                         gsb_real_double_to_real ( s_amortissement -> capital_du ),
@@ -1287,24 +1324,32 @@ void bet_finance_fill_amortization_ligne ( GtkTreeModel *model,
                         gsb_real_double_to_real ( s_amortissement -> principal ),
                         s_amortissement ->  devise, TRUE );
 
-    str_frais = gsb_real_get_string_with_currency (
-                        gsb_real_double_to_real ( s_amortissement -> frais ),
-                        s_amortissement ->  devise, TRUE );
-
-    str_echeance = gsb_real_get_string_with_currency (
-                        gsb_real_double_to_real ( s_amortissement -> echeance ),
-                        s_amortissement ->  devise, TRUE );
-
     gtk_tree_store_append ( GTK_TREE_STORE ( model ), &iter, NULL );
-    gtk_tree_store_set ( GTK_TREE_STORE ( model ),
+
+    if ( s_amortissement -> origin == SPP_ORIGIN_FINANCE )
+    {
+        gtk_tree_store_set ( GTK_TREE_STORE ( model ),
+                        &iter,
+                        BET_AMORTIZATION_DATE_COLUMN, s_amortissement -> str_date,
+                        BET_AMORTIZATION_CAPITAL_DU_COLUMN, str_capital_du,
+                        BET_AMORTIZATION_INTERETS_COLUMN, str_interets,
+                        BET_AMORTIZATION_PRINCIPAL_COLUMN, str_principal,
+                        BET_AMORTIZATION_FRAIS_COLUMN, s_amortissement -> str_frais,
+                        BET_AMORTIZATION_ECHEANCE_COLUMN, s_amortissement -> str_echeance,
+                        - 1 );
+    }
+    else
+    {
+        gtk_tree_store_set ( GTK_TREE_STORE ( model ),
                         &iter,
                         BET_AMORTIZATION_NUMBER_COLUMN, s_amortissement -> num_echeance,
                         BET_AMORTIZATION_CAPITAL_DU_COLUMN, str_capital_du,
                         BET_AMORTIZATION_INTERETS_COLUMN, str_interets,
                         BET_AMORTIZATION_PRINCIPAL_COLUMN, str_principal,
-                        BET_AMORTIZATION_FRAIS_COLUMN, str_frais,
-                        BET_AMORTIZATION_ECHEANCE_COLUMN, str_echeance,
+                        BET_AMORTIZATION_FRAIS_COLUMN, s_amortissement -> str_frais,
+                        BET_AMORTIZATION_ECHEANCE_COLUMN, s_amortissement -> str_echeance,
                         - 1 );
+    }
 
     g_free ( str_capital_du );
     g_free ( str_interets );
@@ -1313,6 +1358,237 @@ void bet_finance_fill_amortization_ligne ( GtkTreeModel *model,
 
 
 /**
+ * Create the account amortization page
+ *
+ *
+ *
+ * */
+GtkWidget *bet_finance_create_account_page ( void )
+{
+    GtkWidget *page;
+    GtkWidget *hbox;
+    GtkWidget *align;
+    GtkWidget *label;
+    GtkWidget *tree_view;
+
+    devel_debug (NULL);
+
+    page = gtk_vbox_new ( FALSE, 5 );
+
+    /* titre de la page */
+    align = gtk_alignment_new (0.5, 0.0, 0.0, 0.0);
+    gtk_box_pack_start ( GTK_BOX ( page ), align, FALSE, FALSE, 5);
+ 
+    label = gtk_label_new ( _("Amortization Table") );
+    g_object_set_data ( G_OBJECT ( account_page ), "bet_finance_amortization_title", label );
+    gtk_container_add ( GTK_CONTAINER ( align ), label );
+
+    /* Choix des données sources */
+    align = gtk_alignment_new (0.5, 0.0, 0.0, 0.0);
+    gtk_box_pack_start ( GTK_BOX ( page ), align, FALSE, FALSE, 5);
+
+    hbox = gtk_hbox_new ( FALSE, 5 );
+    gtk_container_add ( GTK_CONTAINER ( align ), hbox );
+
+    /* capital */
+    label = gtk_label_new ( COLON( _("Loan capital") ) );
+    gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
+    gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
+
+    label = gtk_label_new ( NULL );
+    g_object_set_data ( G_OBJECT ( account_page ), "bet_finance_capital", label );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
+
+    /* Annuel rate interest */
+    label = gtk_label_new ( COLON( _("Annuel rate interest") ) );
+    gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
+    gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
+
+    label = gtk_label_new ( NULL );
+    g_object_set_data ( G_OBJECT ( account_page ), "bet_finance_taux", label );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 0 );
+
+    label = gtk_label_new ( _("%") );
+    gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
+
+    /* Duration */
+    label = gtk_label_new ( COLON( _("Duration") ) );
+    gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
+    gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
+
+    label = gtk_label_new ( NULL );
+    g_object_set_data ( G_OBJECT ( account_page ), "bet_finance_duree", label );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 0 );
+
+    /* création de la liste des données */
+    tree_view = bet_finance_create_amortization_tree_view ( page, SPP_ORIGIN_FINANCE );
+    g_object_set_data ( G_OBJECT ( account_page ), "bet_finance_tree_view", tree_view );
+
+    gtk_widget_show_all ( page );
+
+    return page;
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+void bet_finance_ui_update_amortization_tab ( gint account_number )
+{
+    GtkWidget *page;
+    GtkWidget *label;
+    GtkWidget *tree_view;
+    GtkTreeModel *store;
+    gchar *tmp_str;
+    gchar *tmp_str_2;
+    gint index = 0;
+    gint nbre_ans;
+    gint nbre_echeances;
+    gint type_taux;
+    gdouble taux;
+    gdouble taux_periodique;
+    GDate *date;
+    GDate *last_paid_date;
+    struct_amortissement *s_amortissement;
+
+    //~ devel_debug ( NULL );
+    if ( gsb_gui_navigation_get_current_account ( ) != account_number )
+        return;
+
+    s_amortissement = g_malloc0 ( sizeof ( struct_amortissement ) );
+    s_amortissement -> origin = SPP_ORIGIN_FINANCE;
+
+    /* récupère la page du tableau d'amortissement */
+    page = gtk_notebook_get_nth_page ( GTK_NOTEBOOK ( finance_notebook ), 1 );
+
+    /* récupère les paramètres du compte */
+    s_amortissement -> devise = gsb_data_account_get_currency ( account_number );
+    nbre_echeances = gsb_data_account_get_bet_months ( account_number );
+    date = gsb_data_account_get_bet_start_date ( account_number );
+    s_amortissement -> str_date = gsb_format_gdate ( date );
+    last_paid_date = bet_data_finance_get_date_last_installment_paid ( date );
+
+    /* met à jour le titre du tableau */
+    label = g_object_get_data ( G_OBJECT ( account_page ), "bet_finance_amortization_title" );
+    tmp_str = g_strconcat ( _("Amortization Table"), " at ",
+                        gsb_format_gdate ( last_paid_date ), NULL );
+    gtk_label_set_label ( GTK_LABEL ( label ), tmp_str );
+    g_free ( tmp_str );
+
+    /* set capital */
+    s_amortissement -> capital_du = gsb_data_account_get_bet_finance_capital ( account_number );
+    label = g_object_get_data ( G_OBJECT ( account_page ), "bet_finance_capital" );
+    tmp_str = gsb_real_get_string_with_currency (
+                        gsb_real_double_to_real ( s_amortissement -> capital_du ),
+                        s_amortissement -> devise, TRUE );
+    gtk_label_set_label ( GTK_LABEL ( label ), tmp_str );
+    g_free ( tmp_str );
+
+    /* set taux */
+    label = g_object_get_data ( G_OBJECT ( account_page ), "bet_finance_taux" );
+    taux = gsb_data_account_get_bet_finance_taux_annuel ( account_number );
+    type_taux = gsb_data_account_get_bet_finance_type_taux ( account_number );
+    taux_periodique = bet_data_finance_get_taux_periodique ( taux, type_taux );
+    tmp_str = utils_str_dtostr ( taux, 2, FALSE );
+    gtk_label_set_label ( GTK_LABEL ( label ), tmp_str );
+    g_free ( tmp_str );
+
+    /* set duration */
+    label = g_object_get_data ( G_OBJECT ( account_page ), "bet_finance_duree" );
+    nbre_ans = gsb_data_account_get_bet_months ( account_number ) / 12;
+    if ( nbre_ans == 1 )
+        tmp_str_2 = g_strdup ( _(" year ") );
+    else
+        tmp_str_2 = g_strdup ( _(" years ") );
+    tmp_str = g_strconcat ( utils_str_itoa ( nbre_ans ), tmp_str_2, NULL );
+    gtk_label_set_label ( GTK_LABEL ( label ), tmp_str );
+    g_free ( tmp_str );
+    g_free ( tmp_str_2 );
+
+    /* set frais */
+    s_amortissement -> frais = gsb_data_account_get_bet_finance_frais ( account_number );
+    s_amortissement -> str_frais = gsb_real_get_string_with_currency (
+                        gsb_real_double_to_real ( s_amortissement -> frais ),
+                        s_amortissement -> devise, TRUE );
+
+    /* remplit le tableau d'amortissement */
+    tree_view = g_object_get_data ( G_OBJECT ( account_page ), "bet_finance_tree_view" );
+    store = gtk_tree_view_get_model ( GTK_TREE_VIEW ( tree_view ) );
+    gtk_tree_store_clear ( GTK_TREE_STORE ( store ) );
+
+    /* set echeance */
+    s_amortissement -> echeance = bet_data_finance_get_echeance ( s_amortissement -> capital_du,
+                        taux_periodique, nbre_echeances );
+    s_amortissement -> echeance += s_amortissement -> frais;
+    s_amortissement -> str_echeance = gsb_real_get_string_with_currency (
+                        gsb_real_double_to_real ( s_amortissement -> echeance ),
+                        s_amortissement -> devise, TRUE );
+
+    for ( index = 1; index <= nbre_echeances; index++ )
+    {
+        s_amortissement -> interets = bet_data_finance_get_interets ( s_amortissement -> capital_du,
+                        taux_periodique );
+
+        if ( index == nbre_echeances )
+        {
+            s_amortissement -> echeance = bet_data_finance_get_last_echeance (
+                        s_amortissement -> capital_du,
+                        s_amortissement -> interets,
+                        s_amortissement -> frais );
+            g_free ( s_amortissement -> str_echeance );
+            s_amortissement -> str_echeance = gsb_real_get_string_with_currency (
+                        gsb_real_double_to_real ( s_amortissement -> echeance ),
+                        s_amortissement ->  devise, TRUE );
+            s_amortissement -> principal = s_amortissement -> capital_du;
+        }
+        else
+            s_amortissement -> principal = bet_data_finance_get_principal (
+                        s_amortissement -> echeance,
+                        s_amortissement -> interets,
+                        s_amortissement -> frais );
+
+        if ( g_date_compare ( date, last_paid_date ) >= 0 )
+            bet_finance_fill_amortization_ligne ( store, s_amortissement );
+        date = gsb_date_add_one_month ( date, TRUE );
+        s_amortissement -> str_date = gsb_format_gdate ( date );
+        s_amortissement -> capital_du -= s_amortissement -> principal;
+    }
+
+    bet_finance_ui_struct_amortization_free ( s_amortissement );
+    g_date_free ( date );
+    g_date_free ( last_paid_date );
+
+    bet_finance_list_set_background_color ( tree_view, BET_AMORTIZATION_BACKGROUND_COLOR );
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+void bet_finance_ui_struct_amortization_free ( struct_amortissement *s_amortissement )
+{
+    if ( s_amortissement -> str_date )
+        g_free ( s_amortissement -> str_date );
+    if ( s_amortissement -> str_echeance )
+        g_free ( s_amortissement -> str_echeance );
+    if ( s_amortissement -> str_frais )
+        g_free ( s_amortissement -> str_frais );
+
+    g_free ( s_amortissement );
+}
+
+
+/**
  *
  *
  *
diff --git a/src/bet_finance_ui.h b/src/bet_finance_ui.h
index 0ddaaf4..9e0c592 100644
--- a/src/bet_finance_ui.h
+++ b/src/bet_finance_ui.h
@@ -9,8 +9,11 @@
 
 
 /* START_DECLARATION */
+GtkWidget *bet_finance_create_account_page ( void );
 GtkWidget *bet_finance_create_page ( void );
+gdouble bet_finance_get_number_from_string ( GtkWidget *parent, const gchar *name );
 void bet_finance_switch_simulator_page ( void );
+void bet_finance_ui_update_amortization_tab ( gint account_number );
 /* END_DECLARATION */
 
 
diff --git a/src/fenetre_principale.c b/src/fenetre_principale.c
index 47afbd4..0c13d67 100644
--- a/src/fenetre_principale.c
+++ b/src/fenetre_principale.c
@@ -25,13 +25,14 @@
 
 /*START_INCLUDE*/
 #include "fenetre_principale.h"
-#include "bet_tab.h"
+#include "accueil.h"
 #include "bet_data.h"
+#include "bet_data_finance.h"
 #include "bet_finance_ui.h"
 #include "bet_hist.h"
+#include "bet_tab.h"
 #include "navigation.h"
 #include "gsb_transactions_list.h"
-#include "accueil.h"
 #include "etats_onglet.h"
 #include "gsb_data_account.h"
 #include "gsb_account_property.h"
@@ -220,11 +221,11 @@ gboolean gsb_gui_fill_main_notebook ( GtkWidget *notebook )
 {
     /* append the main page */
     gtk_notebook_append_page ( GTK_NOTEBOOK ( notebook ),
-			       creation_onglet_accueil(),
-			       gtk_label_new (SPACIFY(_("Main page"))) );
+                        creation_onglet_accueil(),
+                        gtk_label_new (SPACIFY(_("Main page"))) );
 
     /* append the account page : a notebook with the account configuration
-     * and the transactions page */
+     * the bet pages and transactions page */
     account_page = gtk_notebook_new ();
     gtk_notebook_set_show_border ( GTK_NOTEBOOK(account_page), FALSE );
     gtk_widget_show ( account_page );
@@ -237,7 +238,7 @@ gboolean gsb_gui_fill_main_notebook ( GtkWidget *notebook )
                         creation_fenetre_operations (),
                         gtk_label_new (SPACIFY(_("Transactions"))) );
 
-     /* append the balance estimate pages */
+    /* append the balance estimate pages */
     gtk_notebook_append_page ( GTK_NOTEBOOK ( account_page ),
                         bet_array_create_page ( ),
                         gtk_label_new (SPACIFY(_("Forecast"))) );
@@ -246,6 +247,11 @@ gboolean gsb_gui_fill_main_notebook ( GtkWidget *notebook )
                         bet_historical_create_page ( ),
                         gtk_label_new (SPACIFY(_("Historical data"))) );
 
+    /* append the amortization page */
+    gtk_notebook_append_page ( GTK_NOTEBOOK ( account_page ),
+                        bet_finance_create_account_page ( ),
+                        gtk_label_new ( SPACIFY ( _("Amortization array") ) ) );
+
     gtk_notebook_append_page ( GTK_NOTEBOOK ( account_page ),
                         gsb_account_property_create_page (),
                         gtk_label_new (SPACIFY(_("Properties"))) );
@@ -257,14 +263,13 @@ gboolean gsb_gui_fill_main_notebook ( GtkWidget *notebook )
 
     /* append the scheduled transactions page */
     gtk_notebook_append_page ( GTK_NOTEBOOK ( notebook ),
-			       gsb_scheduler_list_create_list (),
-			       gtk_label_new (SPACIFY(_("Scheduler"))) );
+                        gsb_scheduler_list_create_list (),
+                        gtk_label_new (SPACIFY(_("Scheduler"))) );
 
     /* append the payee page */
     gtk_notebook_append_page ( GTK_NOTEBOOK ( notebook ),
-			       onglet_tiers (),
-			       gtk_label_new (SPACIFY(_("Payee"))) );
-
+                        onglet_tiers (),
+                        gtk_label_new (SPACIFY(_("Payee"))) );
 
     /* append the financial page */
     gtk_notebook_append_page ( GTK_NOTEBOOK ( notebook ),
@@ -273,18 +278,18 @@ gboolean gsb_gui_fill_main_notebook ( GtkWidget *notebook )
 
     /* append the categories page */
     gtk_notebook_append_page ( GTK_NOTEBOOK ( notebook ),
-			       onglet_categories (),
-			       gtk_label_new (SPACIFY(_("Categories"))) );
+                        onglet_categories (),
+                        gtk_label_new (SPACIFY(_("Categories"))) );
 
     /* append the budget page */
     gtk_notebook_append_page ( GTK_NOTEBOOK ( notebook ),
-			       onglet_imputations(),
-			       gtk_label_new (SPACIFY(_("Budgetary lines"))) );
+                        onglet_imputations(),
+                        gtk_label_new (SPACIFY(_("Budgetary lines"))) );
 
     /* append the reports page */
     gtk_notebook_append_page ( GTK_NOTEBOOK ( notebook ),
-			       creation_onglet_etats (),
-			       gtk_label_new (SPACIFY(_("Reports"))) );
+                        creation_onglet_etats (),
+                        gtk_label_new (SPACIFY(_("Reports"))) );
 
     return FALSE;
 }
@@ -327,6 +332,10 @@ gboolean gsb_gui_on_account_switch_page ( GtkNotebook *notebook,
             bet_data_update_bet_module ( account_number, GSB_HISTORICAL_PAGE );
         bet_historical_set_page_title ( account_number );
         break;
+    case GSB_FINANCE_PAGE:
+        gsb_form_set_expander_visible (FALSE, FALSE );
+        account_number = gsb_gui_navigation_get_current_account ( );
+        bet_finance_ui_update_amortization_tab ( account_number );
     case GSB_PROPERTIES_PAGE:
         gsb_form_set_expander_visible (FALSE, FALSE );
         break;
diff --git a/src/fenetre_principale.h b/src/fenetre_principale.h
index 38963dd..efecee6 100644
--- a/src/fenetre_principale.h
+++ b/src/fenetre_principale.h
@@ -18,7 +18,7 @@ typedef enum GSB_ACCOUNT_NOTEBOOK_PAGES {
     GSB_TRANSACTIONS_PAGE,
     GSB_ESTIMATE_PAGE,
     GSB_HISTORICAL_PAGE,
-    //~ GSB_FINANCIAL_PAGE,
+    GSB_FINANCE_PAGE,
     GSB_PROPERTIES_PAGE,
 } GsbaccountNotebookPages;
 
diff --git a/src/gsb_data_account.c b/src/gsb_data_account.c
index 2ea80c0..a8e4868 100644
--- a/src/gsb_data_account.c
+++ b/src/gsb_data_account.c
@@ -31,24 +31,21 @@
 
 /*START_INCLUDE*/
 #include "gsb_data_account.h"
+#include "custom_list.h"
 #include "dialog.h"
-#include "utils_dates.h"
+#include "fenetre_principale.h"
 #include "gsb_data_currency.h"
 #include "gsb_data_form.h"
 #include "gsb_data_transaction.h"
-#include "fenetre_principale.h"
-#include "navigation.h"
-#include "gsb_real.h"
 #include "gsb_select_icon.h"
-#include "traitement_variables.h"
-#include "utils_str.h"
-#include "custom_list.h"
 #include "gsb_transactions_list.h"
-#include "gsb_data_transaction.h"
-#include "structures.h"
 #include "include.h"
+#include "navigation.h"
+#include "structures.h"
+#include "traitement_variables.h"
+#include "utils_dates.h"
+#include "utils_str.h"
 #include "erreur.h"
-#include "gsb_real.h"
 /*END_INCLUDE*/
 
 /** \struct
@@ -120,10 +117,10 @@ typedef struct
     gpointer 	form_organization;
 
     /** @name bet data */
-    gint bet_use_budget;            /* 1 = use the budget module */
+    gint bet_use_budget;                /* 1 = use the budget module */
     GDate *bet_start_date;              /* date de début */
-    gint bet_spin_range;                /* echelle de la période 0 = mois 1 = années */
     gint bet_months;                    /* nombre de mois ou d'années */
+    gint bet_spin_range;                /* echelle de la période 0 = mois 1 = années */
     gint bet_auto_inc_month;            /* incrémente automatiquement le mois */
     gint bet_select_transaction_label;  /* fixe le label pour les opérations */
     gint bet_select_scheduled_label;    /* fixe le label pour les opérations planifiées */
@@ -131,6 +128,10 @@ typedef struct
     gint bet_hist_data;                 /* origine des données 0 = catégories 1 = IB */
     gint bet_hist_fyear;                /* numéro d'exercice */
     gint bet_maj;                       /* MAJ du module estiamte balance */
+    gdouble bet_capital;                /* capital emprunté */
+    gdouble bet_taux_annuel;            /* taux d'interet annuel */
+    gdouble bet_frais;                  /* frais par echeance */
+    gint bet_type_taux;                 /* type de taux : actuariel ou proportionnel */
 } struct_account;
 
 
@@ -459,7 +460,7 @@ gint gsb_data_account_get_no_account ( gpointer account_ptr )
  * \return the new number, or -1 if failed
  * */
 gint gsb_data_account_set_account_number ( gint account_number,
-					   gint new_no )
+                        gint new_no )
 {
     struct_account *account;
 
@@ -888,7 +889,7 @@ gsb_real gsb_data_account_get_init_balance ( gint account_number,
  * \return TRUE, ok ; FALSE, problem
  * */
 gboolean gsb_data_account_set_init_balance ( gint account_number,
-					     gsb_real balance )
+                        gsb_real balance )
 {
     struct_account *account;
 
@@ -1310,7 +1311,7 @@ gint gsb_data_account_get_current_transaction_number ( gint account_number )
  * \return TRUE, ok ; FALSE, problem
  * */
 gboolean gsb_data_account_set_current_transaction_number ( gint account_number,
-							   gint transaction_number )
+                        gint transaction_number )
 {
     struct_account *account;
 
@@ -2904,7 +2905,7 @@ GDate *gsb_data_account_get_bet_start_date ( gint account_number )
     account = gsb_data_account_get_structure ( account_number );
 
     if (!account )
-	    return 0;
+        return 0;
 
     date = account -> bet_start_date;
 
@@ -3003,7 +3004,7 @@ gint gsb_data_account_get_bet_months ( gint account_number )
     account = gsb_data_account_get_structure ( account_number );
 
     if (!account )
-	    return 0;
+        return 0;
 
     if ( account -> bet_months == 0 )
         return 1;
@@ -3020,11 +3021,11 @@ gint gsb_data_account_get_bet_months ( gint account_number )
 gboolean gsb_data_account_set_bet_months ( gint account_number, gint months )
 {
     struct_account *account;
-
+devel_debug_int ( months );
     account = gsb_data_account_get_structure ( account_number );
 
     if (!account )
-	    return FALSE;
+        return FALSE;
 
     account -> bet_months = months;
 
@@ -3256,7 +3257,7 @@ gint gsb_data_account_get_bet_use_budget ( gint account_number )
     account = gsb_data_account_get_structure ( account_number );
 
     if (!account )
-	    return 0;
+        return 0;
 
     kind = account -> account_kind;
 
@@ -3264,10 +3265,8 @@ gint gsb_data_account_get_bet_use_budget ( gint account_number )
     {
         case GSB_TYPE_BANK:
         case GSB_TYPE_CASH:
-            return account -> bet_use_budget;
-            break;
         case GSB_TYPE_LIABILITIES:
-            return -1;
+            return account -> bet_use_budget;
             break;
         case GSB_TYPE_ASSET:
             return -1;
@@ -3313,7 +3312,7 @@ gint gsb_data_account_get_bet_maj ( gint account_number )
     account = gsb_data_account_get_structure ( account_number );
 
     if (!account )
-	    return 0;
+        return 0;
 
     return account -> bet_maj;
 }
@@ -3332,7 +3331,7 @@ gboolean gsb_data_account_set_bet_maj ( gint account_number, gint type_maj )
     account = gsb_data_account_get_structure ( account_number );
 
     if ( !account )
-	    return FALSE;
+        return FALSE;
 
     account -> bet_maj = type_maj;
 
@@ -3340,6 +3339,170 @@ gboolean gsb_data_account_set_bet_maj ( gint account_number, gint type_maj )
 }
 
 
+/**
+ *
+ *
+ *
+ *
+ * */
+gdouble gsb_data_account_get_bet_finance_capital ( gint account_number )
+{
+    struct_account *account;
+
+    account = gsb_data_account_get_structure ( account_number );
+
+    if (!account )
+        return 0;
+
+    return account -> bet_capital;
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+gboolean gsb_data_account_set_bet_finance_capital ( gint account_number, gdouble capital )
+{
+    struct_account *account;
+
+    account = gsb_data_account_get_structure ( account_number );
+
+    if ( !account )
+        return FALSE;
+
+    account -> bet_capital = capital;
+
+    return TRUE;
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+gdouble gsb_data_account_get_bet_finance_taux_annuel ( gint account_number )
+{
+    struct_account *account;
+
+    account = gsb_data_account_get_structure ( account_number );
+
+    if (!account )
+        return 0;
+
+    return account -> bet_taux_annuel;
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+gboolean gsb_data_account_set_bet_finance_taux_annuel ( gint account_number, gdouble taux_annuel )
+{
+    struct_account *account;
+
+    account = gsb_data_account_get_structure ( account_number );
+
+    if ( !account )
+        return FALSE;
+
+    account -> bet_taux_annuel = taux_annuel;
+
+    return TRUE;
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+gdouble gsb_data_account_get_bet_finance_frais ( gint account_number )
+{
+    struct_account *account;
+
+    account = gsb_data_account_get_structure ( account_number );
+
+    if (!account )
+        return 0;
+
+    return account -> bet_frais;
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+gboolean gsb_data_account_set_bet_finance_frais ( gint account_number, gdouble frais )
+{
+    struct_account *account;
+
+    account = gsb_data_account_get_structure ( account_number );
+
+    if ( !account )
+        return FALSE;
+
+    account -> bet_frais = frais;
+
+    return TRUE;
+}
+
+
+/**
+ * 
+ *
+ *
+ * */
+gint gsb_data_account_get_bet_finance_type_taux ( gint account_number )
+{
+    struct_account *account;
+
+    account = gsb_data_account_get_structure ( account_number );
+
+    if (!account )
+        return 0;
+
+    return account -> bet_type_taux;
+}
+
+
+/**
+ * 
+ *
+ *
+ * */
+gboolean gsb_data_account_set_bet_finance_type_taux ( gint account_number, gint type_taux )
+{
+    struct_account *account;
+
+    account = gsb_data_account_get_structure ( account_number );
+
+    if (!account )
+        return FALSE;
+
+    account -> bet_type_taux = type_taux;
+
+    return TRUE;
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */
diff --git a/src/gsb_data_account.h b/src/gsb_data_account.h
index 4efb0e5..234f615 100644
--- a/src/gsb_data_account.h
+++ b/src/gsb_data_account.h
@@ -44,6 +44,10 @@ gchar *gsb_data_account_get_bank_account_key ( gint account_number );
 gchar *gsb_data_account_get_bank_account_number ( gint account_number );
 gchar *gsb_data_account_get_bank_branch_code ( gint account_number );
 gboolean gsb_data_account_get_bet_auto_inc_month ( gint account_number );
+gdouble gsb_data_account_get_bet_finance_capital ( gint account_number );
+gdouble gsb_data_account_get_bet_finance_frais ( gint account_number );
+gdouble gsb_data_account_get_bet_finance_taux_annuel ( gint account_number );
+gint gsb_data_account_get_bet_finance_type_taux ( gint account_number );
 gint gsb_data_account_get_bet_hist_data ( gint account_number );
 gint gsb_data_account_get_bet_hist_fyear ( gint account_number );
 gint gsb_data_account_get_bet_maj ( gint account_number );
@@ -95,7 +99,7 @@ gboolean gsb_data_account_reorder ( GSList *new_order );
 gboolean gsb_data_account_set_account_icon_pixbuf ( gint account_number,
                         GdkPixbuf * pixbuf );
 gint gsb_data_account_set_account_number ( gint account_number,
-					   gint new_no );
+                        gint new_no );
 gboolean gsb_data_account_set_balances_are_dirty ( gint account_number );
 gboolean gsb_data_account_set_bank ( gint account_number,
                         gint bank );
@@ -108,6 +112,10 @@ gboolean gsb_data_account_set_bank_branch_code ( gint account_number,
                         const gchar *bank_branch_code );
 gboolean gsb_data_account_set_bet_auto_inc_month ( gint account_number,
                         gboolean auto_inc_month );
+gboolean gsb_data_account_set_bet_finance_capital ( gint account_number, gdouble capital );
+gboolean gsb_data_account_set_bet_finance_frais ( gint account_number, gdouble frais );
+gboolean gsb_data_account_set_bet_finance_taux_annuel ( gint account_number, gdouble taux_annuel );
+gboolean gsb_data_account_set_bet_finance_type_taux ( gint account_number, gint type_taux );
 gboolean gsb_data_account_set_bet_hist_data ( gint account_number, gint hist_data );
 gboolean gsb_data_account_set_bet_hist_fyear ( gint account_number, gint hist_fyear );
 gboolean gsb_data_account_set_bet_maj ( gint account_number, gint type_maj );
@@ -125,7 +133,7 @@ gboolean gsb_data_account_set_comment ( gint account_number,
 gboolean gsb_data_account_set_currency ( gint account_number,
                         gint currency );
 gboolean gsb_data_account_set_current_transaction_number ( gint account_number,
-							   gint transaction_number );
+                        gint transaction_number );
 gboolean gsb_data_account_set_default_credit ( gint account_number,
                         gint default_credit );
 gboolean gsb_data_account_set_default_debit ( gint account_number,
@@ -142,7 +150,7 @@ gboolean gsb_data_account_s
et_holder_name ( gint account_number,
 gboolean gsb_data_account_set_id ( gint account_number,
                         const gchar *id );
 gboolean gsb_data_account_set_init_balance ( gint account_number,
-					     gsb_real balance );
+                        gsb_real balance );
 gboolean gsb_data_account_set_kind ( gint account_number,
                         kind_account account_kind );
 gboolean gsb_data_account_set_l ( gint account_number,
diff --git a/src/gsb_file_load.c b/src/gsb_file_load.c
index 58a9cba..eeaf2a9 100644
--- a/src/gsb_file_load.c
+++ b/src/gsb_file_load.c
@@ -1904,6 +1904,38 @@ void gsb_file_load_account_part ( const gchar **attribute_names,
         continue;
     }
 
+    if ( !strcmp ( attribute_names[i], "Bet_capital" ))
+    {
+        gsb_data_account_set_bet_finance_capital ( account_number,
+                        g_ascii_strtod ( attribute_values[i], NULL ) );
+        i++;
+        continue;
+    }
+
+    if ( !strcmp ( attribute_names[i], "Bet_taux_annuel" ))
+    {
+        gsb_data_account_set_bet_finance_taux_annuel ( account_number,
+                        g_ascii_strtod ( attribute_values[i], NULL ) );
+        i++;
+        continue;
+    }
+
+    if ( !strcmp ( attribute_names[i], "Bet_frais" ))
+    {
+        gsb_data_account_set_bet_finance_frais ( account_number,
+                        g_ascii_strtod ( attribute_values[i], NULL ) );
+        i++;
+        continue;
+    }
+
+    if ( !strcmp ( attribute_names[i], "Bet_type_taux" ))
+    {
+        gsb_data_account_set_bet_finance_type_taux ( account_number,
+                        g_ascii_strtod ( attribute_values[i], NULL ) );
+        i++;
+        continue;
+    }
+
     /* normally, shouldn't come here */
     i++;
     }
diff --git a/src/gsb_file_save.c b/src/gsb_file_save.c
index 6d1a71c..8ca53c6 100644
--- a/src/gsb_file_save.c
+++ b/src/gsb_file_save.c
@@ -952,6 +952,8 @@ gulong gsb_file_save_account_part ( gulong iterator,
 	gchar *mini_auto;
     gchar **owner_tab;
     gchar *owner_str;
+    gchar *bet_str;
+    kind_account kind;
 
 	account_number = gsb_data_account_get_no_account ( list_tmp -> data );
 
@@ -1055,6 +1057,8 @@ gulong gsb_file_save_account_part ( gulong iterator,
         g_strfreev ( owner_tab );
     }
 
+    kind = gsb_data_account_get_kind ( account_number );
+
     /* now we can fill the file content */
 	new_string = g_markup_printf_escaped ( "\t<Account\n"
  					       "\t\tName=\"%s\"\n"
@@ -1090,21 +1094,12 @@ gulong gsb_file_save_account_part ( gulong iterator,
 					       "\t\tForm_lines_number=\"%d\"\n"
 					       "\t\tForm_organization=\"%s\"\n"
 					       "\t\tForm_columns_width=\"%s\"\n"
-                           "\t\tBet_use_budget=\"%d\"\n"
-                           "\t\tBet_start_date=\"%s\"\n"
-                           "\t\tBet_months=\"%d\"\n"
-                           "\t\tBet_UT=\"%d\"\n"
-                           "\t\tBet_auto_inc_month=\"%d\"\n"
-                           "\t\tBet_select_transaction_label=\"%d\"\n" 
-                           "\t\tBet_select_scheduled_label=\"%d\"\n" 
-                           "\t\tBet_select_futur_label=\"%d\"\n"
-                           "\t\tBet_SD=\"%d\"\n" 
-                           "\t\tBet_Fi=\"%d\" />\n",
+                           "\t\tBet_use_budget=\"%d\"",
 	    my_safe_null_str(gsb_data_account_get_name (account_number)),
 	    my_safe_null_str(gsb_data_account_get_id (account_number)),
 	    account_number,
 	    my_safe_null_str(gsb_data_account_get_holder_name (account_number)),
-	    gsb_data_account_get_kind (account_number),
+	    kind,
 	    gsb_data_account_get_currency (account_number),
 	    my_safe_null_str(gsb_data_account_get_name_icon (account_number)),
 	    gsb_data_account_get_bank (account_number),
@@ -1133,17 +1128,57 @@ gulong gsb_file_save_account_part ( gulong iterator,
 	    gsb_data_form_get_nb_rows (account_number),
 	    my_safe_null_str(form_organization),
 	    my_safe_null_str(form_columns_width),
-        gsb_data_account_get_bet_use_budget ( account_number ),
-        my_safe_null_str ( gsb_format_gdate_safe (
+        gsb_data_account_get_bet_use_budget ( account_number ) );
+
+    switch ( kind )
+    {
+        case GSB_TYPE_LIABILITIES:
+            bet_str = g_markup_printf_escaped ( "\t\tBet_start_date=\"%s\"\n"
+                        "\t\tBet_months=\"%d\"\n"
+                        "\t\tBet_capital=\"%s\"\n"
+                        "\t\tBet_taux_annuel=\"%s\"\n"
+                        "\t\tBet_frais=\"%s\"\n"
+                        "\t\tBet_type_taux=\"%d\" />\n",
+                my_safe_null_str ( gsb_format_gdate_safe (
                         gsb_data_account_get_bet_start_date ( account_number ) ) ),
-        gsb_data_account_get_bet_months ( account_number ),
-        gsb_data_account_get_bet_spin_range ( account_number ),
-        gsb_data_account_get_bet_auto_inc_month ( account_number ),
-        gsb_data_account_get_bet_select_label ( account_number, SPP_ORIGIN_TRANSACTION ),
-        gsb_data_account_get_bet_select_label ( account_number, SPP_ORIGIN_SCHEDULED ),
-        gsb_data_account_get_bet_select_label ( account_number, SPP_ORIGIN_FUTURE ),
-        gsb_data_account_get_bet_hist_data ( account_number ),
-        gsb_data_account_get_bet_hist_fyear ( account_number ) );
+                gsb_data_account_get_bet_months ( account_number ),
+                my_safe_null_str ( utils_str_dtostr (
+                        gsb_data_account_get_bet_finance_capital ( account_number ), 2, TRUE ) ),
+                my_safe_null_str ( utils_str_dtostr (
+                        gsb_data_account_get_bet_finance_taux_annuel ( account_number ), 2, TRUE ) ),
+                my_safe_null_str ( utils_str_dtostr (
+                        gsb_data_account_get_bet_finance_frais ( account_number ), 2, TRUE ) ),
+                gsb_data_account_get_bet_finance_type_taux ( account_number ) );
+            new_string = g_strconcat ( new_string, "\n", bet_str, NULL );
+            g_free ( bet_str );
+            break;
+        case GSB_TYPE_ASSET:
+            new_string = g_strconcat ( new_string, " />\n",NULL );
+            break;
+        default:
+            bet_str = g_markup_printf_escaped ( "\t\tBet_start_date=\"%s\"\n"
+                        "\t\tBet_months=\"%d\"\n"
+                        "\t\tBet_UT=\"%d\"\n"
+                        "\t\tBet_auto_inc_month=\"%d\"\n"
+                        "\t\tBet_select_transaction_label=\"%d\"\n" 
+                        "\t\tBet_select_scheduled_label=\"%d\"\n" 
+                        "\t\tBet_select_futur_label=\"%d\"\n"
+                        "\t\tBet_SD=\"%d\"\n" 
+                        "\t\tBet_Fi=\"%d\" />\n",
+            my_safe_null_str ( gsb_format_gdate_safe (
+                        gsb_data_account_get_bet_start_date ( account_number ) ) ),
+            gsb_data_account_get_bet_months ( account_number ),
+            gsb_data_account_get_bet_spin_range ( account_number ),
+            gsb_data_account_get_bet_auto_inc_month ( account_number ),
+            gsb_data_account_get_bet_select_label ( account_number, SPP_ORIGIN_TRANSACTION ),
+            gsb_data_account_get_bet_select_label ( account_number, SPP_ORIGIN_SCHEDULED ),
+            gsb_data_account_get_bet_select_label ( account_number, SPP_ORIGIN_FUTURE ),
+            gsb_data_account_get_bet_hist_data ( account_number ),
+            gsb_data_account_get_bet_hist_fyear ( account_number ) );
+            new_string = g_strconcat ( new_string, "\n", bet_str, NULL );
+            g_free ( bet_str );
+            break;
+    }
 
 	g_free (sort_list);
 	g_free (sort_kind_column);
diff --git a/src/gsb_real.c b/src/gsb_real.c
index 7c75198..891429c 100644
--- a/src/gsb_real.c
+++ b/src/gsb_real.c
@@ -1127,6 +1127,22 @@ gchar *gsb_real_save_real_to_string ( gsb_real number, gint default_exponent )
 }
 
 
+gdouble gsb_real_real_to_double ( gsb_real number )
+{
+    gdouble result;
+
+    result = number.mantissa;
+
+    while ( number.exponent > 0 )
+    {
+        result /= 10;
+        number.exponent--;
+    }
+
+    return result;
+}
+
+
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */
diff --git a/src/gsb_real.h b/src/gsb_real.h
index 8849733..bbbf314 100644
--- a/src/gsb_real.h
+++ b/src/gsb_real.h
@@ -46,6 +46,7 @@ gchar *gsb_real_raw_format_string (gsb_real number,
 gsb_real gsb_real_raw_get_from_string ( const gchar *string,
                                         const gchar *mon_thousands_sep,
                                         const gchar *mon_decimal_point );
+gdouble gsb_real_real_to_double ( gsb_real number );
 gchar *gsb_real_save_real_to_string ( gsb_real number, gint default_exponent );
 gsb_real gsb_real_sub ( gsb_real number_1,
                         gsb_real number_2 );
diff --git a/src/navigation.c b/src/navigation.c
index d570322..e79fc22 100644
--- a/src/navigation.c
+++ b/src/navigation.c
@@ -290,7 +290,7 @@ GtkWidget * create_navigation_pane ( void )
 		       NAVIGATION_SENSITIVE, 1,
 		       -1 );
 
-    /* Balance estimate */
+    /* Credits simulator */
     tmpstr = g_build_filename( PIXMAPS_DIR, "ac_liability.png", NULL );
     pixbuf = gdk_pixbuf_new_from_file ( tmpstr , NULL );
     g_free ( tmpstr );
diff --git a/src/structures.h b/src/structures.h
index 0641f90..a558a0b 100644
--- a/src/structures.h
+++ b/src/structures.h
@@ -205,7 +205,8 @@ enum bet_array_origin_data
     SPP_ORIGIN_FUTURE,
     SPP_ORIGIN_ACCOUNT,
     SPP_ORIGIN_ARRAY,
-    SPP_ORIGIN_CONFIG
+    SPP_ORIGIN_CONFIG,
+    SPP_ORIGIN_FINANCE
 };
 
 enum bet_type_maj 
diff --git a/src/utils_dates.c b/src/utils_dates.c
index 961353a..3128be8 100644
--- a/src/utils_dates.c
+++ b/src/utils_dates.c
@@ -145,6 +145,29 @@ GDate *gsb_date_tomorrow ( void )
 }
 
 
+/**
+ * adds one month to a date
+ *
+ * \param date
+ * \param free the init date
+ *
+ * \return a newly allocated GDate which represents the date of the day. 
+ * Use g_date_free to free memory when no more used.
+ * */
+GDate *gsb_date_add_one_month ( GDate *date, gboolean free )
+{
+    GDate *new_date;
+
+    new_date = gsb_date_copy ( date );
+    g_date_add_months ( new_date, 1);
+
+    if ( free )
+        g_date_free ( date );
+
+    return ( new_date );
+}
+
+
 
 /**
  * copy the date given in param
diff --git a/src/utils_dates.h b/src/utils_dates.h
index a53fa14..98f2175 100644
--- a/src/utils_dates.h
+++ b/src/utils_dates.h
@@ -6,6 +6,7 @@
 
 /* START_DECLARATION */
 GDate *gdate_today ( void );
+GDate *gsb_date_add_one_month ( GDate *date, gboolean free );
 gboolean gsb_date_check_and_complete_entry ( GtkWidget *entry,
                         gboolean set_today );
 gboolean gsb_date_check_entry ( GtkWidget *entry );
diff --git a/src/utils_str.c b/src/utils_str.c
index b91b9c8..1277615 100644
--- a/src/utils_str.c
+++ b/src/utils_str.c
@@ -247,7 +247,7 @@ G_MODULE_EXPORT gint utils_str_atoi ( const gchar *chaine )
  * Convertie une chaine de caractères en un nombre
  * Paramètres d'entrée :
  *   - nptr : pointeur sur la chaine de caractères à convertir
- *   - endptr : n'est pas utilisé, alors à quoi peut-il bien servir ?
+ *   - endptr : renvoie le reste de la chaine après le dernier caractère utilisé dans la conversion
  * Valeur de retour :
  *   - resultat : le résultat de la conversion
  * Variables locales :
@@ -256,58 +256,82 @@ G_MODULE_EXPORT gint utils_str_atoi ( const gchar *chaine )
  *   - invert : le signe du résultat (0 -> positif, 1 -> négatif)
  *   - p, m : pointeurs locaux sur la chaine de caractères à convertir
  * */
-double my_strtod ( const char *nptr, const char **endptr )
+double my_strtod ( const gchar *nptr, gchar **endptr )
 {
-    double entier=0, mantisse=0, resultat=0;
-    int invert = 0;
-    const char * p;
+    double entier= 0, mantisse = 0, resultat = 0;
+    gint invert = 0;
+    const gchar *p;
 
-    if (!nptr)
-	return 0;
+    if ( !nptr )
+        return 0;
 
-
-    for ( p = nptr; p < nptr + strlen(nptr); p++ )
+    for ( p = nptr; p < nptr + strlen ( nptr ); p++ )
     {
-	if (g_ascii_isspace(*p) || *p == '+' )
-	    continue;
+        if ( g_ascii_isspace ( *p ) || *p == '+' )
+            continue;
 
-	if (*p == '-')
-	{
-	    invert = 1;
-	    continue;
-	}
+        if ( *p == '-' )
+        {
+            invert = 1;
+            continue;
+        }
 
-	if ( *p == ',' || *p == '.' )
-	{
-	    const char * m;
-	    for ( m = p+1; m <= nptr+strlen(nptr) && 
-		  (g_ascii_isdigit(*m) || g_ascii_isspace(*m)); m++)
-		/* Nothing, just loop */ ;
-	    for ( --m; m > p; m-- )
-	    {
-		if (isdigit(*m))
-		{
-		    mantisse /= 10;
-		    mantisse += (*m - '0');
-		}
-	    }
-	    mantisse /= 10;
-	}
+        /* on traite ici la partie décimale */
+        if ( *p == ',' || *p == '.' )
+        {
+            const gchar *m;
+
+            for ( m = p + 1; m <= nptr + strlen ( nptr ) &&
+             ( g_ascii_isdigit ( *m ) || g_ascii_isspace ( *m ) ); m++ )
+                /* Nothing, just loop pour atteindre la fin de la chaine ou le dernier
+                 * caractère utilisable */
+                ;
+
+            if ( strlen ( m ) > 0 )
+            {
+                gchar *tmp_str = NULL;
+                gchar *tmp_str_2 = NULL;
+                const gchar *ptr;
+
+                for ( ptr = m; ptr < m + strlen ( m ); ptr++ )
+                {
+                    tmp_str = g_strndup ( ptr, 1 );
+                    if ( tmp_str_2 == NULL )
+                        tmp_str_2 = g_strconcat ( tmp_str, "|", NULL );
+                    else
+                        tmp_str_2 = g_strconcat ( tmp_str_2, tmp_str, "|", NULL );
+                    g_free ( tmp_str );
+                }
+                endptr = g_strsplit ( tmp_str_2, "|", strlen ( m ) );
+                g_free ( tmp_str_2 );
+            }
+
+            for ( --m; m > p; m-- )
+            {
+                if ( isdigit ( *m ) )
+                {
+                    mantisse /= 10;
+                    mantisse += ( *m - '0' );
+                }
+            }
+            mantisse /= 10;
+        }
 
-	if (isdigit(*p))
-	{
-	    entier = entier * 10;
-	    entier += (*p - '0');
-	}
-	else
-	{
-	    break;
-	}
+        /* on traite ici la partie entière */
+        if ( isdigit ( *p ) )
+        {
+            entier = entier * 10;
+            entier += ( *p - '0' );
+        }
+        else
+        {
+            break;
+        }
     }
 
     resultat = entier + mantisse;
     if ( invert )
-	resultat = - resultat;
+        resultat = - resultat;
 
     return resultat;
 }
@@ -933,6 +957,34 @@ gchar *gsb_string_uniform_new_line ( const gchar *chaine, gint nbre_char )
 }
 
 
+/**
+ *
+ *
+ *
+ *
+ * */
+gchar *utils_str_dtostr ( gdouble number, gint nbre_decimal, gboolean canonical )
+{
+    gchar buffer[G_ASCII_DTOSTR_BUF_SIZE];
+    gchar *str_number;
+    gchar *format;
+    gint nbre_char;
+
+    format = g_strconcat ( "%.", utils_str_itoa ( nbre_decimal ), "f", NULL );
+
+    nbre_char = g_sprintf ( buffer, format, number );
+    if ( nbre_char > G_ASCII_DTOSTR_BUF_SIZE )
+        return NULL;
+
+    str_number = g_strndup ( buffer, nbre_char );
+
+    if ( canonical && g_strrstr ( str_number, "," ) )
+        str_number = my_strdelimit ( str_number, ",", "." );
+
+    return str_number;
+}
+
+
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */
diff --git a/src/utils_str.h b/src/utils_str.h
index 6c62c10..50bc524 100644
--- a/src/utils_str.h
+++ b/src/utils_str.h
@@ -36,9 +36,10 @@ G_MODULE_EXPORT gchar *my_strdup ( const gchar *string );
 gint my_strncasecmp ( gchar *string_1,
                         gchar *string_2,
                         gint longueur );
-double my_strtod ( const char *nptr, const char **endptr );
+double my_strtod ( const gchar *nptr, gchar **endptr );
 G_MODULE_EXPORT gint utils_str_atoi ( const gchar *chaine );
 gchar *utils_str_itoa ( gint integer );
+gchar *utils_str_dtostr ( gdouble number, gint nbre_decimal, gboolean canonical );
 gchar *utils_str_localise_decimal_point_from_string ( const gchar *string );
 gchar *utils_str_reduce_exponant_from_string ( const gchar *amount_string,
                         gint exponent );


hooks/post-receive
-- 
grisbi


More information about the cvs mailing list