[grisbi-cvs] grisbi/src balance_estimate_tab.c, 1.31, 1.32 gsb_form_scheduler.c, 1.36, 1.37 import.c, 1.319, 1.320 utils_dates.c, 1.63, 1.64 utils_files.c, 1.49, 1.50 utils_files.h, 1.25, 1.26
Pierre Biava
pbiava at users.sourceforge.net
Sat Jan 23 14:46:15 CET 2010
- Previous message: [grisbi-cvs] grisbi/src balance_estimate_tab.c, 1.30, 1.31 gsb_form_widget.c, 1.43, 1.44 gsb_transactions_list.c, 1.193, 1.194 import.c, 1.318, 1.319 transaction_list.c, 1.56, 1.57 transaction_list.h, 1.10, 1.11 transaction_model.c, 1.4, 1.5 utils_dates.c, 1.62, 1.63
- Next message: [grisbi-cvs] grisbi/src balance_estimate_tab.c, 1.32, 1.33 gsb_currency.c, 1.55, 1.56 gsb_file_load.c, 1.204, 1.205 gsb_form_widget.c, 1.44, 1.45 gsb_form_widget.h, 1.5, 1.6
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/grisbi/grisbi/src
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv19005/src
Modified Files:
balance_estimate_tab.c gsb_form_scheduler.c import.c
utils_dates.c utils_files.c utils_files.h
Log Message:
added charset detection of OFX files and added management of historical data in the budget module.
Index: utils_files.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/utils_files.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- utils_files.h 3 Jan 2010 11:21:26 -0000 1.25
+++ utils_files.h 23 Jan 2010 13:46:13 -0000 1.26
@@ -36,6 +36,7 @@
const gchar *tmp_str,
const gchar *charmap_imported,
gchar *filename );
+gchar *utils_files_get_ofx_charset ( gchar *contents );
/*END_DECLARATION*/
#endif
Index: import.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/import.c,v
retrieving revision 1.319
retrieving revision 1.320
diff -u -d -r1.319 -r1.320
--- import.c 21 Jan 2010 22:16:52 -0000 1.319
+++ import.c 23 Jan 2010 13:46:12 -0000 1.320
@@ -645,6 +645,7 @@
gchar *nom_fichier;
gchar *tmp_str;
gchar *contents;
+ gchar *charmap;
GError *error = NULL;
gchar * extension;
@@ -665,7 +666,7 @@
type = autodetect_file_type ( iterator -> data, tmp_str );
/* passe par un fichier temporaire pour bipasser le bug libofx */
- if ( ! strcmp ( type, "OFX" ) )
+ if ( strcmp ( type, "OFX" ) == 0 )
{
nom_fichier = g_strconcat (g_get_tmp_dir (),G_DIR_SEPARATOR_S,
g_path_get_basename ( iterator -> data ), NULL);
@@ -674,6 +675,12 @@
g_free ( tmp_str );
return FALSE;
}
+ if ( ( charmap = utils_files_get_ofx_charset ( tmp_str ) ) != NULL )
+ {
+ if ( charmap_imported )
+ g_free ( charmap_imported );
+ charmap_imported = charmap;
+ }
}
else
nom_fichier = my_strdup (iterator -> data);
@@ -686,8 +693,7 @@
gsb_assistant_set_prev ( assistant, IMPORT_RESUME_PAGE, IMPORT_CSV_PAGE );
}
- /* test conversion to UTF8 */
- /* Convert in UTF8 */
+ /* Convert to UTF8 */
contents = g_convert ( tmp_str, -1, "UTF-8", charmap_imported, NULL, NULL, NULL );
if ( contents == NULL )
Index: utils_dates.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/utils_dates.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- utils_dates.c 21 Jan 2010 22:16:52 -0000 1.63
+++ utils_dates.c 23 Jan 2010 13:46:13 -0000 1.64
@@ -626,6 +626,7 @@
tmp_date = gsb_date_copy ( date );
g_date_set_day ( tmp_date, 1 );
+ g_date_add_months ( tmp_date, 1 );
g_date_subtract_days ( tmp_date, 1 );
return tmp_date;
Index: balance_estimate_tab.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_tab.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- balance_estimate_tab.c 21 Jan 2010 22:16:52 -0000 1.31
+++ balance_estimate_tab.c 23 Jan 2010 13:46:12 -0000 1.32
@@ -79,13 +79,25 @@
/*START_STATIC*/
-static void bet_account_selection_changed (GtkTreeSelection *treeselection, gpointer user_data);
-static gint bet_date_sort_function (GtkTreeModel *model, GtkTreeIter *itera, GtkTreeIter *iterb, gpointer user_data);
+static void bet_account_selection_changed ( GtkTreeSelection *treeselection, gpointer user_data );
+static gint bet_date_sort_function ( GtkTreeModel *model,
+ GtkTreeIter *itera,
+ GtkTreeIter *iterb,
+ gpointer user_data );
static void bet_duration_button_clicked ( GtkWidget *togglebutton, GtkWidget *spin_button );
static void bet_historical_data_clicked ( GtkWidget *togglebutton, gpointer data );
-static void bet_estimate_refresh (void);
-static gboolean bet_update_average_column (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data);
-static gboolean bet_update_graph (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data);
+static void bet_estimate_refresh ( void );
+static void bet_estimate_refresh_historical_data ( GtkTreeModel *tab_model,
+ GDate *date_min,
+ GDate *date_max );
+static gboolean bet_update_average_column (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data);
+static gboolean bet_update_graph ( GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data );
static gint bet_date_sort_function (GtkTreeModel *model,
GtkTreeIter *a,
GtkTreeIter *b,
@@ -97,7 +109,7 @@
static GtkWidget *bet_estimate_get_list_accounts ( GtkWidget *container );
static GtkWidget *bet_estimate_get_duration_widget ( GtkWidget *container );
static gboolean bet_duration_number_changed ( GtkWidget *spin_button, GtkWidget *togglebutton );
-static void bet_duration_period_clicked ( GtkWidget *togglebutton, gpointer data );
+static void bet_duration_period_clicked ( GtkWidget *togglebutton, GtkWidget *button );
static GtkWidget *bet_estimate_get_historical_data ( GtkWidget *container );
static void bet_estimate_populate_historical_data ( void );
static gboolean bet_estimate_populate_div ( gint transaction_number,
@@ -109,6 +121,23 @@
gpointer user_data);
static gboolean bet_fyear_create_combobox_store ( void );
static gint bet_fyear_get_fyear_from_combobox ( GtkWidget *combo_box );
+static gint bet_estimate_get_account_selected ( void );
+static void bet_estimate_tab_add_new_line ( GtkTreeModel *tab_model,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ GDate *date_min,
+ GDate *date_max );
+static gboolean bet_historical_div_toggle_clicked ( GtkCellRendererToggle *renderer,
+ gchar *path_string,
+ GtkTreeModel *store );
+static void bet_historical_div_cell_editing_started ( GtkCellRenderer *cell,
+ GtkCellEditable *editable,
+ const gchar *path,
+ gpointer data );
+static void bet_historical_div_cell_edited (GtkCellRendererText *cell,
+ const gchar *path_string,
+ const gchar *new_text,
+ GtkWidget *tree_view );
static SBR *initialise_struct_bet_range ( void );
static SH *initialise_struct_historical ( void );
static void free_struct_bet_range ( SBR *sbr );
@@ -152,7 +181,7 @@
SPP_HISTORICAL_BALANCE_COLUMN,
SPP_HISTORICAL_AVERAGE_COLUMN,
SPP_HISTORICAL_RETAINED_COLUMN,
- SPP_HISTORICAL_AMOUNT_COLUMN, /* average column without currency */
+ SPP_HISTORICAL_RETAINED_AMOUNT, /* retenaid column without currency */
SPP_HISTORICAL_BALANCE_COLOR,
SPP_HISTORICAL_NUM_COLUMNS
};
@@ -329,12 +358,6 @@
GtkTreeIter *iter,
gpointer data )
{
- GtkWidget* dialog;
- GtkWidget *tree_view;
- GtkTreeModel *tree_model;
- GtkTreeIter iter_account;
- GtkTreeSelection* tree_selection;
- gchar *account_name;
gchar *str_balance = NULL;
gchar *tmp_str;
gchar *color_str = NULL;
@@ -348,26 +371,7 @@
return FALSE;
}
- /* find the selected account */
- tree_view = g_object_get_data ( G_OBJECT ( bet_container ), "bet_account_treeview" );
- tree_model = gtk_tree_view_get_model ( GTK_TREE_VIEW ( tree_view ) );
- tree_selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW ( tree_view ) );
- if ( !gtk_tree_selection_get_selected ( GTK_TREE_SELECTION ( tree_selection ),
- &tree_model, &iter_account ) )
- {
- dialog = gtk_message_dialog_new ( GTK_WINDOW ( window ),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- "Please, select an account in the list !\n" );
- gtk_dialog_run ( GTK_DIALOG ( dialog ) );
- gtk_widget_destroy ( GTK_WIDGET ( dialog ) );
- return FALSE;
- }
-
- account_name = NULL;
- gtk_tree_model_get ( tree_model, &iter_account, 0, &account_name, -1 );
- selected_account = gsb_data_account_get_no_account_by_name ( account_name );
+ selected_account = bet_estimate_get_account_selected ( );
if ( selected_account == -1 )
return FALSE;
@@ -393,11 +397,6 @@
-1 );
g_free ( str_balance );
- if ( gsb_real_cmp ( tmp_range -> min_balance, tmp_range -> current_balance ) > 0 )
- tmp_range -> min_balance = tmp_range -> current_balance;
- if ( gsb_real_cmp ( tmp_range -> max_balance, tmp_range -> current_balance ) < 0 )
- tmp_range -> max_balance = tmp_range -> current_balance;
-
return FALSE;
}
@@ -443,12 +442,10 @@
*/
static void bet_estimate_refresh ( void )
{
- /* find the selected account */
GtkWidget *widget;
GtkWidget *tree_view;
GtkTreeIter iter;
GtkTreeModel *tree_model;
- GtkTreeSelection *tree_selection;
gchar *account_name = NULL;
gchar *data;
gchar *str_date_min;
@@ -467,20 +464,9 @@
GValue date_value = {0, };
tmp_range = initialise_struct_bet_range ( );
- tree_view = g_object_get_data ( G_OBJECT ( bet_container ), "bet_account_treeview" );
- tree_selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW ( tree_view ) );
-
- if ( !gtk_tree_selection_get_selected ( GTK_TREE_SELECTION ( tree_selection ),
- &tree_model, &iter ) )
- {
- /* no selection, select the first account
- * (no warning here because cause a conflict with the tree of navigation */
- gtk_notebook_set_current_page ( GTK_NOTEBOOK ( bet_container ), 0 );
- return;
- }
- gtk_tree_model_get ( tree_model, &iter, 0, &account_name, -1 );
- selected_account = gsb_data_account_get_no_account_by_name ( account_name );
+ /* find the selected account */
+ selected_account = bet_estimate_get_account_selected ( );
if ( selected_account == -1 )
return;
@@ -498,12 +484,15 @@
period = ( data ) ? GPOINTER_TO_INT ( data ): 2;
date_max = gdate_today ();
- g_date_add_months (date_max, months );
if ( period == 1 )
+ {
+ g_date_add_months (date_max, months - 1 );
date_max = gsb_date_get_last_day_of_month ( date_max );
+ }
+ else
+ g_date_add_months (date_max, months );
- /* set the graph title and the array title */
str_date_min = gsb_format_gdate ( date_min );
g_value_init ( &date_value, G_TYPE_DATE );
g_value_set_boxed ( &date_value, date_min );
@@ -775,15 +764,14 @@
g_free ( str_debit );
}
+ /* search data from the past */
+ bet_estimate_refresh_historical_data ( tree_model, date_min, date_max );
+
g_free ( date_min );
g_free ( date_max );
/* Calculate the balance column */
tmp_range -> first_pass = TRUE;
- //~ tmp_range -> min_date = date_min;
- //~ tmp_range -> max_date = date_max;
- tmp_range -> min_balance = null_real;
- tmp_range -> max_balance = null_real;
tmp_range -> current_balance = current_balance;
gtk_tree_model_foreach ( GTK_TREE_MODEL ( tree_model ),
@@ -803,17 +791,31 @@
* It copies the new durations from the data parameter (of the radio button) into
* the bet_period property of the bet container
*/
-static void bet_duration_period_clicked ( GtkWidget *togglebutton, gpointer data )
+static void bet_duration_period_clicked ( GtkWidget *togglebutton, GtkWidget *button )
{
const gchar *name;
-
+
+ g_signal_handlers_block_by_func ( G_OBJECT ( button ),
+ G_CALLBACK (bet_duration_period_clicked),
+ button );
+
name = gtk_widget_get_name ( GTK_WIDGET ( togglebutton ) );
if ( g_strcmp0 ( name, "button_1" ) == 0 )
+ {
g_object_set_data ( G_OBJECT ( bet_container ), "bet_deb_period",
GINT_TO_POINTER ( 1 ) );
+ g_object_set_data ( G_OBJECT ( bet_container ), "bet_end_period",
+ GINT_TO_POINTER ( 1 ) );
+ gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( button ), TRUE );
+ }
else if ( g_strcmp0 ( name, "button_2" ) == 0 )
+ {
g_object_set_data ( G_OBJECT ( bet_container ), "bet_deb_period",
GINT_TO_POINTER ( 2 ) );
+ g_object_set_data ( G_OBJECT ( bet_container ), "bet_end_period",
+ GINT_TO_POINTER ( 2 ) );
+ gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( button ), TRUE );
+ }
else if ( g_strcmp0 ( name, "button_3" ) == 0 )
g_object_set_data ( G_OBJECT ( bet_container ), "bet_end_period",
GINT_TO_POINTER ( 1 ) );
@@ -822,6 +824,10 @@
g_object_set_data ( G_OBJECT ( bet_container ), "bet_end_period",
GINT_TO_POINTER ( 2 ) );
+ g_signal_handlers_unblock_by_func ( G_OBJECT ( button ),
+ G_CALLBACK (bet_duration_period_clicked),
+ button );
+
bet_estimate_refresh ( );
}
@@ -928,13 +934,26 @@
{
GtkTreeIter iter;
gboolean valeur;
+ gchar *tmp_str;
gint nbre_fils;
if ( gtk_tree_model_get_iter_from_string ( GTK_TREE_MODEL ( store ), &iter, path_string ) )
{
- gtk_tree_model_get ( GTK_TREE_MODEL ( store ), &iter, 0, &valeur, -1 );
+ gtk_tree_model_get ( GTK_TREE_MODEL ( store ), &iter,
+ SPP_HISTORICAL_SELECT_COLUMN, &valeur,
+ SPP_HISTORICAL_AVERAGE_COLUMN, &tmp_str,
+ -1 );
valeur = 1 - valeur;
- gtk_tree_store_set ( GTK_TREE_STORE ( store ), &iter, 0, valeur, -1 );
+ if ( valeur == 1 )
+ gtk_tree_store_set ( GTK_TREE_STORE ( store ), &iter,
+ SPP_HISTORICAL_SELECT_COLUMN, valeur,
+ SPP_HISTORICAL_RETAINED_COLUMN, tmp_str,
+ -1 );
+ else
+ gtk_tree_store_set ( GTK_TREE_STORE ( store ), &iter,
+ SPP_HISTORICAL_SELECT_COLUMN, valeur,
+ SPP_HISTORICAL_RETAINED_COLUMN, "",
+ -1 );
nbre_fils = gtk_tree_model_iter_n_children ( GTK_TREE_MODEL ( store ),
&iter );
@@ -980,6 +999,8 @@
}
}
+ bet_estimate_refresh ( );
+
return ( FALSE );
}
@@ -990,24 +1011,54 @@
*
*
* */
+void bet_historical_div_cell_editing_started (GtkCellRenderer *cell,
+ GtkCellEditable *editable,
+ const gchar *path,
+ gpointer data)
+{
+ if ( GTK_IS_ENTRY ( editable ) )
+ {
+ gtk_editable_delete_text ( GTK_EDITABLE ( editable ), 0, -1 );
+ }
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
void bet_historical_div_cell_edited (GtkCellRendererText *cell,
const gchar *path_string,
const gchar *new_text,
GtkWidget *tree_view )
{
- //~ GtkWidget *entry;
- //~ GtkTreeView *treeview;
GtkTreeModel *model;
+ gint selected_account;
+ gint currency_number;
GtkTreePath *path = gtk_tree_path_new_from_string ( path_string );
GtkTreeIter iter;
- //~ GSList *list_tmp;
- //~ gchar *search_str;
- //~ gint payee_number;
+ gchar *tmp_str;
+ gsb_real number;
- printf ("bet_historical_div_cell_edited\n");
- model = gtk_tree_view_get_model ( tree_view );
+ number = gsb_real_get_from_string ( new_text );
+
+ /* find the selected account */
+ selected_account = bet_estimate_get_account_selected ( );
+ if ( selected_account == -1 )
+ return;
+ currency_number = gsb_data_account_get_currency ( selected_account );
+
+ tmp_str = gsb_real_get_string_with_currency ( number, currency_number, TRUE );
+ model = gtk_tree_view_get_model ( GTK_TREE_VIEW ( tree_view ) );
gtk_tree_model_get_iter (model, &iter, path);
- //~ gtk_tree_model_get ( model, &iter, SPP_HISTORICAL_RETAINED_COLUMN, &search_str, -1 );
+ gtk_tree_store_set ( GTK_TREE_STORE ( model ), &iter,
+ SPP_HISTORICAL_RETAINED_COLUMN, tmp_str,
+ SPP_HISTORICAL_RETAINED_AMOUNT, new_text,
+ -1 );
+
+ bet_estimate_refresh ( );
}
@@ -1444,10 +1495,6 @@
gtk_widget_set_name ( button_1, "button_1" );
gtk_size_group_add_widget ( GTK_SIZE_GROUP ( size_group ), button_1 );
- g_signal_connect (G_OBJECT ( button_1 ),
- "released",
- G_CALLBACK ( bet_duration_period_clicked ),
- NULL );
g_object_set_data ( G_OBJECT ( bet_container ), "bet_deb_period",
GINT_TO_POINTER ( 1 ) );
button_2 = gtk_radio_button_new_with_label_from_widget (
@@ -1455,11 +1502,6 @@
_("date today") );
gtk_widget_set_name ( button_2, "button_2" );
- g_signal_connect (G_OBJECT ( button_2 ),
- "released",
- G_CALLBACK ( bet_duration_period_clicked ),
- NULL );
-
gtk_box_pack_start ( GTK_BOX ( hbox ), button_1, FALSE, FALSE, 5) ;
gtk_box_pack_start ( GTK_BOX ( hbox ), button_2, FALSE, FALSE, 5) ;
@@ -1476,16 +1518,26 @@
gtk_widget_set_name ( button_3, "button_3" );
gtk_size_group_add_widget ( GTK_SIZE_GROUP ( size_group ), button_3 );
- g_signal_connect (G_OBJECT ( button_3 ),
- "released",
- G_CALLBACK ( bet_duration_period_clicked ),
- NULL );
g_object_set_data ( G_OBJECT ( bet_container ), "bet_end_period",
GINT_TO_POINTER ( 1 ) );
button_4 = gtk_radio_button_new_with_label_from_widget (
GTK_RADIO_BUTTON ( button_3 ),
_("From date to date") );
gtk_widget_set_name ( button_4, "button_4" );
+
+ /*set the signals */
+ g_signal_connect (G_OBJECT ( button_1 ),
+ "released",
+ G_CALLBACK ( bet_duration_period_clicked ),
+ button_3 );
+ g_signal_connect (G_OBJECT ( button_2 ),
+ "released",
+ G_CALLBACK ( bet_duration_period_clicked ),
+ button_4 );
+ g_signal_connect (G_OBJECT ( button_3 ),
+ "released",
+ G_CALLBACK ( bet_duration_period_clicked ),
+ NULL );
g_signal_connect (G_OBJECT ( button_4 ),
"released",
G_CALLBACK ( bet_duration_period_clicked ),
@@ -1656,6 +1708,10 @@
cell = gtk_cell_renderer_text_new ( );
g_object_set (cell, "editable", TRUE, NULL);
g_signal_connect ( cell,
+ "editing-started",
+ G_CALLBACK (bet_historical_div_cell_editing_started),
+ tree_view );
+ g_signal_connect ( cell,
"edited",
G_CALLBACK (bet_historical_div_cell_edited),
tree_view );
@@ -1688,10 +1744,7 @@
{
GtkWidget *tree_view;
GtkWidget *combo;
- GtkTreeIter iter;
GtkTreeModel *model;
- GtkTreeSelection *tree_selection;
- gchar *account_name = NULL;
gint selected_account;
gint fyear_number;
GDate *date_min;
@@ -1700,20 +1753,7 @@
GHashTable *list_div;
/* récuperation du n° de compte à utiliser */
- tree_view = g_object_get_data ( G_OBJECT ( bet_container ), "bet_account_treeview" );
- tree_selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW ( tree_view ) );
-
- if ( !gtk_tree_selection_get_selected ( GTK_TREE_SELECTION ( tree_selection ),
- &model, &iter ) )
- {
- /* no selection, select the first account
- * (no warning here because cause a conflict with the tree of navigation */
- gtk_notebook_set_current_page ( GTK_NOTEBOOK ( bet_container ), 0 );
- return;
- }
-
- gtk_tree_model_get ( model, &iter, 0, &account_name, -1 );
- selected_account = gsb_data_account_get_no_account_by_name ( account_name );
+ selected_account = bet_estimate_get_account_selected ( );
if ( selected_account == -1 )
return;
@@ -1890,17 +1930,21 @@
gchar *div_name = NULL;
gchar *str_balance;
gchar *str_average;
+ gchar *str_amount;
gchar *titre;
gsb_real period = { 12, 0 };
+ gsb_real average;
div = sh -> div;
div_name = ptr_div_name ( div, 0, FALSE );
titre = g_object_get_data ( G_OBJECT ( bet_container ), "bet_historical_period" );
+
+ average = gsb_real_div ( sbr -> current_balance, period );
+ str_amount = gsb_real_get_string ( average );
str_balance = gsb_real_get_string_with_currency ( sbr -> current_balance,
gsb_data_account_get_currency ( sh -> account_nb ), TRUE );
- str_average = gsb_real_get_string_with_currency (
- gsb_real_div ( sbr -> current_balance, period ),
+ str_average = gsb_real_get_string_with_currency ( average,
gsb_data_account_get_currency ( sh -> account_nb ), TRUE );
gtk_tree_store_append ( GTK_TREE_STORE ( model ), &parent, NULL);
@@ -1910,11 +1954,12 @@
SPP_HISTORICAL_PERIOD_COLUMN, titre,
SPP_HISTORICAL_BALANCE_COLUMN, str_balance,
SPP_HISTORICAL_AVERAGE_COLUMN, str_average,
- SPP_HISTORICAL_RETAINED_COLUMN, str_average,
+ SPP_HISTORICAL_RETAINED_AMOUNT, str_amount,
-1);
g_free ( div_name );
g_free ( str_balance );
g_free ( str_average );
+ g_free ( str_amount );
if ( g_hash_table_size ( sh -> list_sub_div ) == 1 )
return;
@@ -1936,11 +1981,12 @@
if ( tab_str )
g_strfreev ( tab_str );
}
-
+
+ average = gsb_real_div ( sub_sbr -> current_balance, period );
+ str_amount = gsb_real_get_string ( average );
str_balance = gsb_real_get_string_with_currency ( sub_sbr -> current_balance,
gsb_data_account_get_currency ( sh -> account_nb ), TRUE );
- str_average = gsb_real_get_string_with_currency (
- gsb_real_div ( sub_sbr -> current_balance, period ),
+ str_average = gsb_real_get_string_with_currency ( average,
gsb_data_account_get_currency ( sh -> account_nb ), TRUE );
gtk_tree_store_append ( GTK_TREE_STORE ( model ), &fils, &parent );
@@ -1950,9 +1996,13 @@
SPP_HISTORICAL_PERIOD_COLUMN, titre,
SPP_HISTORICAL_BALANCE_COLUMN, str_balance,
SPP_HISTORICAL_AVERAGE_COLUMN, str_average,
+ SPP_HISTORICAL_RETAINED_AMOUNT, str_amount,
-1);
g_free ( div_name );
+ g_free ( str_balance );
+ g_free ( str_average );
+ g_free ( str_amount );
}
}
/**
@@ -2083,10 +2133,181 @@
return fyear_number;
}
/**
+ * find the selected account
+ *
+ * */
+gint bet_estimate_get_account_selected ( void )
+{
+ GtkWidget *tree_view;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkTreeSelection *tree_selection;
+ gchar *account_name = NULL;
+ gint selected_account;
+
+ /* récuperation du n° de compte à utiliser */
+ tree_view = g_object_get_data ( G_OBJECT ( bet_container ), "bet_account_treeview" );
+ tree_selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW ( tree_view ) );
+
+ if ( !gtk_tree_selection_get_selected ( GTK_TREE_SELECTION ( tree_selection ),
+ &model, &iter ) )
+ {
+ /* no selection, select the first account
+ * (no warning here because cause a conflict with the tree of navigation */
+ gtk_notebook_set_current_page ( GTK_NOTEBOOK ( bet_container ), 0 );
+ return -1 ;
+ }
+
+ gtk_tree_model_get ( model, &iter, 0, &account_name, -1 );
+ selected_account = gsb_data_account_get_no_account_by_name ( account_name );
+
+ return selected_account;
+}
+/**
*
*
*
*
* */
+void bet_estimate_refresh_historical_data ( GtkTreeModel *tab_model,
+ GDate *date_min,
+ GDate *date_max )
+{
+ GtkWidget *tree_view;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreeIter fils_iter;
+
+ tree_view = g_object_get_data ( G_OBJECT ( bet_container ), "bet_historical_treeview" );
+ model = gtk_tree_view_get_model ( GTK_TREE_VIEW ( tree_view ) );
+
+ if ( gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( model ), &iter ) )
+ {
+ gboolean valeur;
+ do
+ {
+ gtk_tree_model_get ( GTK_TREE_MODEL ( model ), &iter,
+ SPP_HISTORICAL_SELECT_COLUMN, &valeur,
+ -1 );
+ if ( valeur == 1 )
+ {
+ bet_estimate_tab_add_new_line ( tab_model,
+ GTK_TREE_MODEL ( model ), &iter,
+ date_min, date_max );
+ }
+ else if ( gtk_tree_model_iter_children (
+ GTK_TREE_MODEL ( model ),
+ &fils_iter, &iter ) )
+ {
+ do
+ {
+ gtk_tree_model_get ( GTK_TREE_MODEL ( model ),
+ &fils_iter,
+ SPP_HISTORICAL_SELECT_COLUMN, &valeur,
+ -1 );
+
+ if ( valeur == 1 )
+ {
+ bet_estimate_tab_add_new_line ( tab_model,
+ GTK_TREE_MODEL ( model ), &fils_iter,
+ date_min, date_max );
+ }
+ }
+ while ( gtk_tree_model_iter_next (
+ GTK_TREE_MODEL ( model ), &fils_iter ) );
+ }
+
+ } while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &iter ) );
+ }
+}
+/**
+ *
+ *
+ *
+ *
+ * */
+void bet_estimate_tab_add_new_line ( GtkTreeModel *tab_model,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ GDate *date_min,
+ GDate *date_max )
+{
+ GtkTreeIter tab_iter;
+ GDate *date;
+ GValue date_value = {0, };
+ gchar *str_date;
+ gchar *str_description;
+ gchar *str_value;
+ gchar *str_debit = NULL;
+ gchar *str_credit = NULL;
+ gchar *str_amount;
+ gsb_real amount;
+
+ date = gsb_date_get_last_day_of_month ( date_min );
+
+ /* initialise les données de la ligne insérée */
+ gtk_tree_model_get ( GTK_TREE_MODEL ( model ), iter,
+ SPP_HISTORICAL_DESC_COLUMN, &str_description,
+ SPP_HISTORICAL_RETAINED_COLUMN, &str_value,
+ SPP_HISTORICAL_RETAINED_AMOUNT, &str_amount,
+ -1 );
+
+ amount = gsb_real_get_from_string ( str_amount );
+
+ if (amount.mantissa < 0)
+ str_debit = str_value;
+ else
+ str_credit = str_value;
+
+ while (date != NULL && g_date_valid ( date ) )
+ {
+ if ( g_date_compare ( date, date_max ) > 0 )
+ break;
+
+ if ( g_date_compare ( date, date_min ) < 0 )
+ {
+ g_date_add_months ( date, 1 );
+ continue;
+ }
+
+ if ( g_date_valid ( date ) == FALSE )
+ return;
+
+ str_date = gsb_format_gdate ( date );
+
+ g_value_init ( &date_value, G_TYPE_DATE );
+ if ( date == NULL )
+ return;
+ g_value_set_boxed ( &date_value, date );
+
+ /* add a line in the estimate array */
+ gtk_tree_store_append ( GTK_TREE_STORE ( tab_model ), &tab_iter, NULL );
+ gtk_tree_store_set_value ( GTK_TREE_STORE ( tab_model ), &tab_iter,
+ SPP_ESTIMATE_TREE_SORT_DATE_COLUMN,
+ &date_value );
+ gtk_tree_store_set ( GTK_TREE_STORE ( tab_model ), &tab_iter,
+ SPP_ESTIMATE_TREE_DATE_COLUMN, str_date,
+ SPP_ESTIMATE_TREE_DESC_COLUMN, str_description,
+ SPP_ESTIMATE_TREE_DEBIT_COLUMN, str_debit,
+ SPP_ESTIMATE_TREE_CREDIT_COLUMN, str_credit,
+ SPP_ESTIMATE_TREE_AMOUNT_COLUMN, str_amount,
+ -1);
+
+ g_value_unset ( &date_value );
+ g_free ( str_date );
+ g_date_add_months ( date, 1 );
+ date = gsb_date_get_last_day_of_month ( date );
+ }
+
+ g_free ( str_description );
+ g_free ( str_value );
+ g_free ( str_amount );
+}
+/**
+ *
+ *
+ *
+ *
+ * */
#endif /* ENABLE_BALANCE_ESTIMATE */
Index: utils_files.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/utils_files.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- utils_files.c 20 Jan 2010 13:05:08 -0000 1.49
+++ utils_files.c 23 Jan 2010 13:46:13 -0000 1.50
@@ -78,11 +78,93 @@
static gchar *charset_array[] = {
-"ISO-8859-1",
-"ISO-8859-15",
-"windows-1252",
-"IBM850"};
+ "ISO-8859-1",
+ "ISO-8859-15",
+ "windows-1252",
+ "IBM850"};
+static gchar *all_charset_array[] = {
+ "IBM864",
+ "IBM864i",
+ "ISO-8859-6",
+ "ISO-8859-6-E",
+ "ISO-8859-6-I",
+ "x-mac-arabic",
+ "windows-1256",
+ "armscii-8",
+ "ISO-8859-13",
+ "ISO-8859-4",
+ "windows-1257",
+ "ISO-8859-14",
+ "IBM852",
+ "ISO-8859-2",
+ "x-mac-ce",
+ "windows-1250",
+ "gb18030",
+ "GB2312",
+ "x-gbk",
+ "HZ-GB-2312",
+ "windows-936",
+ "Big5",
+ "Big5-HKSCS",
+ "x-euc-tw",
+ "x-mac-croatian",
+ "IBM855",
+ "ISO-8859-5",
+ "ISO-IR-111",
+ "KOI8-R",
+ "x-mac-cyrillic",
+ "windows-1251",
+ "IBM866",
+ "KOI8-U",
+ "x-mac-ukrainian",
+ "ANSI_X3.4-1968#ASCII",
+ "x-mac-farsi",
+ "geostd8",
+ "ISO-8859-7",
+ "x-mac-greek",
+ "windows-1253",
+ "x-mac-gujarati",
+ "x-mac-gurmukhi",
+ "IBM862",
+ "ISO-8859-8-E",
+ "ISO-8859-8-I",
+ "x-mac-hebrew",
+ "windows-1255",
+ "x-mac-devanagari",
+ "x-mac-icelandic",
+ "EUC-JP",
+ "ISO-2022-JP",
+ "Shift_JIS",
+ "EUC-KR",
+ "ISO-2022-KR",
+ "x-johab",
+ "x-windows-949",
+ "ISO-8859-10",
+ "x-mac-romanian",
+ "ISO-8859-16",
+ "ISO-8859-3",
+ "TIS-620",
+ "IBM857",
+ "ISO-8859-9",
+ "x-mac-turkish",
+ "windows-1254",
+ "UTF-7",
+ "UTF-8",
+ "UTF-16BE",
+ "UTF-16LE",
+ "UTF-32BE",
+ "UTF-32LE",
+ "x-viet-tcvn5712",
+ "VISCII",
+ "x-viet-vps",
+ "windows-1258",
+ "ISO-8859-8",
+ "IBM850",
+ "ISO-8859-1",
+ "ISO-8859-15",
+ "x-mac-roman",
+ "windows-1252"};
/**
* Handler triggered by clicking on the button of a "print to file"
@@ -463,7 +545,7 @@
{
gchar *ptr_r;
- string = g_strndup ( ptr, ( ( ptr_tmp - 1 ) - ptr ) );
+ string = g_strndup ( ptr, ( ( ptr_tmp ) - ptr ) );
if ( ( ptr_r = g_strrstr ( string, "\r" ) ) )
ptr_r = '\0';
@@ -512,7 +594,7 @@
*
* \return A charmap.
*/
-gchar * utils_files_create_sel_charset ( GtkWidget *assistant,
+gchar *utils_files_create_sel_charset ( GtkWidget *assistant,
const gchar *tmp_str,
const gchar *charmap_imported,
gchar *filename )
@@ -761,6 +843,55 @@
}
+/**
+ *
+ *
+ *
+ */
+gchar *utils_files_get_ofx_charset ( gchar *contents )
+{
+ gchar *tmp_str;
+ gchar *string;
+ gchar *ptr;
+ gint i = 0;
+
+ ptr = (gchar *) contents;
+
+ while ( strlen ( ptr ) > 0 )
+ {
+ gchar *ptr_tmp;
+
+ ptr_tmp = g_strstr_len ( ptr, strlen ( ptr ), "\n" );
+ if ( ptr_tmp )
+ {
+ gchar *ptr_r;
+
+ string = g_strndup ( ptr, ( ( ptr_tmp ) - ptr ) );
+ if ( ( ptr_r = g_strrstr ( string, "\r" ) ) )
+ ptr_r = '\0';
+
+ if ( ( tmp_str = g_strrstr ( string, "CHARSET:" ) ) )
+ {
+ do
+ {
+ if ( g_strrstr ( all_charset_array[i], ( tmp_str + 8 ) ) )
+ {
+ g_free ( string );
+ return g_strdup ( all_charset_array[i] );
+ }
+ i++;
+ } while ( all_charset_array[i] );
+ }
+
+ g_free ( string );
+ ptr = ptr_tmp + 1;
+ }
+ else
+ break;
+ }
+
+ return NULL;
+}
/* Local Variables: */
/* c-basic-offset: 4 */
/* End: */
Index: gsb_form_scheduler.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form_scheduler.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- gsb_form_scheduler.c 26 Dec 2009 16:57:13 -0000 1.36
+++ gsb_form_scheduler.c 23 Jan 2010 13:46:12 -0000 1.37
@@ -314,7 +314,7 @@
GtkWidget *category_entry;
gint new_account_number;
- devel_debug (NULL);
+ //~ devel_debug (NULL);
new_account_number = gsb_form_get_account_number ();
- Previous message: [grisbi-cvs] grisbi/src balance_estimate_tab.c, 1.30, 1.31 gsb_form_widget.c, 1.43, 1.44 gsb_transactions_list.c, 1.193, 1.194 import.c, 1.318, 1.319 transaction_list.c, 1.56, 1.57 transaction_list.h, 1.10, 1.11 transaction_model.c, 1.4, 1.5 utils_dates.c, 1.62, 1.63
- Next message: [grisbi-cvs] grisbi/src balance_estimate_tab.c, 1.32, 1.33 gsb_currency.c, 1.55, 1.56 gsb_file_load.c, 1.204, 1.205 gsb_form_widget.c, 1.44, 1.45 gsb_form_widget.h, 1.5, 1.6
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cvs
mailing list