Merge Jean Laroche's 'fix_797042_ofx_return' into maint.

This commit is contained in:
John Ralls 2020-03-22 10:34:12 -07:00
commit b7f6cfe607
4 changed files with 60 additions and 7 deletions

View File

@ -939,7 +939,7 @@ txn_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data)
if (!data->generic_importer)
{
data->generic_importer = gnc_gen_trans_list_new(data->parent, NULL,
TRUE, 14);
TRUE, 14, TRUE);
if (data->execute_txns)
{
gnc_gen_trans_list_add_tp_cb(data->generic_importer,

View File

@ -177,6 +177,21 @@ void gnc_gen_trans_list_delete (GNCImportMainMatcher *info)
g_free (info);
}
gboolean gnc_gen_trans_list_empty(GNCImportMainMatcher *info)
{
GtkTreeModel *model;
GtkTreeIter iter;
GNCImportTransInfo *trans_info;
g_assert (info);
model = gtk_tree_view_get_model (info->view);
return !gtk_tree_model_get_iter_first (model, &iter);
}
void gnc_gen_trans_list_show_all(GNCImportMainMatcher *info)
{
gtk_widget_show_all (GTK_WIDGET (info->main_widget));
}
void
on_matcher_ok_clicked (GtkButton *button, GNCImportMainMatcher *info)
{
@ -190,7 +205,11 @@ on_matcher_ok_clicked (GtkButton *button, GNCImportMainMatcher *info)
model = gtk_tree_view_get_model (info->view);
if (!gtk_tree_model_get_iter_first (model, &iter))
{
// No transaction, we can just close the dialog.
gnc_gen_trans_list_delete (info);
return;
}
/* Don't run any queries and/or split sorts while processing the matcher
results. */
@ -893,7 +912,8 @@ show_account_column_toggled_cb (GtkToggleButton *togglebutton,
GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent,
const gchar* heading,
gboolean all_from_same_account,
gint match_date_hardlimit)
gint match_date_hardlimit,
gboolean show_all)
{
GNCImportMainMatcher *info;
GtkBuilder *builder;
@ -948,7 +968,8 @@ GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent,
gtk_label_set_text (GTK_LABEL (heading_label), heading);
gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->main_widget), GTK_WINDOW (parent));
gtk_widget_show_all (GTK_WIDGET (info->main_widget));
if(show_all)
gtk_widget_show_all (GTK_WIDGET (info->main_widget));
info->transaction_processed_cb = NULL;

View File

@ -62,12 +62,15 @@ typedef void (*GNCTransactionProcessedCB) (GNCImportTransInfo *trans_info,
* with paper checks (e.g. OFX, QIF), values like 42 (days) seem more
* appropriate.
*
@param show_all if true, all widgets are shown
*
* @return A pointer to the GNCImportMainMatcher which has been setup.
*/
GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent,
const gchar* heading,
gboolean all_from_same_account,
gint match_date_hardlimit);
gint match_date_hardlimit,
gboolean show_all);
@ -170,13 +173,28 @@ void gnc_gen_trans_list_add_trans_with_ref_id(GNCImportMainMatcher *gui, Transac
/** Run this dialog and return only after the user pressed Ok, Cancel,
or closed the window. This means that all actual importing will
have been finished upon returning.
*/
* @param info A pointer to a the GNCImportMainMatcher structure.
* @return The boolean return value of the dialog run.
*/
gboolean gnc_gen_trans_list_run (GNCImportMainMatcher *info);
/** Returns the widget of this dialog.
* @param info A pointer to a the GNCImportMainMatcher structure.
* @return A GtkWidget pointer to the dialog's widget.
*/
GtkWidget *gnc_gen_trans_list_widget (GNCImportMainMatcher *info);
/** Checks whether there are no transactions to match.
* @param info A pointer to a the GNCImportMainMatcher structure.
* @return A boolean indicating whether the transaction list is empty.
*/
gboolean gnc_gen_trans_list_empty(GNCImportMainMatcher *info);
/** Shows widgets.
* @param info A pointer to a the GNCImportMainMatcher structure.
*/
void gnc_gen_trans_list_show_all(GNCImportMainMatcher *info);
#endif
/**@}*/

View File

@ -66,6 +66,7 @@ static QofLogModule log_module = GNC_MOD_IMPORT;
GNCImportMainMatcher *gnc_ofx_importer_gui = NULL;
static gboolean auto_create_commodity = FALSE;
static Account *ofx_parent_account = NULL;
static gint num_trans_processed = 0;
GList *ofx_created_commodites = NULL;
@ -889,7 +890,7 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void *user_data)
xaccTransDestroy(transaction);
xaccTransCommitEdit(transaction);
}
num_trans_processed += 1;
return 0;
}//end ofx_proc_transaction()
@ -1064,7 +1065,7 @@ void gnc_file_ofx_import (GtkWindow *parent)
DEBUG("Filename found: %s", selected_filename);
/* Create the Generic transaction importer GUI. */
gnc_ofx_importer_gui = gnc_gen_trans_list_new (GTK_WIDGET(parent), NULL, FALSE, 42);
gnc_ofx_importer_gui = gnc_gen_trans_list_new (GTK_WIDGET(parent), NULL, FALSE, 42, FALSE);
/* Look up the needed preferences */
auto_create_commodity =
@ -1085,8 +1086,21 @@ void gnc_file_ofx_import (GtkWindow *parent)
#endif
DEBUG("Opening selected file");
num_trans_processed = 0;
libofx_proc_file(libofx_context, selected_filename, AUTODETECT);
// Now would be a good time to see whether the view has anything in it!
if(gnc_gen_trans_list_empty(gnc_ofx_importer_gui))
{
gnc_gen_trans_list_delete (gnc_ofx_importer_gui);
if(num_trans_processed)
gnc_info_dialog(parent,_("OFX file imported, %d transactions processed, no transactions to match"),num_trans_processed);
}
else
{
gnc_gen_trans_list_show_all(gnc_ofx_importer_gui);
}
g_free(selected_filename);
}
if (ofx_created_commodites)