/** * called when the user click on the button 'create the new reconciliation' * check the entries and create the corresponding reconciliation * * \param button * \param label a message label, hidden at the beginning, that will say ok the reconciliation is created * or if there is a problem... * * \return FALSE * */ static gboolean gsb_assistant_reconcile_config_page_add_new_reconcile ( GtkWidget *button, GtkWidget *label ) { gint reconcile_number; gchar *string; /* first, we check the date are valid */ if ( !gsb_date_check_entry ( reconcile_init_date_entry ) ) { string = make_red ( _("The initial date is not valid, please check it.") ); gtk_label_set_markup ( GTK_LABEL ( label) , string ); gtk_widget_grab_focus (reconcile_init_date_entry); g_free ( string ); return FALSE; } if ( !gsb_date_check_entry ( reconcile_final_date_entry ) ) { string = make_red ( _("The final date is not valid, please check it.") ); gtk_label_set_markup ( GTK_LABEL ( label) , string ); gtk_widget_grab_focus ( reconcile_final_date_entry ); g_free ( string ); return FALSE; } /* check there is a name */ if ( !strlen (gtk_entry_get_text ( GTK_ENTRY ( reconcile_name_entry ) ) ) ) { string = make_red ( _("Please give a name to the new reconciliation.") ); gtk_label_set_markup ( GTK_LABEL ( label) , string ); gtk_widget_grab_focus ( reconcile_name_entry ); g_free ( string ); return FALSE; } /* check if already exist the name */ if ( gsb_data_reconcile_get_number_by_name ( gtk_entry_get_text (GTK_ENTRY (reconcile_name_entry) ) ) ) { string = make_red ( _("That name already exists, please find another one.") ); gtk_label_set_markup ( GTK_LABEL ( label) , string ); gtk_widget_grab_focus ( reconcile_name_entry ); g_free ( string ); return FALSE; } /* ok, now we can create the reconcile */ reconcile_number = gsb_data_reconcile_new ( gtk_entry_get_text ( GTK_ENTRY ( reconcile_name_entry ) ) ); if ( !reconcile_number ) if (gsb_data_reconcile_get_number_by_name ( gtk_entry_get_text ( GTK_ENTRY ( reconcile_name_entry ) ) ) ) { string = make_red ( _("Cannot allocate memory : Bad things will happen soon.") ); gtk_label_set_markup ( GTK_LABEL ( label) , string ); gtk_widget_grab_focus ( reconcile_name_entry ); g_free ( string ); return FALSE; } gsb_data_reconcile_set_init_date ( reconcile_number, gsb_calendar_entry_get_date ( reconcile_init_date_entry ) ); gsb_data_reconcile_set_final_date ( reconcile_number, gsb_calendar_entry_get_date ( reconcile_final_date_entry ) ); gsb_data_reconcile_set_init_balance ( reconcile_number, utils_real_get_from_string ( gtk_entry_get_text ( GTK_ENTRY (reconcile_init_balance_entry ) ) ) ); gsb_data_reconcile_set_final_balance ( reconcile_number, utils_real_get_from_string ( gtk_entry_get_text ( GTK_ENTRY ( reconcile_final_balance_entry ) ) ) ); gsb_data_reconcile_set_account ( reconcile_number, gsb_account_get_combo_account_number ( reconcile_account_button ) ); /* erase the entries but not the account wich can be used again */ gtk_entry_set_text ( GTK_ENTRY (reconcile_name_entry), "" ); gtk_entry_set_text ( GTK_ENTRY (reconcile_init_date_entry), "" ); gtk_entry_set_text ( GTK_ENTRY (reconcile_final_date_entry), "" ); gtk_entry_set_text ( GTK_ENTRY (reconcile_init_balance_entry), "" ); gtk_entry_set_text ( GTK_ENTRY (reconcile_final_balance_entry), "" ); string = make_blue ( g_strdup_printf ( _("Reconciliation %s successfully appended!"), gsb_data_reconcile_get_name ( reconcile_number ) ) ); gtk_label_set_markup ( GTK_LABEL ( label ), string ); g_free ( string ); /* update the list of reconcile in the configuration list */ gsb_reconcile_config_fill ( ); gtk_widget_grab_focus ( reconcile_name_entry ); return FALSE; }
/** * finish the reconciliation, * called by a click on the finish button * * \param button * \param null * * \return FALSE */ gboolean gsb_reconcile_finish_reconciliation ( GtkWidget *button, gpointer null ) { GSList *list_tmp_transactions; GDate *date; gint account_number; gint reconcile_number; gsb_real real; gchar* tmpstr; account_number = gsb_gui_navigation_get_current_account (); if ( gsb_real_sub ( gsb_real_add ( utils_real_get_from_string (gtk_entry_get_text ( GTK_ENTRY ( reconcile_initial_balance_entry ))), gsb_data_account_calculate_waiting_marked_balance (account_number)), utils_real_get_from_string (gtk_entry_get_text ( GTK_ENTRY ( reconcile_final_balance_entry )))).mantissa != 0 ) { dialogue_warning_hint ( _("There is a variance in balances, check that both final balance and initial balance minus marked transactions are equal."), _("Reconciliation can't be completed.") ); return FALSE; } /* get and check the reconcile name */ reconcile_number = gsb_data_reconcile_get_number_by_name (gtk_entry_get_text ( GTK_ENTRY ( reconcile_number_entry ))); if (reconcile_number) { dialogue_warning_hint ( _("There is already a reconcile with that name, you must use another name or let it free.\nIf the reconcile name is ending by a number,\nit will be automatically incremented."), _("Reconciliation can't be completed.") ); return FALSE; } /* get and save the date */ date = gsb_calendar_entry_get_date (reconcile_new_date_entry); if (!date) { gchar* tmpstr = g_strdup_printf ( _("Invalid date: '%s'"), gtk_entry_get_text ( GTK_ENTRY ( reconcile_new_date_entry ))); dialogue_warning_hint ( tmpstr, _("Reconciliation can't be completed.") ); g_free ( tmpstr ); return FALSE; } if (!strlen (gtk_entry_get_text ( GTK_ENTRY ( reconcile_number_entry )))) { dialogue_warning_hint ( _("You need to set a name to the reconciliation ; at least, set a number,\nit will be automatically incremented later"), _("Reconciliation can't be completed.") ); return FALSE; } /* 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); } tmpstr = g_strdup_printf ( _("Last statement: %s"), gsb_format_gdate (date)); gtk_label_set_text ( GTK_LABEL ( label_last_statement ), tmpstr); g_free ( tmpstr ); /* create the new reconcile structure */ reconcile_number = gsb_data_reconcile_new (gtk_entry_get_text (GTK_ENTRY (reconcile_number_entry))); gsb_data_reconcile_set_account ( reconcile_number, account_number ); /* set the variables of the reconcile */ gsb_data_reconcile_set_final_date ( reconcile_number, date ); g_date_free (date); date = gsb_parse_date_string (gtk_label_get_text (GTK_LABEL (reconcile_last_date_label))); gsb_data_reconcile_set_init_date ( reconcile_number, date ); g_free (date); real = utils_real_get_from_string ( gtk_entry_get_text ( GTK_ENTRY ( reconcile_initial_balance_entry ) ) ); gsb_data_reconcile_set_init_balance ( reconcile_number, real ); real = utils_real_get_from_string ( gtk_entry_get_text ( GTK_ENTRY ( reconcile_final_balance_entry ) ) ); gsb_data_reconcile_set_final_balance ( reconcile_number, real ); /* modify the reconciled transactions */ list_tmp_transactions = gsb_data_transaction_get_transactions_list (); while ( list_tmp_transactions ) { gint transaction_number_tmp; transaction_number_tmp = gsb_data_transaction_get_transaction_number ( list_tmp_transactions -> data); if ( gsb_data_transaction_get_account_number (transaction_number_tmp) == account_number && ( gsb_data_transaction_get_marked_transaction (transaction_number_tmp) == OPERATION_POINTEE || gsb_data_transaction_get_marked_transaction (transaction_number_tmp) == OPERATION_TELERAPPROCHEE )) { gsb_data_transaction_set_marked_transaction ( transaction_number_tmp, OPERATION_RAPPROCHEE ); gsb_data_transaction_set_reconcile_number ( transaction_number_tmp, reconcile_number ); } list_tmp_transactions = list_tmp_transactions -> next; } /* update the P and T to R in the list */ transaction_list_update_element (ELEMENT_MARK); run.mise_a_jour_liste_comptes_accueil = TRUE; /* go back to the normal transactions list */ gsb_reconcile_cancel (NULL, NULL); /* reset records in run: to do after gsb_reconcile_cancel */ 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; gsb_file_set_modified ( TRUE ); if ( reconcile_save_last_scheduled_convert ) { gsb_gui_navigation_set_selection ( GSB_SCHEDULER_PAGE, 0, NULL ); gsb_scheduler_list_select ( reconcile_save_last_scheduled_convert ); gsb_scheduler_list_edit_transaction ( reconcile_save_last_scheduled_convert ); reconcile_save_last_scheduled_convert = 0; } return FALSE; }
/** * called by menubar to obfuscate the file * * \param * * \return TRUE * */ gboolean file_obfuscate_run ( void ) { GtkWidget *assistant; gint result; gsb_status_message ( _("Obfuscating file...") ); assistant = gsb_assistant_new ( _("Grisbi file obfuscation"), _("This assistant produces anonymized copies of account files, with " "all personal data replaced with harmless random data, in order to " "attach an anonimized copy of your Grisbi file with any bug report " "you submit." "\n\n" "That said, please check that bugs you submit are still valid with " "anonymized version of your files.\n" "\n" "To avoid any problems in your file, after saving the modified file, " "Grisbi will close without letting you saving anything. " "So if you didn't save your changes, please stop this assistant, " "save your work and restart the obfuscation process.\n\n" "In next page, you will be able to select individual features to " "obfuscate or to keep depending on the level of privacy needed."), "bug.png", NULL ); gsb_assistant_add_page ( assistant, file_obfuscate_page_1 (), 1, 0, 2, NULL ); gsb_assistant_add_page ( assistant, file_obfuscate_page_2 (), 2, 1, -1, NULL ); result = gsb_assistant_run ( assistant ); if (result == GTK_RESPONSE_APPLY) { /* obfuscate the file */ GSList *tmp_list; gchar *filename; /* remove the swp file */ gsb_file_util_modify_lock (FALSE); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_accounts_details))) { /* hide the details of account but not the names */ tmp_list = gsb_data_account_get_list_accounts (); while (tmp_list) { gint account_number = gsb_data_account_get_no_account (tmp_list -> data); gsb_data_account_set_id (account_number, g_strdup_printf ("id account %d", account_number)); gsb_data_account_set_comment (account_number, NULL); gsb_data_account_set_holder_name (account_number, NULL); gsb_data_account_set_holder_address (account_number, NULL); gsb_data_account_set_init_balance (account_number, null_real); gsb_data_account_set_mini_balance_wanted (account_number, null_real); gsb_data_account_set_mini_balance_authorized (account_number, null_real); gsb_data_account_set_bank_branch_code (account_number, NULL); gsb_data_account_set_bank_account_number (account_number, NULL); gsb_data_account_set_bank_account_key (account_number, NULL); tmp_list = tmp_list -> next; } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_amount))) { /* hide the amounts of transactions */ tmp_list = gsb_data_transaction_get_complete_transactions_list (); while (tmp_list) { gint transaction_number = gsb_data_transaction_get_transaction_number (tmp_list -> data); gsb_data_transaction_set_amount (transaction_number, null_real); gsb_data_transaction_set_voucher (transaction_number, NULL); gsb_data_transaction_set_bank_references (transaction_number, NULL); tmp_list = tmp_list -> next; } /* hide the amounts of scheduled transactions */ tmp_list = gsb_data_scheduled_get_scheduled_list (); while (tmp_list) { gint scheduled_number = gsb_data_scheduled_get_scheduled_number (tmp_list -> data); gsb_data_scheduled_set_amount (scheduled_number, null_real); tmp_list = tmp_list -> next; } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_accounts_names))) { /* hide the accounts names */ tmp_list = gsb_data_account_get_list_accounts (); while (tmp_list) { gint account_number = gsb_data_account_get_no_account (tmp_list -> data); gsb_data_account_set_name (account_number, g_strdup_printf ("Account n°%d", account_number)); tmp_list = tmp_list -> next; } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_payee))) { /* hide the payees names */ tmp_list = gsb_data_payee_get_payees_list (); while (tmp_list) { gint payee_number = gsb_data_payee_get_no_payee (tmp_list -> data); gsb_data_payee_set_name (payee_number, g_strdup_printf ( "Payee n°%d", payee_number)); gsb_data_payee_set_description (payee_number, NULL); tmp_list = tmp_list -> next; } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_categories))) { /* hide the categories */ tmp_list = gsb_data_category_get_categories_list (); while (tmp_list) { GSList *list_sub_categ; gint category_number = gsb_data_category_get_no_category (tmp_list -> data); gsb_data_category_set_name (category_number, g_strdup_printf ( "Category n°%d", category_number)); list_sub_categ = gsb_data_category_get_sub_category_list (category_number); while (list_sub_categ) { gint sub_categ_number = gsb_data_category_get_no_sub_category (list_sub_categ -> data); gsb_data_category_set_sub_category_name (category_number, sub_categ_number, g_strdup_printf ("Sub-category n°%d", sub_categ_number)); list_sub_categ = list_sub_categ -> next; } tmp_list = tmp_list -> next; } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_budgets))) { /* hide the budgets */ tmp_list = gsb_data_budget_get_budgets_list (); while (tmp_list) { GSList *list_sub_budget; gint budget_number = gsb_data_budget_get_no_budget (tmp_list -> data); gsb_data_budget_set_name (budget_number, g_strdup_printf ( "Budget n°%d", budget_number)); list_sub_budget = gsb_data_budget_get_sub_budget_list (budget_number); while (list_sub_budget) { gint sub_budget_number = gsb_data_budget_get_no_sub_budget (list_sub_budget -> data); gsb_data_budget_set_sub_budget_name (budget_number, sub_budget_number, g_strdup_printf ("Sub-budget n°%d", sub_budget_number)); list_sub_budget = list_sub_budget -> next; } tmp_list = tmp_list -> next; } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_notes))) { /* hide the notes */ tmp_list = gsb_data_transaction_get_complete_transactions_list (); while (tmp_list) { gint transaction_number = gsb_data_transaction_get_transaction_number (tmp_list -> data); gsb_data_transaction_set_notes (transaction_number, NULL); tmp_list = tmp_list -> next; } /* hide the notes of scheduled transactions */ tmp_list = gsb_data_scheduled_get_scheduled_list (); while (tmp_list) { gint scheduled_number = gsb_data_scheduled_get_scheduled_number (tmp_list -> data); gsb_data_scheduled_set_notes (scheduled_number, NULL); tmp_list = tmp_list -> next; } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_banks))) { /* hide the banks */ tmp_list = gsb_data_bank_get_bank_list (); while (tmp_list) { gint bank_number = gsb_data_bank_get_no_bank (tmp_list -> data); gsb_data_bank_set_name (bank_number, g_strdup_printf ("Bank n°%d", bank_number)); gsb_data_bank_set_code (bank_number, NULL); gsb_data_bank_set_bank_address (bank_number, NULL); gsb_data_bank_set_bank_tel (bank_number, NULL); gsb_data_bank_set_bank_mail (bank_number, NULL); gsb_data_bank_set_bank_web (bank_number, NULL); gsb_data_bank_set_bank_note (bank_number, NULL); gsb_data_bank_set_correspondent_name (bank_number, NULL); gsb_data_bank_set_correspondent_tel (bank_number, NULL); gsb_data_bank_set_correspondent_mail (bank_number, NULL); gsb_data_bank_set_correspondent_fax (bank_number, NULL); tmp_list = tmp_list -> next; } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_reports))) { /* hide the reports names*/ tmp_list = gsb_data_report_get_report_list (); while (tmp_list) { gint report_number = gsb_data_report_get_report_number (tmp_list -> data); gsb_data_report_set_report_name ( report_number, g_strdup_printf ( "Report n°%d", report_number)); tmp_list = tmp_list -> next; } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_reconcile))) { /* hide the reconciles */ GList *reconcile_list; reconcile_list = gsb_data_reconcile_get_reconcile_list (); while (reconcile_list) { gint reconcile_number = gsb_data_reconcile_get_no_reconcile (reconcile_list -> data); gsb_data_reconcile_set_init_balance (reconcile_number, null_real); gsb_data_reconcile_set_final_balance (reconcile_number, null_real); reconcile_list = reconcile_list -> next; } } if (nom_fichier_comptes) { /* remove the .gsb */ nom_fichier_comptes[strlen(nom_fichier_comptes) -4] = 0; filename = g_strconcat ( nom_fichier_comptes, "-obfuscated.gsb", NULL); } else filename = g_strconcat ( my_get_gsb_file_default_dir (), "No_name-obfuscated.gsb", NULL); if (gsb_file_save_save_file (filename, FALSE, FALSE)) dialogue_hint ( g_strdup_printf ( _("Obfuscated file saved as\n'%s'"), filename ), _("Obfuscation succeeded") ); else dialogue_error_hint (g_strdup_printf (_("Grisbi couldn't save the file\n'%s'"), filename ), _("Obfuscation failed") ); /* bye bye */ exit (0); } gtk_widget_destroy ( assistant ); gsb_status_message ( _("Done.") ); return FALSE; }