/** * compared by date and by party * * \param none but the local variables transaction_number_1 and transaction_number_2 MUST be set * * \return -1 if amount_2 is above amount_number_1 * */ gint gsb_transactions_list_sort_by_date_and_party ( gint transaction_number_1, gint transaction_number_2 ) { gint return_value; gsb_real amount_1; gsb_real amount_2; if ( !gsb_data_transaction_get_date (transaction_number_1) ) { return 1; } if ( !gsb_data_transaction_get_date (transaction_number_2) ) { return -1; } return_value = g_date_compare ( gsb_data_transaction_get_date (transaction_number_1), gsb_data_transaction_get_date (transaction_number_2)); if ( return_value == 0 ) { /* no difference in the dates, sort by amount of transaction */ amount_1 = gsb_data_transaction_get_amount ( transaction_number_1 ); amount_2 = gsb_data_transaction_get_amount ( transaction_number_2 ); return_value = gsb_transactions_list_sort_by_party ( transaction_number_1, transaction_number_2 ); } return return_value; }
/** * compared by date and by amount * * \param none but the local variables transaction_number_1 and transaction_number_2 MUST be set * * \return -1 if amount_2 is above amount_number_1 * */ gint gsb_transactions_list_sort_by_date_and_amount ( gint transaction_number_1, gint transaction_number_2 ) { gint return_value; GsbReal amount_1; GsbReal amount_2; if ( !gsb_data_transaction_get_date (transaction_number_1) ) { return 1; } if ( !gsb_data_transaction_get_date (transaction_number_2) ) { return -1; } return_value = g_date_compare ( gsb_data_transaction_get_date (transaction_number_1), gsb_data_transaction_get_date (transaction_number_2)); if ( return_value == 0 ) { /* no difference in the dates, sort by amount of transaction */ amount_1 = gsb_data_transaction_get_amount ( transaction_number_1 ); amount_2 = gsb_data_transaction_get_amount ( transaction_number_2 ); return_value = (gint)(amount_2.mantissa - amount_1.mantissa); if ( return_value == 0 ) return_value = transaction_number_1 - transaction_number_2; } return return_value; }
/** * fill the budget of the transaction from the string given in param * create the budget if necessary * if string is NULL, free the budget of the transaction * * \param transaction_number * \param string a string like "budget : sub_budget" * \param is_transaction TRUE if it's for a transaction, FALSE for a scheduled transaction * * \return * */ void gsb_data_budget_set_budget_from_string ( gint transaction_number, const gchar *string, gboolean is_transaction ) { gchar **tab_char; gint budget_number; /* the simpliest is to split in 2 parts, transaction and scheduled, * but the 2 parts are exactly the same, exept the call to the functions */ if (is_transaction) { if (!string || strlen ( string ) == 0 ) { gsb_data_transaction_set_budgetary_number ( transaction_number, 0 ); gsb_data_transaction_set_sub_budgetary_number ( transaction_number, 0 ); return; } tab_char = g_strsplit ( string, " : ", 2 ); /* we don't mind if tab_char exists and others, all the checks will be done in ...get_number_by_name */ budget_number = gsb_data_budget_get_number_by_name ( g_strstrip ( tab_char[0] ), TRUE, gsb_data_transaction_get_amount ( transaction_number ).mantissa < 0 ); gsb_data_transaction_set_budgetary_number ( transaction_number, budget_number ); if ( tab_char[1] ) gsb_data_transaction_set_sub_budgetary_number ( transaction_number, gsb_data_budget_get_sub_budget_number_by_name ( budget_number, g_strstrip (tab_char[1]), TRUE )); } else { if (!string) { gsb_data_scheduled_set_budgetary_number ( transaction_number, 0 ); gsb_data_scheduled_set_sub_budgetary_number ( transaction_number, 0 ); return; } tab_char = g_strsplit ( string, " : ", 2 ); /* we don't mind if tab_char exists and others, all the checks will be done in ...get_number_by_name */ budget_number = gsb_data_budget_get_number_by_name ( tab_char[0], TRUE, gsb_data_scheduled_get_amount (transaction_number).mantissa <0 ); gsb_data_scheduled_set_budgetary_number ( transaction_number, budget_number ); if ( tab_char[1] ) gsb_data_scheduled_set_sub_budgetary_number ( transaction_number, gsb_data_budget_get_sub_budget_number_by_name ( budget_number, tab_char[1], TRUE )); } g_strfreev (tab_char); }
gsb_real gsb_data_mix_get_amount ( gint transaction_number, gboolean is_transaction ) { if ( is_transaction ) return ( gsb_data_transaction_get_amount ( transaction_number ) ); else return ( gsb_data_scheduled_get_amount ( transaction_number ) ); }
/** * function called when the user come to the manually association page * update the list of transactions to associate and fill the labels * * \param assistant * \param new_page * * \return FALSE * */ gboolean gsb_assistant_reconcile_config_update_manu_asso ( GtkWidget *assistant, gint new_page ) { gchar *string; GSList *tmp_list; gint transaction_number; GtkListStore *store; /* update the string containing the number of transactions to link */ string = g_strdup_printf (_("Still %d transactions to link with a reconciliation."), transactions_to_link); gtk_label_set_text ( GTK_LABEL (label_transactions_to_link_3), string); g_free (string); gtk_misc_set_alignment ( GTK_MISC (label_transactions_to_link_3), 0, 0.5 ); /* fill the list with the transactions to link */ store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (treeview_transactions_to_link))); gtk_list_store_clear (GTK_LIST_STORE (store)); tmp_list = gsb_data_transaction_get_transactions_list (); while (tmp_list) { transaction_number = gsb_data_transaction_get_transaction_number (tmp_list -> data); if ( gsb_data_transaction_get_marked_transaction (transaction_number) == OPERATION_RAPPROCHEE && !gsb_data_transaction_get_reconcile_number (transaction_number)) { gchar *amount_str; gchar *date_str; GtkTreeIter iter; date_str = gsb_format_gdate (gsb_data_transaction_get_date (transaction_number)); amount_str = utils_real_get_string (gsb_data_transaction_get_amount (transaction_number)); gtk_list_store_append ( GTK_LIST_STORE (store), &iter ); gtk_list_store_set ( GTK_LIST_STORE (store), &iter, TRANSACTION_DATE, date_str, TRANSACTION_PAYEE, gsb_data_payee_get_name (gsb_data_transaction_get_party_number (transaction_number), TRUE), TRANSACTION_AMOUNT, amount_str, TRANSACTION_ACCOUNT, gsb_data_account_get_name (gsb_data_transaction_get_account_number (transaction_number)), TRANSACTION_NUMBER, transaction_number, -1 ); g_free (amount_str); g_free (date_str); } tmp_list = tmp_list -> next; } return FALSE; }