GnuCash  3.1-61-g2e8df19+
Modules | Files | Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
Import_Export

Modules

 AqBanking
 

Files

 
file  import-backend.h
 Generic importer backend interface.
 
file  import-commodity-matcher.h
 A Generic commodity matcher/picker.
 
file  import-main-matcher.h
 Transaction matcher main window.
 
file  import-match-picker.h
 The transaction match picker dialog interface.
 
file  import-pending-matches.h
 Tracking container for pending match status.
 
file  import-settings.h
 Import preference handling.
 
file  import-utilities.h
 Utility functions for writing import modules.
 

Data Structures

struct  AccountPickerDialog
 
struct  GNCImportSelectedMatchInfo
 
struct  GNCImportTransInfo
 
struct  GNCImportMatchInfo
 
struct  GNCImportMainMatcher
 
struct  GNCImportMatchPicker
 
struct  GNCPendingMatches
 
struct  GNCImportSettings
 
struct  split_record
 

Macros

#define STATE_SECTION   "dialogs/import/generic_matcher/account_matcher"
 
#define GNCIMPORT_DESC   "desc"
 
#define GNCIMPORT_MEMO   "memo"
 
#define GNCIMPORT_PAYEE   "payee"
 
#define GNC_PREFS_GROUP   "dialogs.import.generic.transaction-list"
 
#define CSS_INT_REQUIRED_CLASS   "intervention-required"
 
#define CSS_INT_PROB_REQUIRED_CLASS   "intervention-probably-required"
 
#define CSS_INT_NOT_REQUIRED_CLASS   "intervention-not-required"
 
#define GNC_PREFS_GROUP   "dialogs.import.generic.match-picker"
 
#define GNC_PREF_DISPLAY_RECONCILED   "display-reconciled"
 
#define GNC_PREFS_GROUP_IMPORT   "dialogs.import.generic"
 The preferences used by the importer.
 
#define GNC_PREF_ENABLE_SKIP   "enable-skip"
 
#define GNC_PREF_ENABLE_UPDATE   "enable-update"
 
#define GNC_PREF_USE_BAYES   "use-bayes"
 
#define GNC_PREF_ATM_FEE_THRESHOLD   "atm-fee-threshold"
 
#define GNC_PREF_AUTO_CLEAR_THRESHOLD   "auto-clear-threshold"
 
#define GNC_PREF_AUTO_ADD_THRESHOLD   "auto-add-threshold"
 
#define GNC_PREF_MATCH_THRESHOLD   "match-threshold"
 
#define GNC_PREFS_GROUP   "dialogs.log-replay"
 
#define STRING_FIELD_SIZE   256
 
#define GNC_PREFS_GROUP   "dialogs.import.ofx"
 
#define GNC_PREF_AUTO_COMMODITY   "auto-create-commodity"
 

Typedefs

typedef void(* GNCTransactionProcessedCB) (GNCImportTransInfo *trans_info, gboolean imported, gpointer user_data)
 
typedef GHashTable GNCImportPendingMatches
 

Enumerations

enum  GNCImportAction {
  GNCImport_SKIP, GNCImport_ADD, GNCImport_CLEAR, GNCImport_UPDATE,
  GNCImport_LAST_ACTION, GNCImport_INVALID_ACTION
}
 
enum  downloaded_cols {
  DOWNLOADED_COL_DATE = 0, DOWNLOADED_COL_ACCOUNT, DOWNLOADED_COL_AMOUNT, DOWNLOADED_COL_DESCRIPTION,
  DOWNLOADED_COL_MEMO, DOWNLOADED_COL_ACTION_ADD, DOWNLOADED_COL_ACTION_CLEAR, DOWNLOADED_COL_ACTION_UPDATE,
  DOWNLOADED_COL_ACTION_INFO, DOWNLOADED_COL_ACTION_PIXBUF, DOWNLOADED_COL_DATA, DOWNLOADED_COL_COLOR,
  NUM_DOWNLOADED_COLS, DOWNLOADED_COL_ACCOUNT = 0, DOWNLOADED_COL_DATE, DOWNLOADED_COL_AMOUNT,
  DOWNLOADED_COL_DESCRIPTION, DOWNLOADED_COL_MEMO, DOWNLOADED_COL_BALANCED, DOWNLOADED_COL_INFO_PTR,
  NUM_DOWNLOADED_COLS
}
 
enum  downloaded_cols {
  DOWNLOADED_COL_DATE = 0, DOWNLOADED_COL_ACCOUNT, DOWNLOADED_COL_AMOUNT, DOWNLOADED_COL_DESCRIPTION,
  DOWNLOADED_COL_MEMO, DOWNLOADED_COL_ACTION_ADD, DOWNLOADED_COL_ACTION_CLEAR, DOWNLOADED_COL_ACTION_UPDATE,
  DOWNLOADED_COL_ACTION_INFO, DOWNLOADED_COL_ACTION_PIXBUF, DOWNLOADED_COL_DATA, DOWNLOADED_COL_COLOR,
  NUM_DOWNLOADED_COLS, DOWNLOADED_COL_ACCOUNT = 0, DOWNLOADED_COL_DATE, DOWNLOADED_COL_AMOUNT,
  DOWNLOADED_COL_DESCRIPTION, DOWNLOADED_COL_MEMO, DOWNLOADED_COL_BALANCED, DOWNLOADED_COL_INFO_PTR,
  NUM_DOWNLOADED_COLS
}
 
enum  matcher_cols {
  MATCHER_COL_CONFIDENCE = 0, MATCHER_COL_CONFIDENCE_PIXBUF, MATCHER_COL_DATE, MATCHER_COL_AMOUNT,
  MATCHER_COL_DESCRIPTION, MATCHER_COL_MEMO, MATCHER_COL_RECONCILED, MATCHER_COL_PENDING,
  MATCHER_COL_INFO_PTR, NUM_MATCHER_COLS
}
 
enum  GNCImportPendingMatchType { GNCImportPending_NONE, GNCImportPending_AUTO, GNCImportPending_MANUAL }
 

Functions

char * libgncmod_csv_export_gnc_module_path (void)
 
char * libgncmod_csv_export_gnc_module_description (void)
 
int libgncmod_csv_export_gnc_module_init (int refcount)
 
int libgncmod_csv_export_gnc_module_end (int refcount)
 
char * libgncmod_csv_import_gnc_module_path (void)
 
char * libgncmod_csv_import_gnc_module_description (void)
 
int libgncmod_csv_import_gnc_module_init (int refcount)
 
int libgncmod_csv_import_gnc_module_end (int refcount)
 
Accountgnc_import_select_account (GtkWidget *parent, const gchar *account_online_id_value, gboolean auto_create, const gchar *account_human_description, const gnc_commodity *new_account_default_commodity, GNCAccountType new_account_default_type, Account *default_selection, gboolean *ok_pressed)
 Must be called with a string containing a unique identifier for the account. More...
 
AccountPickerDialoggnc_import_account_assist_setup (GtkWidget *parent)
 Must be called with the parent widget, ie. More...
 
void gnc_import_account_assist_disable (AccountPickerDialog *picker, gboolean disable)
 Must be called with an AccountPickerDialog structure allready setup. More...
 
Accountgnc_import_account_assist_update (AccountPickerDialog *picker)
 Must be called with an AccountPickerDialog structure allready setup. More...
 
gnc_commodity * gnc_import_select_commodity (const char *cusip, gboolean ask_on_unknown, const char *default_fullname, const char *default_mnemonic)
 Must be called with a string containing a unique identifier for the commodity. More...
 
void on_matcher_ok_clicked (GtkButton *button, GNCImportMainMatcher *info)
 
void on_matcher_cancel_clicked (GtkButton *button, gpointer user_data)
 
void on_matcher_help_clicked (GtkButton *button, gpointer user_data)
 This allows for the transaction help dialog to be started from the assistant button callback. More...
 
void on_matcher_help_close_clicked (GtkButton *button, gpointer user_data)
 
void gnc_gen_trans_list_delete (GNCImportMainMatcher *info)
 Deletes the given object. More...
 
GNCImportMainMatcher * gnc_gen_trans_list_new (GtkWidget *parent, const gchar *heading, gboolean all_from_same_account, gint match_date_hardlimit)
 Create a new generic transaction dialog window and return it. More...
 
GNCImportMainMatcher * gnc_gen_trans_assist_new (GtkWidget *parent, GtkWidget *assistant_page, const gchar *heading, gboolean all_from_same_account, gint match_date_hardlimit)
 Add the Transaction matcher to an existing page of an assistant. More...
 
void gnc_gen_trans_assist_start (GNCImportMainMatcher *info)
 This starts the import process for transaction from an assistant. More...
 
void gnc_gen_trans_list_add_tp_cb (GNCImportMainMatcher *info, GNCTransactionProcessedCB trans_processed_cb, gpointer user_data)
 Add transaction processed callback to the transaction importer. More...
 
gboolean gnc_gen_trans_list_run (GNCImportMainMatcher *info)
 Run this dialog and return only after the user pressed Ok, Cancel, or closed the window. More...
 
void gnc_gen_trans_list_add_trans (GNCImportMainMatcher *gui, Transaction *trans)
 Add a newly imported Transaction to the Transaction Importer. More...
 
void gnc_gen_trans_list_add_trans_with_ref_id (GNCImportMainMatcher *gui, Transaction *trans, guint32 ref_id)
 Add a newly imported Transaction to the Transaction Importer and provide an external reference id for it. More...
 
GtkWidget * gnc_gen_trans_list_widget (GNCImportMainMatcher *info)
 Returns the widget of this dialog.
 
void gnc_import_match_picker_run_and_close (GtkWidget *parent, GNCImportTransInfo *transaction_info, GNCImportPendingMatches *pending_matches)
 Run a match_picker dialog so that the selected-MatchInfo in the given trans_info is updated accordingly. More...
 
GNCImportPendingMatches * gnc_import_PendingMatches_new (void)
 
void gnc_import_PendingMatches_delete (GNCImportPendingMatches *map)
 
void gnc_import_PendingMatches_add_match (GNCImportPendingMatches *map, GNCImportMatchInfo *match_info, gboolean selected_manually)
 
void gnc_import_PendingMatches_remove_match (GNCImportPendingMatches *map, GNCImportMatchInfo *match_info, gboolean selected_manually)
 
GNCImportPendingMatchType gnc_import_PendingMatches_get_match_type (GNCImportPendingMatches *map, GNCImportMatchInfo *match_info)
 
const char * gnc_import_PendingMatches_get_type_str (GNCImportPendingMatchType type)
 
GNCImportSettings * gnc_import_Settings_new (void)
 Allocates a new GNCImportSettings object, and initialize it with the appropriate user prefs.
 
void gnc_import_Settings_delete (GNCImportSettings *settings)
 Destructor.
 
gboolean gnc_import_trans_has_online_id (Transaction *transaction)
 
gboolean gnc_import_split_has_online_id (Split *split)
 
void qof_instance_set_guid (gpointer inst, const GncGUID *guid)
 Set the GncGUID of this instance.
 
void gnc_file_log_replay (GtkWindow *parent)
 The gnc_file_log_replay() routine will pop up a standard file selection dialogue asking the user to pick a log file to replay. More...
 
char * libgncmod_log_replay_gnc_module_path (void)
 
char * libgncmod_log_replay_gnc_module_description (void)
 
int libgncmod_log_replay_gnc_module_init (int refcount)
 
int libgncmod_log_replay_gnc_module_end (int refcount)
 
int ofx_proc_security_cb (const struct OfxSecurityData data, void *security_user_data)
 
int ofx_proc_transaction_cb (struct OfxTransactionData data, void *user_data)
 
int ofx_proc_account_cb (struct OfxAccountData data, void *account_user_data)
 
void gnc_file_ofx_import (GtkWindow *parent)
 The gnc_file_ofx_import() routine will pop up a standard file selection dialogue asking the user to pick a OFX/QFX file. More...
 
char * libgncmod_ofx_gnc_module_path (void)
 
char * libgncmod_ofx_gnc_module_description (void)
 
int libgncmod_ofx_gnc_module_init (int refcount)
 
int libgncmod_ofx_gnc_module_end (int refcount)
 

Variables

int libgncmod_csv_export_gnc_module_system_interface = 0
 
int libgncmod_csv_export_gnc_module_current = 0
 
int libgncmod_csv_export_gnc_module_revision = 0
 
int libgncmod_csv_export_gnc_module_age = 0
 
int libgncmod_csv_import_gnc_module_system_interface = 0
 
int libgncmod_csv_import_gnc_module_current = 0
 
int libgncmod_csv_import_gnc_module_revision = 0
 
int libgncmod_csv_import_gnc_module_age = 0
 
gint GNCPendingMatches::num_manual_matches
 
gint GNCPendingMatches::num_auto_matches
 
int libgncmod_log_replay_gnc_module_system_interface = 0
 
int libgncmod_log_replay_gnc_module_current = 0
 
int libgncmod_log_replay_gnc_module_revision = 0
 
int libgncmod_log_replay_gnc_module_age = 0
 
GNCImportMainMatcher * gnc_ofx_importer_gui = NULL
 
GList * ofx_created_commodites = NULL
 
int libgncmod_ofx_gnc_module_system_interface = 0
 
int libgncmod_ofx_gnc_module_current = 0
 
int libgncmod_ofx_gnc_module_revision = 0
 
int libgncmod_ofx_gnc_module_age = 0
 

Non-GUI Functions

GdkPixbuf * gen_probability_pixbuf (gint score, GNCImportSettings *settings, GtkWidget *widget)
 This function generates a new pixmap representing a match score. More...
 
void gnc_import_find_split_matches (GNCImportTransInfo *trans_info, gint process_threshold, double fuzzy_amount_difference, gint match_date_hardlimit)
 /brief Iterate through all splits of the originating account of the given transaction, and find all matching splits there. More...
 
gboolean gnc_import_process_trans_item (GncImportMatchMap *matchmap, GNCImportTransInfo *trans_info)
 /brief – Processes one match according to its selected action. More...
 
gboolean gnc_import_exists_online_id (Transaction *trans)
 Checks whether the given transaction's online_id already exists in its parent account. More...
 
void gnc_import_TransInfo_init_matches (GNCImportTransInfo *trans_info, GNCImportSettings *settings)
 Iterates through all splits of the originating account of trans_info. More...
 

Getters/Setters for GNCImportTransInfo

GList * gnc_import_TransInfo_get_match_list (const GNCImportTransInfo *info)
 Returns the stored list of possible matches. More...
 
Transaction * gnc_import_TransInfo_get_trans (const GNCImportTransInfo *info)
 Returns the transaction of this TransInfo. More...
 
gboolean gnc_import_TransInfo_is_balanced (const GNCImportTransInfo *info)
 Returns if the transaction stored in the TransInfo is currently balanced. More...
 
Split * gnc_import_TransInfo_get_fsplit (const GNCImportTransInfo *info)
 Returns the first split of the transaction of this TransInfo. More...
 
GNCImportMatchInfognc_import_TransInfo_get_selected_match (const GNCImportTransInfo *info)
 Returns the currently selected match in this TransInfo. More...
 
void gnc_import_TransInfo_set_selected_match_info (GNCImportTransInfo *info, GNCImportMatchInfo *match, gboolean selected_manually)
 Sets the currently selected match in this TransInfo. More...
 
gboolean gnc_import_TransInfo_get_match_selected_manually (const GNCImportTransInfo *info)
 Returns if the currently selected match was selected by the user. More...
 
GNCImportAction gnc_import_TransInfo_get_action (const GNCImportTransInfo *info)
 Returns the currently selected action for this TransInfo. More...
 
void gnc_import_TransInfo_set_action (GNCImportTransInfo *info, GNCImportAction action)
 Set the action for this TransInfo. More...
 
Accountgnc_import_TransInfo_get_destacc (const GNCImportTransInfo *info)
 Returns the 'other account' of this transaction. More...
 
void gnc_import_TransInfo_set_destacc (GNCImportTransInfo *info, Account *acc, gboolean selected_manually)
 Set the 'other account' of this transaction (used for auto-balance if needed). More...
 
gboolean gnc_import_TransInfo_get_destacc_selected_manually (const GNCImportTransInfo *info)
 Returns if the currently selected destination account for auto-matching was selected by the user. More...
 
guint32 gnc_import_TransInfo_get_ref_id (const GNCImportTransInfo *info)
 Returns the reference id for this TransInfo. More...
 
void gnc_import_TransInfo_set_ref_id (GNCImportTransInfo *info, guint32 ref_id)
 Set the reference id for this TransInfo. More...
 
void gnc_import_TransInfo_delete (GNCImportTransInfo *info)
 Destructor.
 
GNCImportTransInfo * gnc_import_TransInfo_new (Transaction *trans, GncImportMatchMap *matchmap)
 Create a new object of GNCImportTransInfo here. More...
 
gboolean gnc_import_TransInfo_refresh_destacc (GNCImportTransInfo *transaction_info, GncImportMatchMap *matchmap)
 Try to automatch a given transaction to a destination account.
 

Getters/Setters for GNCImportMatchInfo

Split * gnc_import_MatchInfo_get_split (const GNCImportMatchInfo *info)
 Get the split ('this-side split') of this MatchInfo. More...
 
gint gnc_import_MatchInfo_get_probability (const GNCImportMatchInfo *info)
 Get the probability (confidence level) of this MatchInfo. More...
 

Getters/Setters for GNCImportSettings

double gnc_import_Settings_get_fuzzy_amount (GNCImportSettings *settings)
 Return the allowed amount range for fuzzy amount matching. More...
 
gboolean gnc_import_Settings_get_action_skip_enabled (GNCImportSettings *settings)
 Return the selected action is enable state.
 
gboolean gnc_import_Settings_get_action_add_enabled (GNCImportSettings *settings)
 Return the selected action is enable state.
 
gboolean gnc_import_Settings_get_action_update_enabled (GNCImportSettings *settings)
 Return the selected action is enable state.
 
gboolean gnc_import_Settings_get_action_clear_enabled (GNCImportSettings *settings)
 Return the selected action is enable state.
 
gint gnc_import_Settings_get_clear_threshold (GNCImportSettings *settings)
 Return the selected threshold.
 
gint gnc_import_Settings_get_add_threshold (GNCImportSettings *settings)
 Return the selected threshold.
 
gint gnc_import_Settings_get_display_threshold (GNCImportSettings *settings)
 Return the selected threshold.
 
void gnc_import_Settings_set_match_date_hardlimit (GNCImportSettings *s, gint m)
 
gint gnc_import_Settings_get_match_date_hardlimit (const GNCImportSettings *settings)
 Returns the hard-limiting number of days that a matching split may differ. More...
 

Setter-getters

Setter and getter functions for the online_id field for Splits.

const gchar * gnc_import_get_acc_online_id (Account *account)
 
void gnc_import_set_acc_online_id (Account *account, const gchar *id)
 
const gchar * gnc_import_get_trans_online_id (Transaction *transaction)
 
void gnc_import_set_trans_online_id (Transaction *transaction, const gchar *id)
 
const gchar * gnc_import_get_split_online_id (Split *split)
 
void gnc_import_set_split_online_id (Split *split, const gchar *id)
 

Detailed Description

Function Documentation

◆ gen_probability_pixbuf()

GdkPixbuf * gen_probability_pixbuf ( gint  score,
GNCImportSettings *  settings,
GtkWidget *  widget 
)

This function generates a new pixmap representing a match score.

It is a series of vertical bars of different colors. -Below or at the add_threshold the bars are red -Above or at the clear_threshold the bars are green -Between the two threshold the bars are yellow

Parameters
scoreThe score for which to generate a pixmap.
settingsThe user settings from which to get the threshold
widgetThe parent widget in which the pixmap will eventually be added. Will be used to generate the colormap.

Definition at line 278 of file import-backend.c.

279 {
280  GdkPixbuf* retval = NULL;
281  gint i, j;
282  gint score;
283  const gint height = 15;
284  const gint width_each_bar = 7;
285  gchar * green_bar = ("bggggb ");
286  gchar * yellow_bar = ("byyyyb ");
287  gchar * red_bar = ("brrrrb ");
288  gchar * black_bar = ("bbbbbb ");
289  const gint width_first_bar = 1;
290  gchar * black_first_bar = ("b");
291  const gint num_colors = 5;
292  gchar * size_str;
293  gchar * none_color_str = g_strdup_printf(" c None");
294  gchar * green_color_str = g_strdup_printf("g c green");
295  gchar * yellow_color_str = g_strdup_printf("y c yellow");
296  gchar * red_color_str = g_strdup_printf("r c red");
297  gchar * black_color_str = g_strdup_printf("b c black");
298  gchar * xpm[2+num_colors+height];
299  gint add_threshold, clear_threshold;
300 
301  g_assert(settings);
302  g_assert(widget);
303  if (score_original < 0)
304  {
305  score = 0;
306  }
307  else
308  {
309  score = score_original;
310  }
311  size_str = g_strdup_printf("%d%s%d%s%d%s", (width_each_bar * score) + width_first_bar/*width*/, " ", height, " ", num_colors, " 1"/*characters per pixel*/);
312 
313  /*DEBUG("Begin");*/
314  xpm[0] = size_str;
315  xpm[1] = none_color_str;
316  xpm[2] = green_color_str;
317  xpm[3] = yellow_color_str;
318  xpm[4] = red_color_str;
319  xpm[5] = black_color_str;
320  add_threshold = gnc_import_Settings_get_add_threshold(settings);
321  clear_threshold = gnc_import_Settings_get_clear_threshold(settings);
322 
323  for (i = 0; i < height; i++)
324  {
325  xpm[num_colors+1+i] = g_new0(char, (width_each_bar * score) + width_first_bar + 1);
326  for (j = 0; j <= score; j++)
327  {
328  if (i == 0 || i == height - 1)
329  {
330  if (j == 0)
331  {
332  strcat(xpm[num_colors+1+i], black_first_bar);
333  }
334  else
335  {
336  strcat(xpm[num_colors+1+i], black_bar);
337  }
338  }
339  else
340  {
341  if (j == 0)
342  {
343  strcat(xpm[num_colors+1+i], black_first_bar);
344  }
345  else if (j <= add_threshold)
346  {
347  strcat(xpm[num_colors+1+i], red_bar);
348  }
349  else if (j >= clear_threshold)
350  {
351  strcat(xpm[num_colors+1+i], green_bar);
352  }
353  else
354  {
355  strcat(xpm[num_colors+1+i], yellow_bar);
356  }
357  }
358  }
359  }
360 
361  retval = gdk_pixbuf_new_from_xpm_data((const gchar **)xpm);
362  for (i = 0; i <= num_colors + height; i++)
363  {
364  /*DEBUG("free_loop i=%d%s%s",i,": ",xpm[i]);*/
365  g_free(xpm[i]);
366  }
367 
368  return retval;
369 }
gint gnc_import_Settings_get_clear_threshold(GNCImportSettings *settings)
Return the selected threshold.
gint gnc_import_Settings_get_add_threshold(GNCImportSettings *settings)
Return the selected threshold.

◆ gnc_file_log_replay()

void gnc_file_log_replay ( GtkWindow *  parent)

The gnc_file_log_replay() routine will pop up a standard file selection dialogue asking the user to pick a log file to replay.

If one is selected the the .log file is opened and read. It's contents are then silently merged in the current log file.

Definition at line 553 of file gnc-log-replay.c.

554 {
555  char *selected_filename;
556  char *default_dir;
557  char read_buf[256];
558  char *read_retval;
559  GtkFileFilter *filter;
560  FILE *log_file;
561  char * record_start_str = "===== START";
562  /* NOTE: This string must match src/engine/TransLog.c (sans newline) */
563  char * expected_header_orig = "mod\ttrans_guid\tsplit_guid\ttime_now\t"
564  "date_entered\tdate_posted\tacc_guid\tacc_name\tnum\tdescription\t"
565  "notes\tmemo\taction\treconciled\tamount\tvalue\tdate_reconciled";
566  static char *expected_header = NULL;
567 
568  /* Use g_strdup_printf so we don't get accidental tab -> space conversion */
569  if (!expected_header)
570  expected_header = g_strdup(expected_header_orig);
571 
572  qof_log_set_level(GNC_MOD_IMPORT, QOF_LOG_DEBUG);
573  ENTER(" ");
574 
575  /* Don't log the log replay. This would only result in redundant logs */
576  xaccLogDisable();
577 
578  default_dir = gnc_get_default_directory(GNC_PREFS_GROUP);
579 
580  filter = gtk_file_filter_new();
581  gtk_file_filter_set_name(filter, "*.log");
582  gtk_file_filter_add_pattern(filter, "*.[Ll][Oo][Gg]");
583  selected_filename = gnc_file_dialog(parent,
584  _("Select a .log file to replay"),
585  g_list_prepend(NULL, filter),
586  default_dir,
587  GNC_FILE_DIALOG_OPEN);
588  g_free(default_dir);
589 
590  if (selected_filename != NULL)
591  {
592  /* Remember the directory as the default. */
593  default_dir = g_path_get_dirname(selected_filename);
594  gnc_set_default_directory(GNC_PREFS_GROUP, default_dir);
595  g_free(default_dir);
596 
597  /*strncpy(file,selected_filename, 255);*/
598  DEBUG("Filename found: %s", selected_filename);
599  if (xaccFileIsCurrentLog(selected_filename))
600  {
601  g_warning("Cannot open the current log file: %s", selected_filename);
602  gnc_error_dialog(NULL,
603  /* Translators: %s is the file name. */
604  _("Cannot open the current log file: %s"),
605  selected_filename);
606  }
607  else
608  {
609  DEBUG("Opening selected file");
610  log_file = g_fopen(selected_filename, "r");
611  if (!log_file || ferror(log_file) != 0)
612  {
613  int err = errno;
614  perror("File open failed");
615  gnc_error_dialog(NULL,
616  /* Translation note:
617  * First argument is the filename,
618  * second argument is the error.
619  */
620  _("Failed to open log file: %s: %s"),
621  selected_filename,
622  strerror(err));
623  }
624  else
625  {
626  if ((read_retval = fgets(read_buf, sizeof(read_buf), log_file)) == NULL)
627  {
628  DEBUG("Read error or EOF");
629  gnc_info_dialog(NULL, "%s",
630  _("The log file you selected was empty."));
631  }
632  else
633  {
634  if (strncmp(expected_header, read_buf, strlen(expected_header)) != 0)
635  {
636  PERR("File header not recognised:\n%s", read_buf);
637  PERR("Expected:\n%s", expected_header);
638  gnc_error_dialog(NULL, "%s",
639  _("The log file you selected cannot be read. "
640  "The file header was not recognized."));
641  }
642  else
643  {
644  do
645  {
646  read_retval = fgets(read_buf, sizeof(read_buf), log_file);
647  /*DEBUG("Chunk read: %s",read_retval);*/
648  if (strncmp(record_start_str, read_buf, strlen(record_start_str)) == 0) /* If a record started */
649  {
650  process_trans_record(log_file);
651  }
652  }
653  while (feof(log_file) == 0);
654  }
655  }
656  fclose(log_file);
657  }
658  }
659  g_free(selected_filename);
660  }
661  /* Start logging again */
662  xaccLogEnable();
663 
664  LEAVE("");
665 }
void qof_log_set_level(QofLogModule log_module, QofLogLevel level)
Set the logging level of the given log_module.
Definition: qoflog.cpp:232
void xaccLogDisable(void)
document me
Definition: TransLog.c:95
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:260
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:242
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:266
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:276
gboolean xaccFileIsCurrentLog(const gchar *name)
Test a filename to see if it is the name of the current logfile.
Definition: TransLog.c:141
void xaccLogEnable(void)
document me
Definition: TransLog.c:99

◆ gnc_file_ofx_import()

void gnc_file_ofx_import ( GtkWindow *  parent)

The gnc_file_ofx_import() routine will pop up a standard file selection dialogue asking the user to pick a OFX/QFX file.

If one is selected the the OFX file is opened and read. It's contents are merged into the existing session (if any). The current session continues to remain open for editing.

Definition at line 991 of file gnc-ofx-import.c.

992 {
993  extern int ofx_PARSER_msg;
994  extern int ofx_DEBUG_msg;
995  extern int ofx_WARNING_msg;
996  extern int ofx_ERROR_msg;
997  extern int ofx_INFO_msg;
998  extern int ofx_STATUS_msg;
999  char *selected_filename;
1000  char *default_dir;
1001  LibofxContextPtr libofx_context = libofx_get_new_context();
1002 
1003  ofx_PARSER_msg = false;
1004  ofx_DEBUG_msg = false;
1005  ofx_WARNING_msg = true;
1006  ofx_ERROR_msg = true;
1007  ofx_INFO_msg = true;
1008  ofx_STATUS_msg = false;
1009 
1010  DEBUG("gnc_file_ofx_import(): Begin...\n");
1011 
1012  default_dir = gnc_get_default_directory(GNC_PREFS_GROUP);
1013  selected_filename = gnc_file_dialog(parent,
1014  _("Select an OFX/QFX file to process"),
1015  NULL,
1016  default_dir,
1017  GNC_FILE_DIALOG_IMPORT);
1018  g_free(default_dir);
1019 
1020  if (selected_filename != NULL)
1021  {
1022 #ifdef G_OS_WIN32
1023  gchar *conv_name;
1024 #endif
1025 
1026  /* Remember the directory as the default. */
1027  default_dir = g_path_get_dirname(selected_filename);
1028  gnc_set_default_directory(GNC_PREFS_GROUP, default_dir);
1029  g_free(default_dir);
1030 
1031  /*strncpy(file,selected_filename, 255);*/
1032  DEBUG("Filename found: %s", selected_filename);
1033 
1034  /* Create the Generic transaction importer GUI. */
1035  gnc_ofx_importer_gui = gnc_gen_trans_list_new (GTK_WIDGET(parent), NULL, FALSE, 42);
1036 
1037  /* Look up the needed preferences */
1038  auto_create_commodity =
1039  gnc_prefs_get_bool (GNC_PREFS_GROUP_IMPORT, GNC_PREF_AUTO_COMMODITY);
1040 
1041  /* Initialize libofx */
1042 
1043  /*ofx_set_statement_cb(libofx_context, ofx_proc_statement_cb, 0);*/
1044  ofx_set_account_cb(libofx_context, ofx_proc_account_cb, 0);
1045  ofx_set_transaction_cb(libofx_context, ofx_proc_transaction_cb, parent);
1046  ofx_set_security_cb(libofx_context, ofx_proc_security_cb, 0);
1047  /*ofx_set_status_cb(libofx_context, ofx_proc_status_cb, 0);*/
1048 
1049 #ifdef G_OS_WIN32
1050  conv_name = g_win32_locale_filename_from_utf8(selected_filename);
1051  g_free(selected_filename);
1052  selected_filename = conv_name;
1053 #endif
1054 
1055  DEBUG("Opening selected file");
1056  libofx_proc_file(libofx_context, selected_filename, AUTODETECT);
1057  g_free(selected_filename);
1058  }
1059 
1060  if (ofx_created_commodites)
1061  {
1062  /* FIXME: Present some result window about the newly created
1063  * commodities */
1064  g_warning("Created %d new commodities during import", g_list_length(ofx_created_commodites));
1065  g_list_free(ofx_created_commodites);
1066  ofx_created_commodites = NULL;
1067  }
1068  else
1069  {
1070  //g_warning("No new commodities created");
1071  }
1072 }
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:260
#define GNC_PREFS_GROUP_IMPORT
The preferences used by the importer.
GNCImportMainMatcher * gnc_gen_trans_list_new(GtkWidget *parent, const gchar *heading, gboolean all_from_same_account, gint match_date_hardlimit)
Create a new generic transaction dialog window and return it.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
Definition: gnc-prefs.c:183

◆ gnc_gen_trans_assist_new()

GNCImportMainMatcher * gnc_gen_trans_assist_new ( GtkWidget *  parent,
GtkWidget *  assistant_page,
const gchar *  heading,
gboolean  all_from_same_account,
gint  match_date_hardlimit 
)

Add the Transaction matcher to an existing page of an assistant.

Must be called with the parent widget, ie. a vbox that the transaction matcher will be packed into. The data structure GNCImportMainMatcher is returned.

Parameters
parentThe parent widget
assistant_pageThe parent widget. This is the place the transaction matcher will be packed into.
headingThe heading label in the Importer window. May be NULL.
all_from_same_accountSet this to TRUE if ALL the transaction that will be added with gnc_gen_trans_list_add_trans are from the same source account. This will cause the account column to be hidden.
match_date_hardlimitThe number of days that a matching split may differ from the given transaction before it is discarded immediately. In other words, any split that is more distant from the given transaction than this match_date_hardlimit days will be ignored altogether. For use cases without paper checks (e.g. HBCI), values like 14 (days) might be appropriate, whereas for use cases with paper checks (e.g. OFX, QIF), values like 42 (days) seem more appropriate.
Returns
A pointer to the GNCImportMainMatcher which has been setup.

Definition at line 593 of file import-main-matcher.c.

596 {
597  GNCImportMainMatcher *info;
598  GtkBuilder *builder;
599  GtkWidget *heading_label;
600  GtkWidget *box;
601  gboolean show_update;
602  GtkStyleContext *stylectxt;
603  GdkRGBA color;
604 
605  info = g_new0 (GNCImportMainMatcher, 1);
606  info->pending_matches = gnc_import_PendingMatches_new();
607  info->main_widget = GTK_WIDGET(parent);
608 
609  /* Initialize user Settings. */
610  info->user_settings = gnc_import_Settings_new ();
611  gnc_import_Settings_set_match_date_hardlimit (info->user_settings, match_date_hardlimit);
612 
613  stylectxt = gtk_widget_get_style_context (GTK_WIDGET(parent));
614  gtk_style_context_get_color (stylectxt, GTK_STATE_FLAG_NORMAL, &color);
615  info->dark_theme = gnc_is_dark_theme (&color);
616 
617  /* load the interface */
618  builder = gtk_builder_new();
619  gnc_builder_add_from_file (builder, "dialog-import.glade", "transaction_matcher_content");
620  if (builder == NULL)
621  {
622  PERR("Error opening the glade builder interface");
623  }
624  /* Pack content into Assistant page widget */
625  box = GTK_WIDGET(gtk_builder_get_object (builder, "transaction_matcher_content"));
626  gtk_box_pack_start (GTK_BOX(assistant_page), box, TRUE, TRUE, 6);
627 
628  /* Get the view */
629  info->view = GTK_TREE_VIEW(gtk_builder_get_object (builder, "downloaded_view"));
630  g_assert (info->view != NULL);
631 
632  show_update = gnc_import_Settings_get_action_update_enabled(info->user_settings);
633  gnc_gen_trans_init_view(info, all_from_same_account, show_update);
634  heading_label = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label"));
635  g_assert (heading_label != NULL);
636 
637  if (heading)
638  gtk_label_set_text (GTK_LABEL (heading_label), heading);
639 
640  info->transaction_processed_cb = NULL;
641 
642  /* Connect the signals */
643  gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, info);
644 
645  g_object_unref(G_OBJECT(builder));
646 
647  return info;
648 }
GNCImportSettings * gnc_import_Settings_new(void)
Allocates a new GNCImportSettings object, and initialize it with the appropriate user prefs...
gboolean gnc_is_dark_theme(GdkRGBA *fg_color)
Return whether the current gtk theme is a dark one.
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:242
void gnc_import_Settings_set_match_date_hardlimit(GNCImportSettings *s, gint m)
gboolean gnc_import_Settings_get_action_update_enabled(GNCImportSettings *settings)
Return the selected action is enable state.

◆ gnc_gen_trans_assist_start()

void gnc_gen_trans_assist_start ( GNCImportMainMatcher *  info)

This starts the import process for transaction from an assistant.

assistant button callback.

Parameters
info.A pointer to a the GNCImportMainMatcher structure.

Definition at line 650 of file import-main-matcher.c.

651 {
652  on_matcher_ok_clicked (NULL, info);
653 }

◆ gnc_gen_trans_list_add_tp_cb()

void gnc_gen_trans_list_add_tp_cb ( GNCImportMainMatcher *  info,
GNCTransactionProcessedCB  trans_processed_cb,
gpointer  user_data 
)

Add transaction processed callback to the transaction importer.

Parameters
infoThe Transaction Importer to use.
trans_processed_cbThe callback function.

Definition at line 659 of file import-main-matcher.c.

662 {
663  info->user_data = user_data;
664  info->transaction_processed_cb = trans_processed_cb;
665 }

◆ gnc_gen_trans_list_add_trans()

void gnc_gen_trans_list_add_trans ( GNCImportMainMatcher *  gui,
Transaction *  trans 
)

Add a newly imported Transaction to the Transaction Importer.

The Importer takes over ownership of the passed transaction.

Parameters
guiThe Transaction Importer to use.
transThe Transaction to add. The must contain at least one split, and this split must have been associated with an account Only the first split will be used for matching. The transaction must NOT be committed. The Importer takes over ownership of the passed transaction.

Definition at line 918 of file import-main-matcher.c.

919 {
921  return;
922 }/* end gnc_import_add_trans() */
void gnc_gen_trans_list_add_trans_with_ref_id(GNCImportMainMatcher *gui, Transaction *trans, guint32 ref_id)
Add a newly imported Transaction to the Transaction Importer and provide an external reference id for...

◆ gnc_gen_trans_list_add_trans_with_ref_id()

void gnc_gen_trans_list_add_trans_with_ref_id ( GNCImportMainMatcher *  gui,
Transaction *  trans,
guint32  ref_id 
)

Add a newly imported Transaction to the Transaction Importer and provide an external reference id for it.

The Importer takes over ownership of the passed transaction.

Parameters
guiThe Transaction Importer to use.
transThe Transaction to add. The must contain at least one split, and this split must have been associated with an account Only the first split will be used for matching. The transaction must NOT be committed. The Importer takes over ownership of the passed transaction.
ref_idReference id which links an external object to the transaction.

Definition at line 924 of file import-main-matcher.c.

925 {
926  GNCImportTransInfo * transaction_info = NULL;
927  GtkTreeModel *model;
928  GtkTreeIter iter;
929  GNCImportMatchInfo *selected_match;
930  gboolean match_selected_manually;
931  g_assert (gui);
932  g_assert (trans);
933 
934 
935  if (gnc_import_exists_online_id (trans))
936  return;
937  else
938  {
939  transaction_info = gnc_import_TransInfo_new(trans, NULL);
940  gnc_import_TransInfo_set_ref_id(transaction_info, ref_id);
941 
942  gnc_import_TransInfo_init_matches(transaction_info,
943  gui->user_settings);
944 
945  selected_match =
946  gnc_import_TransInfo_get_selected_match(transaction_info);
947  match_selected_manually =
949 
950  if (selected_match)
951  gnc_import_PendingMatches_add_match(gui->pending_matches,
952  selected_match,
953  match_selected_manually);
954 
955  model = gtk_tree_view_get_model(gui->view);
956  gtk_list_store_append(GTK_LIST_STORE(model), &iter);
957  refresh_model_row (gui, model, &iter, transaction_info);
958  }
959  return;
960 }/* end gnc_import_add_trans_with_ref_id() */
GNCImportTransInfo * gnc_import_TransInfo_new(Transaction *trans, GncImportMatchMap *matchmap)
Create a new object of GNCImportTransInfo here.
void gnc_import_TransInfo_set_ref_id(GNCImportTransInfo *info, guint32 ref_id)
Set the reference id for this TransInfo.
void gnc_import_TransInfo_init_matches(GNCImportTransInfo *trans_info, GNCImportSettings *settings)
Iterates through all splits of the originating account of trans_info.
gboolean gnc_import_exists_online_id(Transaction *trans)
Checks whether the given transaction&#39;s online_id already exists in its parent account.
gboolean gnc_import_TransInfo_get_match_selected_manually(const GNCImportTransInfo *info)
Returns if the currently selected match was selected by the user.
GNCImportMatchInfo * gnc_import_TransInfo_get_selected_match(const GNCImportTransInfo *info)
Returns the currently selected match in this TransInfo.

◆ gnc_gen_trans_list_delete()

void gnc_gen_trans_list_delete ( GNCImportMainMatcher *  info)

Deletes the given object.

Definition at line 102 of file import-main-matcher.c.

103 {
104  GtkTreeModel *model;
105  GtkTreeIter iter;
106  GNCImportTransInfo *trans_info;
107 
108  if (info == NULL)
109  return;
110 
111  model = gtk_tree_view_get_model(info->view);
112  if (gtk_tree_model_get_iter_first(model, &iter))
113  {
114  do
115  {
116  gtk_tree_model_get(model, &iter,
117  DOWNLOADED_COL_DATA, &trans_info,
118  -1);
119 
120  if (info->transaction_processed_cb)
121  {
122  info->transaction_processed_cb(trans_info,
123  FALSE,
124  info->user_data);
125  }
126 
127  gnc_import_TransInfo_delete(trans_info);
128  }
129  while (gtk_tree_model_iter_next (model, &iter));
130  }
131 
132  if (GTK_IS_DIALOG(info->main_widget))
133  {
134  gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(info->main_widget));
135  gnc_import_Settings_delete (info->user_settings);
136  gtk_widget_destroy (GTK_WIDGET (info->main_widget));
137  }
138  else
139  gnc_import_Settings_delete (info->user_settings);
140  g_free (info);
141 }
void gnc_import_TransInfo_delete(GNCImportTransInfo *info)
Destructor.
void gnc_import_Settings_delete(GNCImportSettings *settings)
Destructor.

◆ gnc_gen_trans_list_new()

GNCImportMainMatcher * gnc_gen_trans_list_new ( GtkWidget *  parent,
const gchar *  heading,
gboolean  all_from_same_account,
gint  match_date_hardlimit 
)

Create a new generic transaction dialog window and return it.

Parameters
parentThe parent GtkWidget. May be NULL.
headingThe heading label in the Importer window. May be NULL.
all_from_same_accountSet this to TRUE if ALL the transaction that will be added with gnc_gen_trans_list_add_trans are from the same source account. This will cause the account column to be hidden.
match_date_hardlimitThe number of days that a matching split may differ from the given transaction before it is discarded immediately. In other words, any split that is more distant from the given transaction than this match_date_hardlimit days will be ignored altogether. For use cases without paper checks (e.g. HBCI), values like 14 (days) might be appropriate, whereas for use cases with paper checks (e.g. OFX, QIF), values like 42 (days) seem more appropriate.
Returns
A pointer to the GNCImportMainMatcher which has been setup.

Definition at line 525 of file import-main-matcher.c.

529 {
530  GNCImportMainMatcher *info;
531  GtkBuilder *builder;
532  GtkWidget *heading_label;
533  GtkWidget *box, *pbox;
534  gboolean show_update;
535  GtkStyleContext *stylectxt;
536  GdkRGBA color;
537 
538  info = g_new0 (GNCImportMainMatcher, 1);
539  info->pending_matches = gnc_import_PendingMatches_new();
540 
541  /* Initialize user Settings. */
542  info->user_settings = gnc_import_Settings_new ();
543  gnc_import_Settings_set_match_date_hardlimit (info->user_settings, match_date_hardlimit);
544 
545  stylectxt = gtk_widget_get_style_context (GTK_WIDGET(parent));
546  gtk_style_context_get_color (stylectxt, GTK_STATE_FLAG_NORMAL, &color);
547  info->dark_theme = gnc_is_dark_theme (&color);
548 
549  /* Initialize the GtkDialog. */
550  builder = gtk_builder_new();
551  gnc_builder_add_from_file (builder, "dialog-import.glade", "transaction_matcher_dialog");
552  gnc_builder_add_from_file (builder, "dialog-import.glade", "transaction_matcher_content");
553  info->main_widget = GTK_WIDGET(gtk_builder_get_object (builder, "transaction_matcher_dialog"));
554  g_assert (info->main_widget != NULL);
555 
556  /* Pack the content into the dialog vbox */
557  pbox = GTK_WIDGET(gtk_builder_get_object (builder, "transaction_matcher_vbox"));
558  box = GTK_WIDGET(gtk_builder_get_object (builder, "transaction_matcher_content"));
559  gtk_box_pack_start( GTK_BOX(pbox), box, TRUE, TRUE, 0);
560 
561  /* Get the view */
562  info->view = GTK_TREE_VIEW(gtk_builder_get_object (builder, "downloaded_view"));
563  g_assert (info->view != NULL);
564 
565  show_update = gnc_import_Settings_get_action_update_enabled(info->user_settings);
566  gnc_gen_trans_init_view(info, all_from_same_account, show_update);
567  heading_label = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label"));
568  g_assert (heading_label != NULL);
569 
570  if (parent)
571  gtk_window_set_transient_for (GTK_WINDOW (info->main_widget), GTK_WINDOW (parent));
572 
573  if (heading)
574  gtk_label_set_text (GTK_LABEL (heading_label), heading);
575 
576  gnc_restore_window_size(GNC_PREFS_GROUP, GTK_WINDOW(info->main_widget));
577  gtk_widget_show_all (GTK_WIDGET (info->main_widget));
578 
579  info->transaction_processed_cb = NULL;
580 
581  /* Connect the signals */
582  gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, info);
583 
584  g_object_unref(G_OBJECT(builder));
585 
586  return info;
587 }
GNCImportSettings * gnc_import_Settings_new(void)
Allocates a new GNCImportSettings object, and initialize it with the appropriate user prefs...
gboolean gnc_is_dark_theme(GdkRGBA *fg_color)
Return whether the current gtk theme is a dark one.
void gnc_import_Settings_set_match_date_hardlimit(GNCImportSettings *s, gint m)
gboolean gnc_import_Settings_get_action_update_enabled(GNCImportSettings *settings)
Return the selected action is enable state.

◆ gnc_gen_trans_list_run()

gboolean gnc_gen_trans_list_run ( GNCImportMainMatcher *  info)

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.

Definition at line 667 of file import-main-matcher.c.

668 {
669  gboolean result;
670 
671  /* DEBUG("Begin"); */
672  result = gtk_dialog_run (GTK_DIALOG (info->main_widget));
673  /* DEBUG("Result was %d", result); */
674 
675  /* No destroying here since the dialog was already destroyed through
676  the ok_clicked handlers. */
677 
678  return result;
679 }

◆ gnc_import_account_assist_disable()

void gnc_import_account_assist_disable ( AccountPickerDialog picker,
gboolean  disable 
)

Must be called with an AccountPickerDialog structure allready setup.

Set the sensitivity of the account picker to disable input.

Parameters
Accountpicker Dialog structure, AccountPickerDialog
TRUEto make picker insensitve.

Definition at line 482 of file import-account-matcher.c.

483 {
484  gtk_widget_set_sensitive (picker->account_tree_sw, !disable);
485  gtk_widget_set_sensitive (picker->new_button, !disable);
486 }

◆ gnc_import_account_assist_setup()

AccountPickerDialog * gnc_import_account_assist_setup ( GtkWidget *  parent)

Must be called with the parent widget, ie.

a vbox that the account picker dialog will be packed into. The data structure AccountPickerDialog is initialised and default values populated.

Parameters
parentThe parent widget. This is the place the account picker dialog will be packed into.
Returns
A pointer to the AccountPickerDialog which has been setup.

Definition at line 428 of file import-account-matcher.c.

429 {
430  AccountPickerDialog * picker;
431  GtkBuilder *builder;
432  GtkWidget *box, *h_box;
433 
434  /* Init the account picker structure */
435  picker = gnc_import_new_account_picker();
436 
437  /* load the interface */
438  builder = gtk_builder_new();
439  gnc_builder_add_from_file (builder, "dialog-import.glade", "account_picker_content");
440  /* connect the signals in the interface */
441  if (builder == NULL)
442  {
443  PERR("Error opening the glade builder interface");
444  }
445 
446  picker->assistant = gtk_widget_get_parent(parent);
447  /* Pack content into Assistant page widget */
448  box = GTK_WIDGET(gtk_builder_get_object (builder, "account_picker_content"));
449  gtk_box_pack_start( GTK_BOX(parent), box, TRUE, TRUE, 6);
450 
451  picker->account_tree_sw = GTK_WIDGET(gtk_builder_get_object (builder, "account_tree_sw"));
452  picker->account_online_id_label = GTK_WIDGET(gtk_builder_get_object (builder, "online_id_label"));
453 
454  /* Add the New Account Button */
455  picker->new_button = gtk_button_new_with_mnemonic (_("_New Account"));
456 
457  h_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
458  gtk_box_set_homogeneous (GTK_BOX (h_box), TRUE);
459 
460  gtk_box_pack_start(GTK_BOX(h_box), picker->new_button, FALSE, FALSE, 0);
461  gtk_box_pack_start( GTK_BOX(box), h_box, FALSE, FALSE, 6);
462  gtk_widget_show (picker->new_button);
463  g_signal_connect(picker->new_button, "clicked",
464  G_CALLBACK(gnc_import_add_account), picker);
465 
466  build_acct_tree(picker);
467 
468  g_signal_connect(picker->account_tree, "row-activated",
469  G_CALLBACK(account_tree_row_activated_cb), picker);
470 
471  g_object_unref(G_OBJECT(builder));
472  return picker;
473 }
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:242

◆ gnc_import_account_assist_update()

Account * gnc_import_account_assist_update ( AccountPickerDialog picker)

Must be called with an AccountPickerDialog structure allready setup.

If an account with a matching online_id is found, which is allready present in the dialog structure, the function returns with a pointer to that account or NULL if not found.

Parameters
Accountpicker Dialog structure, AccountPickerDialog
Returns
A pointer to the found account, or NULL if account not found.

Definition at line 494 of file import-account-matcher.c.

495 {
496 #define ACCOUNT_DESCRIPTION_MAX_SIZE 255
497 
498  const gchar *retval_name = NULL;
499  gchar account_description_text[ACCOUNT_DESCRIPTION_MAX_SIZE] = "";
500 
501  ENTER("Default commodity received: %s", gnc_commodity_get_fullname( picker->new_account_default_commodity));
502  DEBUG("Default account type received: %s", xaccAccountGetTypeStr( picker->new_account_default_type));
503 
504  /*DEBUG("Looking for account with online_id: %s", picker->account_online_id_value);*/
505  if (picker->account_online_id_value != NULL)
506  {
507  picker->retAccount =
508  gnc_account_foreach_descendant_until(gnc_get_current_root_account (),
509  test_acct_online_id_match,
510  /* This argument will only be used as a "const char*" */
511  (void*)picker->account_online_id_value);
512  }
513 
514  if (picker->account_human_description != NULL)
515  {
516  strncat(account_description_text, picker->account_human_description,
517  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
518  strncat(account_description_text, "\n",
519  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
520  }
521  if (picker->account_online_id_value != NULL)
522  {
523  strncat(account_description_text, _("(Full account ID: "),
524  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
525  strncat(account_description_text, picker->account_online_id_value,
526  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
527  strncat(account_description_text, ")",
528  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
529  }
530  gtk_label_set_text(GTK_LABEL( picker->account_online_id_label), account_description_text);
531 
532  if (picker->default_account == NULL)
533  gnc_tree_view_account_set_selected_account(picker->account_tree, picker->retAccount);
534  else
535  gnc_tree_view_account_set_selected_account(picker->account_tree, picker->default_account);
536 
537  /*FIXME: DEBUG("WRITEME: Here we should check if an account type is compatible, currency matches, etc.\n"); */
538 
539  /*DEBUG("Return value: %p%s%s%s",picker->retAccount,", account name:",xaccAccountGetName(picker->retAccount),"\n");*/
540  retval_name = picker->retAccount ? xaccAccountGetName(picker->retAccount) : NULL;
541  LEAVE("Selected account %p, %s", picker->retAccount, retval_name ? retval_name : "(null)");
542  return picker->retAccount;
543 }
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:260
gpointer gnc_account_foreach_descendant_until(const Account *acc, AccountCb2 thunk, gpointer user_data)
This method will traverse all children of this accounts and their descendants, calling &#39;func&#39; on each...
Definition: Account.cpp:2972
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:266
const char * gnc_commodity_get_fullname(const gnc_commodity *cm)
Retrieve the full name for the specified commodity.
void gnc_tree_view_account_set_selected_account(GncTreeViewAccount *view, Account *account)
This function selects an account in the account tree view.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:276
const char * xaccAccountGetName(const Account *acc)
Get the account&#39;s name.
Definition: Account.cpp:3024
const char * xaccAccountGetTypeStr(GNCAccountType type)
The xaccAccountGetTypeStr() routine returns a string suitable for use in the GUI/Interface.
Definition: Account.cpp:4126

◆ gnc_import_exists_online_id()

gboolean gnc_import_exists_online_id ( Transaction *  trans)

Checks whether the given transaction's online_id already exists in its parent account.

The given transaction has to be open for editing. If a matching online_id exists, the transaction is destroyed (!) and TRUE is returned, otherwise FALSE is returned.

Parameters
transThe transaction for which to check for an existing online_id.

Definition at line 1130 of file import-backend.c.

1131 {
1132  gboolean online_id_exists = FALSE;
1133  Account *dest_acct;
1134  Split *source_split;
1135 
1136  /* Look for an online_id in the first split */
1137  source_split = xaccTransGetSplit(trans, 0);
1138  g_assert(source_split);
1139 
1140  /* DEBUG("%s%d%s","Checking split ",i," for duplicates"); */
1141  dest_acct = xaccSplitGetAccount(source_split);
1142  online_id_exists = xaccAccountForEachTransaction(dest_acct,
1143  check_trans_online_id,
1144  source_split);
1145 
1146  /* If it does, abort the process for this transaction, since it is
1147  already in the system. */
1148  if (online_id_exists == TRUE)
1149  {
1150  DEBUG("%s", "Transaction with same online ID exists, destroying current transaction");
1151  xaccTransDestroy(trans);
1152  xaccTransCommitEdit(trans);
1153  }
1154  return online_id_exists;
1155 }
gint xaccAccountForEachTransaction(const Account *acc, TransactionCallback proc, void *data)
The xaccAccountForEachTransaction() routine will traverse all of the transactions in account and call...
Definition: Account.cpp:5047
Split * xaccTransGetSplit(const Transaction *trans, int i)
The xaccTransGetSplit() method returns a pointer to each of the splits in this transaction.
Definition: Transaction.c:2191
STRUCTS.
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:260
void xaccTransDestroy(Transaction *trans)
Destroys a transaction.
Definition: Transaction.c:1451
void xaccTransCommitEdit(Transaction *trans)
The xaccTransCommitEdit() method indicates that the changes to the transaction and its splits are com...
Definition: Transaction.c:1628
Account * xaccSplitGetAccount(const Split *s)
Returns the account of this split, which was set through xaccAccountInsertSplit().
Definition: Split.c:909

◆ gnc_import_find_split_matches()

void gnc_import_find_split_matches ( GNCImportTransInfo *  trans_info,
gint  process_threshold,
double  fuzzy_amount_difference,
gint  match_date_hardlimit 
)

/brief Iterate through all splits of the originating account of the given transaction, and find all matching splits there.

Iterate through all splits of the originating account of the given transaction, find all matching splits there, and store them in the GNCImportTransInfo structure.

Parameters
trans_infoThe TransInfo for which the corresponding matching existing transactions should be found.
process_thresholdEach match whose heuristics are smaller than this value is totally ignored.
fuzzy_amount_differenceFor fuzzy amount matching, a certain fuzzyness in the matching amount is allowed up to this value. May be e.g. 3.00 dollars for ATM fees, or 0.0 if you only want to allow exact matches.
match_date_hardlimitThe number of days that a matching split may differ from the given transaction before it is discarded immediately. In other words, any split that is more distant from the given transaction than this match_date_hardlimit days will be ignored altogether. For use cases without paper checks (e.g. HBCI), values like 14 (days) might be appropriate, whereas for use cases with paper checks (e.g. OFX, QIF), values like 42 (days) seem more appropriate.

Definition at line 807 of file import-backend.c.

811 {
812  GList * list_element;
813  Query *query = qof_query_create_for(GNC_ID_SPLIT);
814  g_assert (trans_info);
815 
816  /* Get list of splits of the originating account. */
817  {
818  /* We used to traverse *all* splits of the account by using
819  xaccAccountGetSplitList, which is a bad idea because 90% of these
820  splits are outside the date range that is interesting. We should
821  rather use a query according to the date region, which is
822  implemented here.
823  */
824  Account *importaccount =
826  time64 download_time = xaccTransGetDate (gnc_import_TransInfo_get_trans (trans_info));
827 
828  qof_query_set_book (query, gnc_get_current_book());
829  xaccQueryAddSingleAccountMatch (query, importaccount,
830  QOF_QUERY_AND);
831  xaccQueryAddDateMatchTT (query,
832  TRUE, download_time - match_date_hardlimit * 86400,
833  TRUE, download_time + match_date_hardlimit * 86400,
834  QOF_QUERY_AND);
835  list_element = qof_query_run (query);
836  /* Sigh. Doesn't help too much. We still create and run one query
837  for each imported transaction. Maybe it would improve
838  performance further if there is one single (master-)query at
839  the beginning, matching the full date range and all accounts in
840  question. However, this doesn't quite work because this function
841  here is called from each gnc_gen_trans_list_add_trans(), which
842  is called one at a time. Therefore the whole importer would
843  have to change its behaviour: Accept the imported txns via
844  gnc_gen_trans_list_add_trans(), and only when
845  gnc_gen_trans_list_run() is called, then calculate all the
846  different match candidates. That's too much work for now.
847  */
848  }
849 
850  /* Traverse that list, calling split_find_match on each one. Note
851  that xaccAccountForEachSplit is declared in Account.h but
852  implemented nowhere :-( */
853  while (list_element != NULL)
854  {
855  split_find_match (trans_info, list_element->data,
856  process_threshold, fuzzy_amount_difference);
857  list_element = g_list_next (list_element);
858  }
859 
860  qof_query_destroy (query);
861 }
time64 xaccTransGetDate(const Transaction *trans)
Retrieve the posted date of the transaction.
Definition: Transaction.c:2349
STRUCTS.
Split * gnc_import_TransInfo_get_fsplit(const GNCImportTransInfo *info)
Returns the first split of the transaction of this TransInfo.
Transaction * gnc_import_TransInfo_get_trans(const GNCImportTransInfo *info)
Returns the transaction of this TransInfo.
void qof_query_destroy(QofQuery *q)
Frees the resources associate with a Query object.
Definition: qofquery.cpp:993
void qof_query_set_book(QofQuery *q, QofBook *book)
Set the book to be searched.
Definition: qofquery.cpp:1309
GList * qof_query_run(QofQuery *q)
Perform the query, return the results.
Definition: qofquery.cpp:849
Account * xaccSplitGetAccount(const Split *s)
Returns the account of this split, which was set through xaccAccountInsertSplit().
Definition: Split.c:909
gint64 time64
Many systems, including Microsoft Windows and BSD-derived Unixes like Darwin, are retaining the int-3...
Definition: gnc-date.h:84

◆ gnc_import_match_picker_run_and_close()

void gnc_import_match_picker_run_and_close ( GtkWidget *  parent,
GNCImportTransInfo *  transaction_info,
GNCImportPendingMatches *  pending_matches 
)

Run a match_picker dialog so that the selected-MatchInfo in the given trans_info is updated accordingly.

Run a match_picker dialog where the user should pick the best match for 'one' given transaction, so that the selected-MatchInfo in the given trans_info is updated accordingly.

This functions will only return after the user clicked Ok, Cancel, or Window-Close.

This functions will only return after the user clicked Ok, Cancel, or Window-Close.

The dialog uses the same functionality as the one created through gnc_import_add_trans(), except that its two listviews are shown above one another, and the listview of downloaded transactions shows only one transaction, namely, the given trans_info.

This function is used from the gnc-gen-transaction code.

Parameters
parentThe parent widget
transaction_infoThe TransInfo for which the user is supposed to pick a matching transaction.
pending_matchesList of transactions

Definition at line 508 of file import-match-picker.c.

510 {
511  GNCImportMatchPicker *matcher;
512  gint response;
513  GNCImportMatchInfo *old;
514  gboolean old_selected_manually;
515  g_assert (transaction_info);
516 
517  /* Create a new match_picker, even though it's stored in a
518  transmatcher struct :-) */
519  matcher = g_new0(GNCImportMatchPicker, 1);
520 
521  matcher->pending_matches = pending_matches;
522 
523  /* DEBUG("Init match_picker"); */
524  init_match_picker_gui(parent, matcher);
525 
526  /* Append this single transaction to the view and select it */
527  downloaded_transaction_append(matcher, transaction_info);
528 
529  old = gnc_import_TransInfo_get_selected_match (transaction_info);
530  old_selected_manually =
532 
533  /* Let this dialog run and close. */
534  /*DEBUG("Right before run and close");*/
535  gtk_window_set_modal(GTK_WINDOW(matcher->transaction_matcher), TRUE);
536  response = gtk_dialog_run (GTK_DIALOG (matcher->transaction_matcher));
537 
538  gnc_save_window_size(GNC_PREFS_GROUP,
539  GTK_WINDOW (matcher->transaction_matcher));
540  gtk_widget_destroy (matcher->transaction_matcher);
541  /*DEBUG("Right after run and close");*/
542  /* DEBUG("Response was %d.", response); */
543  if (response == GTK_RESPONSE_OK && matcher->selected_match_info != old)
544  {
545  /* OK was pressed */
547  matcher->selected_match_info,
548  TRUE);
549 
550  gnc_import_PendingMatches_remove_match (pending_matches,
551  old,
552  old_selected_manually);
553  gnc_import_PendingMatches_add_match (pending_matches,
554  matcher->selected_match_info,
555  TRUE);
556  }
557 }
void gnc_import_TransInfo_set_selected_match_info(GNCImportTransInfo *info, GNCImportMatchInfo *match, gboolean selected_manually)
Sets the currently selected match in this TransInfo.
gboolean gnc_import_TransInfo_get_match_selected_manually(const GNCImportTransInfo *info)
Returns if the currently selected match was selected by the user.
GNCImportMatchInfo * gnc_import_TransInfo_get_selected_match(const GNCImportTransInfo *info)
Returns the currently selected match in this TransInfo.

◆ gnc_import_MatchInfo_get_probability()

gint gnc_import_MatchInfo_get_probability ( const GNCImportMatchInfo info)

Get the probability (confidence level) of this MatchInfo.

Parameters
infoCan be NULL, in which case the function returns 0

Definition at line 242 of file import-backend.c.

243 {
244  if (info)
245  {
246  return info->probability;
247  }
248  else
249  {
250  return 0;
251  }
252 }

◆ gnc_import_MatchInfo_get_split()

Split * gnc_import_MatchInfo_get_split ( const GNCImportMatchInfo info)

Get the split ('this-side split') of this MatchInfo.

Definition at line 235 of file import-backend.c.

236 {
237  g_assert (info);
238  return info->split;
239 }

◆ gnc_import_process_trans_item()

gboolean gnc_import_process_trans_item ( GncImportMatchMap matchmap,
GNCImportTransInfo *  trans_info 
)

/brief – Processes one match according to its selected action.

This function is intended to be called when the importer dialog is finished.

It should be called once for each imported transaction and processes each ImportTransInfo according to its selected action: For GNCImport_ADD, the transaction is added etc. etc.

Each successful match is also stored in the given ImportMatchMap, or, if that argument is NULL, in the ImportMatchMap of each originating account.

Parameters
matchmapThe ImportMatchMap where each match should be stored. May be NULL, in which case the ImportMatchMap of each account will be used.
trans_infoThe ImportTransInfo item to process.
Returns
TRUE if the item has been processed.

Definition at line 870 of file import-backend.c.

872 {
873  Split * other_split;
874  gnc_numeric imbalance_value;
875 
876  /* DEBUG("Begin"); */
877 
878  g_assert (trans_info);
879  /*DEBUG("Iteration %d, action %d, split %s", i,
880  trans_info->action,
881  xaccTransGetDescription (gnc_import_TransInfo_get_trans
882  (trans_info)))*/
883  switch (gnc_import_TransInfo_get_action (trans_info))
884  {
885  case GNCImport_SKIP:
886  return FALSE;
887  case GNCImport_ADD:
888  /* Transaction gets imported. */
889 
890  /* Is the transaction not balanced and there is a non-NULL destination account? */
891  if (gnc_import_TransInfo_is_balanced(trans_info) == FALSE
892  && gnc_import_TransInfo_get_destacc(trans_info) != NULL)
893  {
894  /* Create the 'other' split. */
895  Split *split =
897  (gnc_account_get_book
898  (gnc_import_TransInfo_get_destacc (trans_info)));
900  (gnc_import_TransInfo_get_trans (trans_info), split);
902  (gnc_import_TransInfo_get_destacc (trans_info), split);
903  /*xaccSplitSetBaseValue
904  (split,
905  gnc_numeric_neg(xaccTransGetImbalance
906  (gnc_import_TransInfo_get_trans (trans_info))),
907  xaccTransGetCurrency
908  (gnc_import_TransInfo_get_trans (trans_info)));*/
909  {
910  /* This is a quick workaround for the bug described in
911  http://gnucash.org/pipermail/gnucash-devel/2003-August/009982.html
912  Assume that importers won't create transactions involving two or more
913  currencies so we can use xaccTransGetImbalanceValue. */
914  imbalance_value =
916  (gnc_import_TransInfo_get_trans (trans_info)));
917  xaccSplitSetValue (split, imbalance_value);
918  xaccSplitSetAmount (split, imbalance_value);
919  }
920  /*xaccSplitSetMemo (split, _("Auto-Balance split"));
921  -- disabled due to popular request */
922  }
923 
925  /*Set reconcile date to today*/
927  gnc_time (NULL));
928  /* Done editing. */
930  return TRUE;
931  case GNCImport_UPDATE:
932  {
933  GNCImportMatchInfo *selected_match =
935 
936  /* If there is no selection, ignore this transaction. */
937  if (!selected_match)
938  {
939  PWARN("No matching translaction to be cleared was chosen. Imported transaction will be ignored.");
940  break;
941  }
942 
943  /* Transaction gets not imported but the matching one gets
944  updated and reconciled. */
945  if (gnc_import_MatchInfo_get_split(selected_match) == NULL)
946  {
947  PERR("The split I am trying to update and reconcile is NULL, shouldn't happen!");
948  }
949  else
950  {
951  /* Update and reconcile the matching transaction */
952  /*DEBUG("BeginEdit selected_match")*/
953  xaccTransBeginEdit(selected_match->trans);
954 
955  xaccTransSetDatePostedSecsNormalized(selected_match->trans,
957  gnc_import_TransInfo_get_fsplit(trans_info))));
958 
959  xaccSplitSetAmount(selected_match->split,
961  gnc_import_TransInfo_get_fsplit(trans_info)));
962  xaccSplitSetValue(selected_match->split,
964  gnc_import_TransInfo_get_fsplit(trans_info)));
965 
966  imbalance_value = xaccTransGetImbalanceValue(
967  gnc_import_TransInfo_get_trans(trans_info));
968  other_split = xaccSplitGetOtherSplit(selected_match->split);
969  if (!gnc_numeric_zero_p(imbalance_value) && other_split)
970  {
971  if (xaccSplitGetReconcile(other_split) == NREC)
972  {
973  imbalance_value = gnc_numeric_neg(imbalance_value);
974  xaccSplitSetValue(other_split, imbalance_value);
975  xaccSplitSetAmount(other_split, imbalance_value);
976  }
977  /* else GC will automatically insert a split to equity
978  to balance the transaction */
979  }
980 
981  xaccTransSetDescription(selected_match->trans,
983  gnc_import_TransInfo_get_trans(trans_info)));
984 
985  xaccTransSetNotes(selected_match->trans,
987  gnc_import_TransInfo_get_trans(trans_info)));
988 
989  if (xaccSplitGetReconcile(selected_match->split) == NREC)
990  {
991  xaccSplitSetReconcile(selected_match->split, CREC);
992  }
993 
994  /* Set reconcile date to today */
995  xaccSplitSetDateReconciledSecs(selected_match->split, gnc_time (NULL));
996 
997  /* Copy the online id to the reconciled transaction, so
998  the match will be remembered */
999  if (gnc_import_split_has_online_id(trans_info->first_split))
1000  {
1001  gnc_import_set_split_online_id(selected_match->split,
1002  gnc_import_get_split_online_id(trans_info->first_split));
1003  }
1004 
1005  /* Done editing. */
1006  /*DEBUG("CommitEdit selected_match")*/
1007  xaccTransCommitEdit(selected_match->trans);
1008 
1009  /* Store the mapping to the other account in the MatchMap. */
1010  matchmap_store_destination(matchmap, trans_info, TRUE);
1011 
1012  /* Erase the downloaded transaction */
1013  xaccTransDestroy(trans_info->trans);
1014  /*DEBUG("CommitEdit trans")*/
1015  xaccTransCommitEdit(trans_info->trans);
1016  /* Very important: Make sure the freed transaction is not freed again! */
1017  trans_info->trans = NULL;
1018  }
1019  }
1020  return TRUE;
1021  case GNCImport_CLEAR:
1022  {
1023  GNCImportMatchInfo *selected_match =
1025 
1026  /* If there is no selection, ignore this transaction. */
1027  if (!selected_match)
1028  {
1029  PWARN("No matching translaction to be cleared was chosen. Imported transaction will be ignored.");
1030  break;
1031  }
1032 
1033  /* Transaction gets not imported but the matching one gets
1034  reconciled. */
1035  if (gnc_import_MatchInfo_get_split (selected_match) == NULL)
1036  {
1037  PERR("The split I am trying to reconcile is NULL, shouldn't happen!");
1038  }
1039  else
1040  {
1041  /* Reconcile the matching transaction */
1042  /*DEBUG("BeginEdit selected_match")*/
1043  xaccTransBeginEdit(selected_match->trans);
1044 
1046  (selected_match->split) == NREC)
1048  (selected_match->split, CREC);
1049  /* Set reconcile date to today */
1051  (selected_match->split, gnc_time (NULL));
1052 
1053  /* Copy the online id to the reconciled transaction, so
1054  the match will be remembered */
1055  if (gnc_import_split_has_online_id(trans_info->first_split))
1056  gnc_import_set_split_online_id
1057  (selected_match->split,
1058  gnc_import_get_split_online_id(trans_info->first_split));
1059 
1060  /* Done editing. */
1061  /*DEBUG("CommitEdit selected_match")*/
1063  (selected_match->trans);
1064 
1065  /* Store the mapping to the other account in the MatchMap. */
1066  matchmap_store_destination (matchmap, trans_info, TRUE);
1067 
1068  /* Erase the downloaded transaction */
1069  xaccTransDestroy(trans_info->trans);
1070  /*DEBUG("CommitEdit trans")*/
1071  xaccTransCommitEdit(trans_info->trans);
1072  /* Very important: Make sure the freed transaction is not freed again! */
1073  trans_info->trans = NULL;
1074  }
1075  }
1076  return TRUE;
1077  default:
1078  DEBUG("Invalid GNCImportAction for this imported transaction.");
1079  break;
1080  }
1081  /*DEBUG("End");*/
1082  return FALSE;
1083 }
void xaccSplitSetValue(Split *s, gnc_numeric amt)
The xaccSplitSetValue() method sets the value of this split in the transaction&#39;s commodity.
Definition: Split.c:1238
#define xaccTransAppendSplit(t, s)
Add a split to the transaction.
Definition: Transaction.h:361
void xaccTransSetDatePostedSecsNormalized(Transaction *trans, time64 time)
This function sets the posted date of the transaction, specified by a time64 (see ctime(3))...
Definition: Transaction.c:1962
time64 xaccTransGetDate(const Transaction *trans)
Retrieve the posted date of the transaction.
Definition: Transaction.c:2349
gnc_numeric gnc_numeric_neg(gnc_numeric a)
Returns a newly created gnc_numeric that is the negative of the given gnc_numeric value...
void xaccTransSetNotes(Transaction *trans, const char *notes)
Sets the transaction Notes.
Definition: Transaction.c:2154
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:260
char xaccSplitGetReconcile(const Split *split)
Returns the value of the reconcile flag.
Definition: Split.c:1897
Split * gnc_import_TransInfo_get_fsplit(const GNCImportTransInfo *info)
Returns the first split of the transaction of this TransInfo.
void xaccTransSetDescription(Transaction *trans, const char *desc)
Sets the transaction Description.
Definition: Transaction.c:2122
Transaction * gnc_import_TransInfo_get_trans(const GNCImportTransInfo *info)
Returns the transaction of this TransInfo.
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
void xaccSplitSetReconcile(Split *split, char recn)
Set the reconcile flag.
Definition: Split.c:1743
Transaction * xaccSplitGetParent(const Split *split)
Returns the parent transaction of the split.
Definition: Split.c:1820
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:242
GNCImportAction gnc_import_TransInfo_get_action(const GNCImportTransInfo *info)
Returns the currently selected action for this TransInfo.
void xaccTransDestroy(Transaction *trans)
Destroys a transaction.
Definition: Transaction.c:1451
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:248
const char * xaccTransGetNotes(const Transaction *trans)
Gets the transaction Notes.
Definition: Transaction.c:2324
Split * gnc_import_MatchInfo_get_split(const GNCImportMatchInfo *info)
Get the split (&#39;this-side split&#39;) of this MatchInfo.
void xaccSplitSetAmount(Split *s, gnc_numeric amt)
The xaccSplitSetAmount() method sets the amount in the account&#39;s commodity that the split should have...
Definition: Split.c:1202
gnc_numeric xaccTransGetImbalanceValue(const Transaction *trans)
The xaccTransGetImbalanceValue() method returns the total value of the transaction.
Definition: Transaction.c:1029
const char * xaccTransGetDescription(const Transaction *trans)
Gets the transaction Description.
Definition: Transaction.c:2307
void xaccTransCommitEdit(Transaction *trans)
The xaccTransCommitEdit() method indicates that the changes to the transaction and its splits are com...
Definition: Transaction.c:1628
void xaccTransBeginEdit(Transaction *trans)
The xaccTransBeginEdit() method must be called before any changes are made to a transaction or any of...
Definition: Transaction.c:1429
#define CREC
The Split has been cleared.
Definition: Split.h:71
Split * xaccMallocSplit(QofBook *book)
Constructor.
Definition: Split.c:526
void xaccSplitSetDateReconciledSecs(Split *split, time64 secs)
Set the date on which this split was reconciled by specifying the time as time64. ...
Definition: Split.c:1769
gnc_numeric xaccSplitGetValue(const Split *split)
Returns the value of this split in the transaction&#39;s commodity.
Definition: Split.c:1910
#define xaccAccountInsertSplit(acc, s)
The xaccAccountInsertSplit() method will insert the indicated split into the indicated account...
Definition: Account.h:990
Split * xaccSplitGetOtherSplit(const Split *split)
The xaccSplitGetOtherSplit() is a convenience routine that returns the other of a pair of splits...
Definition: Split.c:2072
Account * gnc_import_TransInfo_get_destacc(const GNCImportTransInfo *info)
Returns the &#39;other account&#39; of this transaction.
time64 gnc_time(time64 *tbuf)
get the current local time
Definition: gnc-date.cpp:248
GNCImportMatchInfo * gnc_import_TransInfo_get_selected_match(const GNCImportTransInfo *info)
Returns the currently selected match in this TransInfo.
gboolean gnc_import_TransInfo_is_balanced(const GNCImportTransInfo *info)
Returns if the transaction stored in the TransInfo is currently balanced.
#define NREC
not reconciled or cleared
Definition: Split.h:74
gnc_numeric xaccSplitGetAmount(const Split *split)
Returns the amount of the split in the account&#39;s commodity.
Definition: Split.c:1904

◆ gnc_import_select_account()

Account * gnc_import_select_account ( GtkWidget *  parent,
const gchar *  account_online_id_value,
gboolean  auto_create,
const gchar *  account_human_description,
const gnc_commodity *  new_account_default_commodity,
GNCAccountType  new_account_default_type,
Account default_selection,
gboolean *  ok_pressed 
)

Must be called with a string containing a unique identifier for the account.

If an account with a matching online_id is found, the function immediately returns with a pointer to that account. Otherwise, the user is prompted to select a GnuCash account or create a new one (in both cases, the unique identifier is written to the account, so the user won't be prompted again). If the user refuses to select or create an account, NULL is returned.

Parameters
parentThe parent widget. Can be NULL.
account_online_id_valueThe string containing your unique account_id coming from some string of your module. This is the normal mode of operation. Can be NULL.

If account_online_id_value==NULL, you basically end up with an account selector that allows you to select an account whose GncGUID will be remembered elsewhere. You would fill account_human_description to tell the user what he is looking for. In this mode, the online_id field of the found account will not be touched. To use this mode, auto_create must NOT be set to 0.

Parameters
account_human_descriptionA human-readable description of the account. Can be NULL. If it is not NULL, it will be shown before the id in the account matching dialog. It will also be used as the default account name if a new account is created.
new_account_default_commodityDefault commodity of the new account. Can be NULL. If not NULL, it will be the account's commodity if a new account is created. Also, if not NULL, the function will also warn the user if the found or created account's commodity doesn't match.
new_account_default_typeDefault account type of a new account. Can be NULL. If not ACCT_TYPE_NONE, it will be the account's type if a new account is created. If not ACCT_TYPE_NONE, the function will also warn the user if the found or created account's commodity doesn't match.
auto_createOnly active if no account with the account_online_id_value could be found in gnucash, or if online-id was NULL. In that case, if auto_create is TRUE (nonzero), the user will be asked to create a new account. If auto_create is FALSE (zero), this function will simply return NULL but will neither select nor create any account.
default_selectionIf not NULL, that account will be pre-selected by default.
ok_pressedA pointer to gboolean. If non-NULL, whether or not the picker dialog was closed by the user pressing ok will be stored in the parameter. If no dialog was created by the gnc_import_select_account() call, TRUE is always returned.
Returns
A pointer to the found or created Account, or NULL if no account was found or created.

Definition at line 235 of file import-account-matcher.c.

243 {
244 #define ACCOUNT_DESCRIPTION_MAX_SIZE 255
245  AccountPickerDialog * picker;
246  gint response;
247  Account * retval = NULL;
248  const gchar *retval_name = NULL;
249  GtkBuilder *builder;
250  GtkWidget * online_id_label, *box, *pbox;
251  gchar account_description_text[ACCOUNT_DESCRIPTION_MAX_SIZE] = "";
252  gboolean ok_pressed_retval = FALSE;
253 
254  ENTER("Default commodity received: %s", gnc_commodity_get_fullname( new_account_default_commodity));
255  DEBUG("Default account type received: %s", xaccAccountGetTypeStr( new_account_default_type));
256  picker = g_new0(AccountPickerDialog, 1);
257 
258  picker->account_online_id_value = account_online_id_value;
259  picker->account_human_description = account_human_description;
260  picker->new_account_default_commodity = new_account_default_commodity;
261  picker->new_account_default_type = new_account_default_type;
262 
263  /*DEBUG("Looking for account with online_id: \"%s\"", account_online_id_value);*/
264  if (account_online_id_value != NULL)
265  {
266  retval =
267  gnc_account_foreach_descendant_until(gnc_get_current_root_account (),
268  test_acct_online_id_match,
269  /* This argument will only be used as a "const char*" */
270  (void*)account_online_id_value);
271 
272  /* BEGIN: try again without extra space at the end */
273  /*
274  * libofx, used for file import, generates online_id as
275  * ACCTID + space + ACCTKEY which differs from the online_id
276  * generated by aqbanking for online ofx transfer as ACCTID.
277  *
278  * If a gnucash account has been associated with an online_id
279  * via aqbanking data, it is not possible to construct an OFX
280  * file for gnucash import that matches the same online_id
281  * because even with no ACCTKEY in the file, there will be a
282  * trailing space.
283  *
284  * This is a hack to overcome that problem.
285  */
286  if ((retval == NULL) && g_str_has_suffix(account_online_id_value, " "))
287  {
288  gchar *trimmed = g_strndup(account_online_id_value, strlen(account_online_id_value) - 1);
289  if (trimmed)
290  {
292  gnc_get_current_root_account (),
293  test_acct_online_id_match,
294  (void *)trimmed);
295  }
296  g_free(trimmed);
297  }
298  /* END: try again without extra space at the end */
299  }
300  if (retval == NULL && auto_create != 0)
301  {
302  /* load the interface */
303  builder = gtk_builder_new();
304  gnc_builder_add_from_file (builder, "dialog-import.glade", "account_new_icon");
305  gnc_builder_add_from_file (builder, "dialog-import.glade", "account_picker_dialog");
306  gnc_builder_add_from_file (builder, "dialog-import.glade", "account_picker_content");
307  /* connect the signals in the interface */
308  if (builder == NULL)
309  {
310  PERR("Error opening the glade builder interface");
311  }
312  picker->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "account_picker_dialog"));
313  if (parent)
314  gtk_window_set_transient_for (GTK_WINDOW (picker->dialog),
315  GTK_WINDOW (parent));
316 
317  /* Pack the content into the dialog vbox */
318  pbox = GTK_WIDGET(gtk_builder_get_object (builder, "account_picker_vbox"));
319  box = GTK_WIDGET(gtk_builder_get_object (builder, "account_picker_content"));
320  gtk_box_pack_start( GTK_BOX(pbox), box, TRUE, TRUE, 0);
321 
322  picker->account_tree_sw = GTK_WIDGET(gtk_builder_get_object (builder, "account_tree_sw"));
323  online_id_label = GTK_WIDGET(gtk_builder_get_object (builder, "online_id_label"));
324 
325  //printf("gnc_import_select_account(): Fin get widget\n");
326 
327  if (account_human_description != NULL)
328  {
329  strncat(account_description_text, account_human_description,
330  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
331  strncat(account_description_text, "\n",
332  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
333  }
334  if (account_online_id_value != NULL)
335  {
336  strncat(account_description_text, _("(Full account ID: "),
337  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
338  strncat(account_description_text, account_online_id_value,
339  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
340  strncat(account_description_text, ")",
341  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
342  }
343  gtk_label_set_text((GtkLabel*)online_id_label, account_description_text);
344  build_acct_tree(picker);
345  gnc_tree_view_account_set_selected_account(picker->account_tree, default_selection);
346 
347  gtk_window_set_modal(GTK_WINDOW(picker->dialog), TRUE);
348  g_signal_connect(picker->account_tree, "row-activated",
349  G_CALLBACK(account_tree_row_activated_cb), picker);
350  do
351  {
352  response = gtk_dialog_run(GTK_DIALOG(picker->dialog));
353  switch (response)
354  {
355  case GNC_RESPONSE_NEW:
356  gnc_import_add_account(NULL, picker);
357  response = GTK_RESPONSE_OK;
358  /* no break */
359 
360  case GTK_RESPONSE_OK:
361  retval = gnc_tree_view_account_get_selected_account(picker->account_tree);
362  if (retval == NULL)
363  {
364  response = GNC_RESPONSE_NEW;
365  break;
366  }
367  if (retval)
368  retval_name = xaccAccountGetName(retval);
369  if (!retval_name)
370  retval_name = "(null)";
371  DEBUG("Selected account %p, %s", retval, retval_name);
372 
373  /* See if the selected account is a placeholder. */
374  if (retval && xaccAccountGetPlaceholder (retval))
375  {
376  gnc_error_dialog
377  (GTK_WINDOW (picker->dialog),
378  _("The account %s is a placeholder account and does not allow "
379  "transactions. Please choose a different account."),
380  retval_name);
381  response = GNC_RESPONSE_NEW;
382  break;
383  }
384 
385  if ( account_online_id_value != NULL)
386  {
387  gnc_import_set_acc_online_id(retval, account_online_id_value);
388  }
389  ok_pressed_retval = TRUE;
390  break;
391 
392  default:
393  ok_pressed_retval = FALSE;
394  break;
395  }
396  }
397  while (response == GNC_RESPONSE_NEW);
398 
399  g_object_unref(G_OBJECT(builder));
400  gtk_widget_destroy(picker->dialog);
401  }
402  else
403  {
404  retval_name = retval ? xaccAccountGetName(retval) : NULL;
405  ok_pressed_retval = TRUE; /* There was no dialog involved, so the computer "pressed" ok */
406  }
407  /*FIXME: DEBUG("WRITEME: gnc_import_select_account() Here we should check if account type is compatible, currency matches, etc.\n"); */
408  g_free(picker);
409  /*DEBUG("Return value: %p%s%s%s",retval,", account name:",xaccAccountGetName(retval),"\n");*/
410  if (ok_pressed != NULL)
411  {
412  *ok_pressed = ok_pressed_retval;
413  }
414  LEAVE("Selected account %p, %s", retval, retval_name ? retval_name : "(null)");
415  return retval;
416 }
STRUCTS.
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:260
gpointer gnc_account_foreach_descendant_until(const Account *acc, AccountCb2 thunk, gpointer user_data)
This method will traverse all children of this accounts and their descendants, calling &#39;func&#39; on each...
Definition: Account.cpp:2972
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:242
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:266
const char * gnc_commodity_get_fullname(const gnc_commodity *cm)
Retrieve the full name for the specified commodity.
void gnc_tree_view_account_set_selected_account(GncTreeViewAccount *view, Account *account)
This function selects an account in the account tree view.
gboolean xaccAccountGetPlaceholder(const Account *acc)
Get the "placeholder" flag for an account.
Definition: Account.cpp:3923
Account * gnc_tree_view_account_get_selected_account(GncTreeViewAccount *view)
This function returns the account associated with the selected item in the account tree view...
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:276
const char * xaccAccountGetName(const Account *acc)
Get the account&#39;s name.
Definition: Account.cpp:3024
const char * xaccAccountGetTypeStr(GNCAccountType type)
The xaccAccountGetTypeStr() routine returns a string suitable for use in the GUI/Interface.
Definition: Account.cpp:4126

◆ gnc_import_select_commodity()

gnc_commodity * gnc_import_select_commodity ( const char *  cusip,
gboolean  ask_on_unknown,
const char *  default_fullname,
const char *  default_mnemonic 
)

Must be called with a string containing a unique identifier for the commodity.

If an commodity with a matching cusip is found, the function immediately returns with a pointer to that commodity. Otherwise, the user may be prompted to select a GnuCash commodity or create a new one (in both cases, the cusip is written to the commodity's cusip field, overwriting anything that was there before.

Parameters
cusipThe string containing the code for which you want a matching commodity. A CUISP code or similar UNIQUE code. The stock ticker is NOT appropriate, unless you have no other option. Must be non-NULL.
ask_on_unknownIf the cusip value is unknown and this parameter is false (zero), the function returns NULL. Otherwise the user will be asked to select an existing or create a new commodity.
default_fullnameA human-readable description of the commodity, such as the stock name. Can be NULL. If it is not NULL, it will be shown to the user when selecting a commodity. It will also be used as the default if a new commodity is created.
default_mnemonicUsually the stock ticker or similar. Can be NULL. If it is not NULL, it will be shown to the user when selecting a commodity. It will also be used as the default if a new commodity is created.
Returns
A pointer to the found or created commodity, or NULL if no commodity was found or created.

Definition at line 53 of file import-commodity-matcher.c.

57 {
58  const gnc_commodity_table * commodity_table = gnc_get_current_commodities ();
59  gnc_commodity * retval = NULL;
60  gnc_commodity * tmp_commodity = NULL;
61  char * tmp_namespace = NULL;
62  GList * commodity_list = NULL;
63  GList * namespace_list = NULL;
64  DEBUG("Default fullname received: %s",
65  default_fullname ? default_fullname : "(null)");
66  DEBUG("Default mnemonic received: %s",
67  default_mnemonic ? default_mnemonic : "(null)");
68 
69  g_return_val_if_fail(cusip, NULL);
70  DEBUG("Looking for commodity with exchange_code: %s", cusip);
71 
72  g_assert(commodity_table);
73  namespace_list = gnc_commodity_table_get_namespaces(commodity_table);
74 
75 
76  namespace_list = g_list_first(namespace_list);
77  while ( namespace_list != NULL && retval == NULL)
78  {
79  tmp_namespace = namespace_list->data;
80  DEBUG("Looking at namespace %s", tmp_namespace);
81  commodity_list = gnc_commodity_table_get_commodities(commodity_table,
82  tmp_namespace);
83  commodity_list = g_list_first(commodity_list);
84  while ( commodity_list != NULL && retval == NULL)
85  {
86  const char* tmp_cusip = NULL;
87  tmp_commodity = commodity_list->data;
88  DEBUG("Looking at commodity %s",
89  gnc_commodity_get_fullname(tmp_commodity));
90  tmp_cusip = gnc_commodity_get_cusip(tmp_commodity);
91  if (tmp_cusip != NULL && cusip != NULL)
92  {
93  int len = strlen(cusip) > strlen(tmp_cusip) ? strlen(cusip) :
94  strlen(tmp_cusip);
95  if (strncmp(tmp_cusip, cusip, len) == 0)
96  {
97  retval = tmp_commodity;
98  DEBUG("Commodity %s%s",
99  gnc_commodity_get_fullname(retval), " matches.");
100  }
101  }
102  commodity_list = g_list_next(commodity_list);
103  }
104  namespace_list = g_list_next(namespace_list);
105  }
106 
107  g_list_free(commodity_list);
108  g_list_free(namespace_list);
109 
110  if (retval == NULL && ask_on_unknown != 0)
111  {
112  const gchar *message =
113  _("Please select a commodity to match the following exchange "
114  "specific code. Please note that the exchange code of the "
115  "commodity you select will be overwritten.");
117  NULL,
119  message,
120  cusip,
121  default_fullname,
122  default_mnemonic);
123 
124  }
125  /* There seems to be a problem here - if the matched commodity does not
126  have a cusip defined (gnc_commodity_get_cusip returns NULL) then
127  it does not get overwritten - which is not consistent with the
128  message - so Im adding it to do this. Looks like this is all
129  that was needed to fix the cash value used as stock units problem
130  for pre-defined commodities which didnt have the cusip defined! */
131  if (retval != NULL &&
132  gnc_commodity_get_cusip(retval) != NULL &&
133  cusip != NULL &&
134  (strncmp(gnc_commodity_get_cusip(retval), cusip, strlen(cusip)) != 0))
135  {
136  gnc_commodity_set_cusip(retval, cusip);
137  }
138  else if (gnc_commodity_get_cusip(retval) == NULL && cusip != NULL)
139  {
140  gnc_commodity_set_cusip(retval, cusip);
141  }
142  return retval;
143 };
const char * gnc_commodity_get_cusip(const gnc_commodity *cm)
Retrieve the &#39;exchange code&#39; for the specified commodity.
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:260
Dialog box should allow selection of anything.
GList * gnc_commodity_table_get_namespaces(const gnc_commodity_table *table)
Return a list of all namespaces in the commodity table.
void gnc_commodity_set_cusip(gnc_commodity *cm, const char *cusip)
Set the &#39;exchange code&#39; for the specified commodity.
gnc_commodity * gnc_ui_select_commodity_modal_full(gnc_commodity *orig_sel, GtkWidget *parent, dialog_commodity_mode mode, const char *user_message, const char *cusip, const char *fullname, const char *mnemonic)
Ask the user to select a commodity from the existing set of commodities.
const char * gnc_commodity_get_fullname(const gnc_commodity *cm)
Retrieve the full name for the specified commodity.
CommodityList * gnc_commodity_table_get_commodities(const gnc_commodity_table *table, const char *name_space)
Return a list of all commodities in the commodity table that are in the given namespace.

◆ gnc_import_Settings_get_fuzzy_amount()

double gnc_import_Settings_get_fuzzy_amount ( GNCImportSettings *  settings)

Return the allowed amount range for fuzzy amount matching.

Returns
The allowed amount range for fuzzy amount matching, in the users default commodity.

Definition at line 115 of file import-settings.c.

116 {
117  g_assert (settings);
118  return settings->fuzzy_amount;
119 };

◆ gnc_import_Settings_get_match_date_hardlimit()

gint gnc_import_Settings_get_match_date_hardlimit ( const GNCImportSettings *  settings)

Returns the hard-limiting number of days that a matching split may differ.

Definition at line 168 of file import-settings.c.

169 {
170  g_assert(s);
171  return s->match_date_hardlimit;
172 }

◆ gnc_import_Settings_set_match_date_hardlimit()

void gnc_import_Settings_set_match_date_hardlimit ( GNCImportSettings *  settings,
gint  match_date_hardlimit 
)
Parameters
match_date_hardlimitThe number of days that a matching split may differ from the given transaction before it is discarded immediately. In other words, any split that is more distant from the given transaction than this match_date_hardlimit days will be ignored altogether. For use cases without paper checks (e.g. HBCI), values like 14 (days) might be appropriate, whereas for use cases with paper checks (e.g. OFX, QIF), values like 42 (days) seem more appropriate.

Definition at line 163 of file import-settings.c.

164 {
165  g_assert(s);
166  s->match_date_hardlimit = m;
167 }

◆ gnc_import_TransInfo_get_action()

GNCImportAction gnc_import_TransInfo_get_action ( const GNCImportTransInfo *  info)

Returns the currently selected action for this TransInfo.

Definition at line 172 of file import-backend.c.

173 {
174  g_assert (info);
175  return info->action;
176 }

◆ gnc_import_TransInfo_get_destacc()

Account * gnc_import_TransInfo_get_destacc ( const GNCImportTransInfo *  info)

Returns the 'other account' of this transaction.

May return NULL.

Definition at line 191 of file import-backend.c.

192 {
193  g_assert (info);
194  return info->dest_acc;
195 }

◆ gnc_import_TransInfo_get_destacc_selected_manually()

gboolean gnc_import_TransInfo_get_destacc_selected_manually ( const GNCImportTransInfo *  info)

Returns if the currently selected destination account for auto-matching was selected by the user.

Definition at line 212 of file import-backend.c.

213 {
214  g_assert (info);
215  return info->dest_acc_selected_manually;
216 }

◆ gnc_import_TransInfo_get_fsplit()

Split * gnc_import_TransInfo_get_fsplit ( const GNCImportTransInfo *  info)

Returns the first split of the transaction of this TransInfo.

Definition at line 141 of file import-backend.c.

142 {
143  g_assert (info);
144  return info->first_split;
145 }

◆ gnc_import_TransInfo_get_match_list()

GList * gnc_import_TransInfo_get_match_list ( const GNCImportTransInfo *  info)

Returns the stored list of possible matches.

Definition at line 110 of file import-backend.c.

111 {
112  g_assert (info);
113  return info->match_list;
114 }

◆ gnc_import_TransInfo_get_match_selected_manually()

gboolean gnc_import_TransInfo_get_match_selected_manually ( const GNCImportTransInfo *  info)

Returns if the currently selected match was selected by the user.

Definition at line 165 of file import-backend.c.

166 {
167  g_assert (info);
168  return info->selected_match_info.selected_manually;
169 }

◆ gnc_import_TransInfo_get_ref_id()

guint32 gnc_import_TransInfo_get_ref_id ( const GNCImportTransInfo *  info)

Returns the reference id for this TransInfo.

Definition at line 219 of file import-backend.c.

220 {
221  g_assert (info);
222  return info->ref_id;
223 }

◆ gnc_import_TransInfo_get_selected_match()

GNCImportMatchInfo * gnc_import_TransInfo_get_selected_match ( const GNCImportTransInfo *  info)

Returns the currently selected match in this TransInfo.

Definition at line 148 of file import-backend.c.

149 {
150  g_assert (info);
151  return info->selected_match_info.selected_match;
152 }

◆ gnc_import_TransInfo_get_trans()

Transaction * gnc_import_TransInfo_get_trans ( const GNCImportTransInfo *  info)

Returns the transaction of this TransInfo.

Definition at line 117 of file import-backend.c.

118 {
119  g_assert (info);
120  return info->trans;
121 }

◆ gnc_import_TransInfo_init_matches()

void gnc_import_TransInfo_init_matches ( GNCImportTransInfo *  trans_info,
GNCImportSettings *  settings 
)

Iterates through all splits of the originating account of trans_info.

Sorts the resulting list and sets the selected_match and action fields in the trans_info.

Sorts the resulting list and sets the selected_match and action fields in the trans_info.

Parameters
trans_infoThe TransInfo for which the matches should be found, sorted, and selected.
settingsThe structure that holds all the user preferences.

Definition at line 1199 of file import-backend.c.

1201 {
1202  GNCImportMatchInfo * best_match = NULL;
1203  g_assert (trans_info);
1204 
1205 
1206  /* Find all split matches in originating account. */
1207  gnc_import_find_split_matches(trans_info,
1211 
1212  if (trans_info->match_list != NULL)
1213  {
1214  trans_info->match_list = g_list_sort(trans_info->match_list,
1215  compare_probability);
1216  best_match = g_list_nth_data(trans_info->match_list, 0);
1218  best_match,
1219  FALSE);
1220  if (best_match != NULL &&
1221  best_match->probability >= gnc_import_Settings_get_clear_threshold(settings))
1222  {
1223  trans_info->action = GNCImport_CLEAR;
1224  }
1225  else if (best_match == NULL ||
1226  best_match->probability <= gnc_import_Settings_get_add_threshold(settings))
1227  {
1228  trans_info->action = GNCImport_ADD;
1229  }
1231  {
1232  trans_info->action = GNCImport_SKIP;
1233  }
1235  {
1236  trans_info->action = GNCImport_UPDATE;
1237  }
1238  else
1239  {
1240  trans_info->action = GNCImport_ADD;
1241  }
1242  }
1243  else
1244  {
1245  trans_info->action = GNCImport_ADD;
1246  }
1247  if (best_match &&
1248  trans_info->action == GNCImport_CLEAR &&
1250  {
1251  if (best_match->update_proposed)
1252  {
1253  trans_info->action = GNCImport_UPDATE;
1254  }
1255  }
1256 
1257  trans_info->previous_action = trans_info->action;
1258 }
gint gnc_import_Settings_get_clear_threshold(GNCImportSettings *settings)
Return the selected threshold.
void gnc_import_TransInfo_set_selected_match_info(GNCImportTransInfo *info, GNCImportMatchInfo *match, gboolean selected_manually)
Sets the currently selected match in this TransInfo.
gint gnc_import_Settings_get_display_threshold(GNCImportSettings *settings)
Return the selected threshold.
gint gnc_import_Settings_get_match_date_hardlimit(const GNCImportSettings *s)
Returns the hard-limiting number of days that a matching split may differ.
double gnc_import_Settings_get_fuzzy_amount(GNCImportSettings *settings)
Return the allowed amount range for fuzzy amount matching.
void gnc_import_find_split_matches(GNCImportTransInfo *trans_info, gint process_threshold, double fuzzy_amount_difference, gint match_date_hardlimit)
/brief Iterate through all splits of the originating account of the given transaction, and find all matching splits there.
gboolean gnc_import_Settings_get_action_update_enabled(GNCImportSettings *settings)
Return the selected action is enable state.
gboolean gnc_import_Settings_get_action_skip_enabled(GNCImportSettings *settings)
Return the selected action is enable state.
gint gnc_import_Settings_get_add_threshold(GNCImportSettings *settings)
Return the selected threshold.

◆ gnc_import_TransInfo_is_balanced()

gboolean gnc_import_TransInfo_is_balanced ( const GNCImportTransInfo *  info)

Returns if the transaction stored in the TransInfo is currently balanced.

Definition at line 124 of file import-backend.c.

125 {
126  g_assert (info);
127  /* Assume that the importer won't create a transaction that involves two or more
128  currencies and no non-currency commodity. In that case can use the simpler
129  value imbalance check. */
131  {
132  return TRUE;
133  }
134  else
135  {
136  return FALSE;
137  }
138 }
Transaction * gnc_import_TransInfo_get_trans(const GNCImportTransInfo *info)
Returns the transaction of this TransInfo.
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
gnc_numeric xaccTransGetImbalanceValue(const Transaction *trans)
The xaccTransGetImbalanceValue() method returns the total value of the transaction.
Definition: Transaction.c:1029

◆ gnc_import_TransInfo_new()

GNCImportTransInfo * gnc_import_TransInfo_new ( Transaction *  trans,
GncImportMatchMap matchmap 
)

Create a new object of GNCImportTransInfo here.

Allocates a new TransInfo object, with the Transaction 'trans' already stored in there.

Also, this already checks the ImportMatchMap for automated destination account matching. The given MatchMap may be NULL, in which case the ImportMatchMap of the originating account will be used.

Parameters
transThe transaction that this TransInfo should work with.
matchmapMatchMap used for automated destination account choosing. This may be NULL, in which case the MatchMap of the originating account will be used.

Definition at line 1163 of file import-backend.c.

1164 {
1165  GNCImportTransInfo *transaction_info;
1166  Split *split;
1167  g_assert (trans);
1168 
1169  transaction_info = g_new0(GNCImportTransInfo, 1);
1170 
1171  transaction_info->trans = trans;
1172  /* Only use first split, the source split */
1173  split = xaccTransGetSplit(trans, 0);
1174  g_assert(split);
1175  transaction_info->first_split = split;
1176 
1177  /* Try to find a previously selected destination account
1178  string match for the ADD action */
1179  gnc_import_TransInfo_set_destacc (transaction_info,
1180  matchmap_find_destination (matchmap, transaction_info),
1181  FALSE);
1182  return transaction_info;
1183 }
Split * xaccTransGetSplit(const Transaction *trans, int i)
The xaccTransGetSplit() method returns a pointer to each of the splits in this transaction.
Definition: Transaction.c:2191
void gnc_import_TransInfo_set_destacc(GNCImportTransInfo *info, Account *acc, gboolean selected_manually)
Set the &#39;other account&#39; of this transaction (used for auto-balance if needed).

◆ gnc_import_TransInfo_set_action()

void gnc_import_TransInfo_set_action ( GNCImportTransInfo *  info,
GNCImportAction  action 
)

Set the action for this TransInfo.

Also sets the previous action.

Definition at line 179 of file import-backend.c.

181 {
182  g_assert (info);
183  if (action != info->action)
184  {
185  info->previous_action = info->action;
186  info->action = action;
187  }
188 }

◆ gnc_import_TransInfo_set_destacc()

void gnc_import_TransInfo_set_destacc ( GNCImportTransInfo *  info,
Account acc,
gboolean  selected_manually 
)

Set the 'other account' of this transaction (used for auto-balance if needed).

May be set to NULL.

Parameters
selected_manuallyTRUE or FALSE; Was this account set as a result of a selection by the user or by an algorithm?

Definition at line 196 of file import-backend.c.

199 {
200  g_assert (info);
201  info->dest_acc = acc;
202  info->dest_acc_selected_manually = selected_manually;
203 
204  /* Store the mapping to the other account in the MatchMap. */
205  if (selected_manually)
206  {
207  matchmap_store_destination (NULL, info, FALSE);
208  }
209 }

◆ gnc_import_TransInfo_set_ref_id()

void gnc_import_TransInfo_set_ref_id ( GNCImportTransInfo *  info,
guint32  ref_id 
)

Set the reference id for this TransInfo.

Definition at line 226 of file import-backend.c.

228 {
229  g_assert (info);
230  info->ref_id = ref_id;
231 }

◆ gnc_import_TransInfo_set_selected_match_info()

void gnc_import_TransInfo_set_selected_match_info ( GNCImportTransInfo *  info,
GNCImportMatchInfo match,
gboolean  selected_manually 
)

Sets the currently selected match in this TransInfo.

Parameters
selected_manuallyTRUE or FALSE; Was this match set as a result of a selection by the user or by an algorithm?

Definition at line 155 of file import-backend.c.

158 {
159  g_assert (info);
160  info->selected_match_info.selected_match = match;
161  info->selected_match_info.selected_manually = selected_manually;
162 }

◆ on_matcher_help_clicked()

void on_matcher_help_clicked ( GtkButton *  button,
gpointer  user_data 
)

This allows for the transaction help dialog to be started from the assistant button callback.

Parameters
button.The button widget clicked on in the call back.
user_data.A pointer to a structure.

Definition at line 204 of file import-main-matcher.c.

205 {
206  GNCImportMainMatcher *info = user_data;
207  GtkBuilder *builder;
208  GtkWidget *help_dialog, *box;
209  gchar *int_required_class, *int_prob_required_class, *int_not_required_class;
210  gchar *class_extension = NULL;
211 
212  builder = gtk_builder_new();
213  gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer2");
214  gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer3");
215  gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer4");
216  gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer5");
217  gnc_builder_add_from_file (builder, "dialog-import.glade", "matcher_help_dialog");
218 
219  if (info->dark_theme == TRUE)
220  class_extension = "-dark";
221 
222  int_required_class = g_strconcat (CSS_INT_REQUIRED_CLASS, class_extension, NULL);
223  int_prob_required_class = g_strconcat (CSS_INT_PROB_REQUIRED_CLASS, class_extension, NULL);
224  int_not_required_class = g_strconcat (CSS_INT_NOT_REQUIRED_CLASS, class_extension, NULL);
225 
226  box = GTK_WIDGET(gtk_builder_get_object (builder, "intervention_required_box"));
227  gnc_widget_set_style_context (GTK_WIDGET(box), int_required_class);
228 
229  box = GTK_WIDGET(gtk_builder_get_object (builder, "intervention_probably_required_box"));
230  gnc_widget_set_style_context (GTK_WIDGET(box), int_prob_required_class);
231 
232  box = GTK_WIDGET(gtk_builder_get_object (builder, "intervention_not_required_box"));
233  gnc_widget_set_style_context (GTK_WIDGET(box), int_not_required_class);
234 
235  help_dialog = GTK_WIDGET(gtk_builder_get_object (builder, "matcher_help_dialog"));
236  gtk_window_set_transient_for(GTK_WINDOW(help_dialog),
237  GTK_WINDOW(info->main_widget));
238 
239  /* Connect the signals */
240  gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, help_dialog);
241 
242  g_object_unref(G_OBJECT(builder));
243 
244  g_free (int_required_class);
245  g_free (int_prob_required_class);
246  g_free (int_not_required_class);
247 
248  gtk_widget_show(help_dialog);
249 }