/** * come here to cancel the reconciliation * come here too at the end of the finish reconcile to set the default values * * \param button not used * \param null not used * * \return FALSE * */ gboolean gsb_reconcile_cancel ( GtkWidget *button, gpointer null ) { run.equilibrage = 0; /* save the final balance/new date for the next time the user will try to reconcile */ run.reconcile_account_number = gsb_gui_navigation_get_current_account (); run.reconcile_final_balance = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( reconcile_final_balance_entry ) ) ); run.reconcile_new_date = gsb_parse_date_string ( gtk_entry_get_text ( GTK_ENTRY ( reconcile_new_date_entry ) ) ); /* set the normal color to the date entry */ gsb_calendar_entry_set_color ( reconcile_new_date_entry, TRUE); /* restore the good sort of the list */ if (transaction_list_sort_get_reconcile_sort ()) { gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (reconcile_sort_list_button), FALSE ); gsb_reconcile_list_button_clicked (reconcile_sort_list_button, NULL); } transaction_list_show_toggle_mark (FALSE); /* restore the saved data */ etat.retient_affichage_par_compte = reconcile_save_account_display; gsb_transactions_list_set_visible_rows_number ( reconcile_save_rows_number ); if (reconcile_save_show_marked) { gsb_data_account_set_r (gsb_gui_navigation_get_current_account (), TRUE ); mise_a_jour_affichage_r (TRUE); } /* Don't display uneeded widget for now. */ gtk_widget_hide ( reconcile_panel ); gsb_reconcile_sensitive (TRUE); return FALSE; }
/** * start the reconciliation, called by a click on the * reconcile button * * \param button the button we click to come here * \param null not used * * \return FALSE * */ gboolean gsb_reconcile_run_reconciliation ( GtkWidget *button, gpointer null ) { GDate *date; gint account_number; gint reconcile_number; gchar *label; gchar *string; gchar* tmpstr; account_number = gsb_gui_navigation_get_current_account (); reconcile_number = gsb_data_reconcile_get_account_last_number (account_number); label = gsb_reconcile_build_label ( reconcile_number ); gtk_entry_set_text ( GTK_ENTRY ( reconcile_number_entry ), label ); g_free ( label ); /* reset records in run structure if user has changed of account */ if (run.reconcile_account_number != account_number) { g_free (run.reconcile_final_balance); if (run.reconcile_new_date) g_date_free (run.reconcile_new_date); run.reconcile_final_balance = NULL; run.reconcile_new_date = NULL; run.reconcile_account_number = -1; } /* set last input date/amount if available */ if (run.reconcile_new_date) { date = run.reconcile_new_date; } else { /* increase the last date of 1 month */ date = gsb_date_copy (gsb_data_reconcile_get_final_date (reconcile_number)); if (date) { GDate *today; gchar *string ; string = gsb_format_gdate ( date ); gtk_label_set_text ( GTK_LABEL ( reconcile_last_date_label ), string); gtk_widget_set_sensitive ( GTK_WIDGET ( reconcile_last_date_label ), FALSE ); g_free (string); g_date_add_months ( date, 1 ); /* if etat.reconcile_end_date or the new date is after today, set today */ today = gdate_today(); if ( etat.reconcile_end_date || g_date_compare ( date, today) > 0 ) { g_date_free (date); date = gdate_today(); } else g_date_free (today); /* it's not the first reconciliation, set the old balance and unsensitive the old balance entry */ tmpstr = utils_real_get_string (gsb_data_reconcile_get_final_balance (reconcile_number)); gtk_entry_set_text ( GTK_ENTRY ( reconcile_initial_balance_entry ), tmpstr); g_free ( tmpstr ); gtk_widget_set_sensitive ( GTK_WIDGET ( reconcile_initial_balance_entry ), FALSE ); } else { gtk_label_set_text ( GTK_LABEL ( reconcile_last_date_label ), _("None") ); date = gdate_today(); /* it's the first reconciliation, set the initial balance and make sensitive the old balance to change * it if necessary */ tmpstr = utils_real_get_string ( gsb_data_account_get_init_balance (account_number, -1)); gtk_entry_set_text ( GTK_ENTRY ( reconcile_initial_balance_entry ), tmpstr); g_free ( tmpstr ); gtk_widget_set_sensitive ( GTK_WIDGET ( reconcile_initial_balance_entry ), TRUE ); } } string = gsb_format_gdate (date); gtk_entry_set_text ( GTK_ENTRY ( reconcile_new_date_entry ), string ); g_free (string); g_date_free (date); /* set last input amount if available and if the account is the good one */ gtk_entry_set_text ( GTK_ENTRY ( reconcile_final_balance_entry ), (run.reconcile_final_balance) ? run.reconcile_final_balance : ""); g_free(run.reconcile_final_balance); /* set the title */ tmpstr = g_markup_printf_escaped ( _(" <b>%s reconciliation</b> "), gsb_data_account_get_name (account_number)); gtk_label_set_markup ( GTK_LABEL (gtk_frame_get_label_widget (GTK_FRAME (reconcile_panel))), tmpstr ); g_free ( tmpstr ); /* we go to the reconciliation mode */ run.equilibrage = 1; /* set all the balances for reconciliation */ gsb_reconcile_update_amounts (NULL, NULL); /* set the transactions list to reconciliation mode */ /* only change the current account */ reconcile_save_account_display = etat.retient_affichage_par_compte; etat.retient_affichage_par_compte = 1; /* hide the marked R transactions */ reconcile_save_show_marked = gsb_data_account_get_r (account_number); if (reconcile_save_show_marked) { gsb_data_account_set_r (account_number, FALSE ); mise_a_jour_affichage_r (FALSE); } /* 1 line on the transaction list */ reconcile_save_rows_number = gsb_data_account_get_nb_rows (account_number); if (reconcile_save_rows_number != 1) gsb_transactions_list_set_visible_rows_number ( 1 ); /* sort by method of payment if in conf */ if (gsb_data_account_get_reconcile_sort_type (account_number)) gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (reconcile_sort_list_button), TRUE ); gtk_widget_show_all ( reconcile_panel ); transaction_list_show_toggle_mark (TRUE); /* unsensitive all that could change the account number */ gsb_reconcile_sensitive (FALSE); gtk_widget_grab_focus ( GTK_WIDGET ( reconcile_number_entry ) ); return FALSE; }
/** * set the selection on the given transaction * * \param transaction_number the transaction to select * * \return FALSE if not possible (not visible), TRUE if ok * */ gboolean transaction_list_select ( gint transaction_number ) { CustomRecord *record = NULL; gboolean return_value; GtkTreePath *path; CustomList *custom_list; custom_list = transaction_model_get_model (); g_return_val_if_fail ( custom_list != NULL, FALSE ); /* fixes bug 1875 */ if (custom_list->num_visibles_rows == 0) return FALSE; /* if the selection didn't change, do nothing */ if ( gsb_data_transaction_get_transaction_number (custom_list -> selected_row) == transaction_number ) return FALSE; /* first, we un-select the last transaction */ if (custom_list -> selected_row) transaction_list_select_unselect (); /* if we want the white line, this will increase a little the speed */ if (transaction_number == -1) { record = custom_list -> visibles_rows [custom_list -> num_visibles_rows - custom_list -> nb_rows_by_transaction]; if (gsb_data_transaction_get_transaction_number (record -> transaction_pointer) != -1) record = NULL; } if (!record) { GtkTreeIter iter; if (!transaction_model_get_transaction_iter ( &iter, transaction_number, 0 )) return FALSE; record = iter.user_data; } /* si l'opération n'est pas visible on la rend visible */ if ( ( record -> mother_row && record -> mother_row -> filtered_pos == -1 ) || record -> filtered_pos == -1 ) { gint account_number; account_number = gsb_data_transaction_get_account_number ( transaction_number ); gsb_data_account_set_r ( account_number, TRUE ); gsb_menu_update_view_menu ( account_number ); mise_a_jour_affichage_r ( TRUE ); } return_value = transaction_list_select_record (record); /* if we are on a child, open the expander if necessary */ path = gtk_tree_path_new (); if (record -> mother_row) { gtk_tree_path_append_index (path, record -> mother_row -> filtered_pos); gtk_tree_view_expand_row ( GTK_TREE_VIEW (gsb_transactions_list_get_tree_view ()), path, FALSE ); } else gtk_tree_path_append_index (path, record -> filtered_pos); /* move the tree view to the selection */ gtk_tree_view_scroll_to_cell ( GTK_TREE_VIEW (gsb_transactions_list_get_tree_view ()), path, NULL, FALSE, 0.0, 0.0 ); gtk_tree_path_free (path); return return_value; }