GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-settings.h
 Import preference handling.
 
file  import-utilities.h
 Utility functions for writing import modules.
 

Data Structures

struct  AccountPickerDialog
 
struct  GNCImportTransInfo
 
struct  GNCImportMatchInfo
 
struct  GNCImportMainMatcher
 
struct  GNCImportMatchPicker
 
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 COLOR_RED   "brown1"
 
#define COLOR_YELLOW   "gold"
 
#define COLOR_GREEN   "DarkSeaGreen1"
 
#define GNC_PREFS_GROUP   "dialogs.import.generic.match-picker"
 
#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)
 

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_INFO_PTR, NUM_MATCHER_COLS
}
 

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, 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 (GNCImportTransInfo *transaction_info)
 Run a match_picker dialog so that the selected-MatchInfo in the given trans_info is updated accordingly. More...
 
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)
 
void gnc_file_log_replay (void)
 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 *transaction_user_data)
 
int ofx_proc_account_cb (struct OfxAccountData data, void *account_user_data)
 
void gnc_file_ofx_import (void)
 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
 
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...
 
GNCImportMatchInfo * gnc_import_TransInfo_get_selected_match (const GNCImportTransInfo *info)
 Returns the currently selected match in this TransInfo. More...
 
void gnc_import_TransInfo_set_selected_match (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

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 282 of file import-backend.c.

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

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 547 of file gnc-log-replay.c.

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

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 950 of file gnc-ofx-import.c.

951 {
952  extern int ofx_PARSER_msg;
953  extern int ofx_DEBUG_msg;
954  extern int ofx_WARNING_msg;
955  extern int ofx_ERROR_msg;
956  extern int ofx_INFO_msg;
957  extern int ofx_STATUS_msg;
958  char *selected_filename;
959  char *default_dir;
960  LibofxContextPtr libofx_context = libofx_get_new_context();
961 
962  ofx_PARSER_msg = false;
963  ofx_DEBUG_msg = false;
964  ofx_WARNING_msg = true;
965  ofx_ERROR_msg = true;
966  ofx_INFO_msg = true;
967  ofx_STATUS_msg = false;
968 
969  DEBUG("gnc_file_ofx_import(): Begin...\n");
970 
971  default_dir = gnc_get_default_directory(GNC_PREFS_GROUP);
972  selected_filename = gnc_file_dialog(_("Select an OFX/QFX file to process"),
973  NULL,
974  default_dir,
975  GNC_FILE_DIALOG_IMPORT);
976  g_free(default_dir);
977 
978  if (selected_filename != NULL)
979  {
980 #ifdef G_OS_WIN32
981  gchar *conv_name;
982 #endif
983 
984  /* Remember the directory as the default. */
985  default_dir = g_path_get_dirname(selected_filename);
986  gnc_set_default_directory(GNC_PREFS_GROUP, default_dir);
987  g_free(default_dir);
988 
989  /*strncpy(file,selected_filename, 255);*/
990  DEBUG("Filename found: %s", selected_filename);
991 
992  /* Create the Generic transaction importer GUI. */
993  gnc_ofx_importer_gui = gnc_gen_trans_list_new(NULL, NULL, FALSE, 42);
994 
995  /* Look up the needed preferences */
996  auto_create_commodity =
997  gnc_prefs_get_bool (GNC_PREFS_GROUP_IMPORT, GNC_PREF_AUTO_COMMODITY);
998 
999  /* Initialize libofx */
1000 
1001  /*ofx_set_statement_cb(libofx_context, ofx_proc_statement_cb, 0);*/
1002  ofx_set_account_cb(libofx_context, ofx_proc_account_cb, 0);
1003  ofx_set_transaction_cb(libofx_context, ofx_proc_transaction_cb, 0);
1004  ofx_set_security_cb(libofx_context, ofx_proc_security_cb, 0);
1005  /*ofx_set_status_cb(libofx_context, ofx_proc_status_cb, 0);*/
1006 
1007 #ifdef G_OS_WIN32
1008  conv_name = g_win32_locale_filename_from_utf8(selected_filename);
1009  g_free(selected_filename);
1010  selected_filename = conv_name;
1011 #endif
1012 
1013  DEBUG("Opening selected file");
1014  libofx_proc_file(libofx_context, selected_filename, AUTODETECT);
1015  g_free(selected_filename);
1016  }
1017 
1018  if (ofx_created_commodites)
1019  {
1020  /* FIXME: Present some result window about the newly created
1021  * commodities */
1022  g_warning("Created %d new commodities during import", g_list_length(ofx_created_commodites));
1023  g_list_free(ofx_created_commodites);
1024  ofx_created_commodites = NULL;
1025  }
1026  else
1027  {
1028  //g_warning("No new commodities created");
1029  }
1030 }
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:255
#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:196
GNCImportMainMatcher * gnc_gen_trans_assist_new ( GtkWidget *  parent,
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. 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 573 of file import-main-matcher.c.

577 {
578  GNCImportMainMatcher *info;
579  GtkBuilder *builder;
580  GtkWidget *heading_label;
581  GtkWidget *box;
582  gboolean show_update;
583 
584  info = g_new0 (GNCImportMainMatcher, 1);
585 
586  /* Initialize user Settings. */
587  info->user_settings = gnc_import_Settings_new ();
588  gnc_import_Settings_set_match_date_hardlimit (info->user_settings, match_date_hardlimit);
589 
590  /* load the interface */
591  builder = gtk_builder_new();
592  gnc_builder_add_from_file (builder, "dialog-import.glade", "transaction_matcher_content");
593  if (builder == NULL)
594  {
595  PERR("Error opening the glade builder interface");
596  }
597  /* Pack content into Assistant page widget */
598  box = GTK_WIDGET(gtk_builder_get_object (builder, "transaction_matcher_content"));
599  gtk_box_pack_start( GTK_BOX(parent), box, TRUE, TRUE, 6);
600 
601  /* Get the view */
602  info->view = GTK_TREE_VIEW(gtk_builder_get_object (builder, "downloaded_view"));
603  g_assert (info->view != NULL);
604 
605  show_update = gnc_import_Settings_get_action_update_enabled(info->user_settings);
606  gnc_gen_trans_init_view(info, all_from_same_account, show_update);
607  heading_label = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label"));
608  g_assert (heading_label != NULL);
609 
610  /*Initialise the colors */
611  gdk_color_parse(COLOR_RED, &info->color_back_red);
612  gdk_color_parse(COLOR_YELLOW, &info->color_back_yellow);
613  gdk_color_parse(COLOR_GREEN, &info->color_back_green);
614 
615  if (heading)
616  gtk_label_set_text (GTK_LABEL (heading_label), heading);
617 
618  info->transaction_processed_cb = NULL;
619 
620  /* Connect the signals */
621  gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, info);
622 
623  g_object_unref(G_OBJECT(builder));
624 
625  return info;
626 }
GNCImportSettings * gnc_import_Settings_new(void)
Allocates a new GNCImportSettings object, and initialize it with the appropriate user prefs...
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:237
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.
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 628 of file import-main-matcher.c.

629 {
630  on_matcher_ok_clicked (NULL, info);
631 }
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 637 of file import-main-matcher.c.

640 {
641  info->user_data = user_data;
642  info->transaction_processed_cb = trans_processed_cb;
643 }
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 commited. The Importer takes over ownership of the passed transaction.

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

873 {
875  return;
876 }/* 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...
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 commited. The Importer takes over ownership of the passed transaction.
ref_idReference id which links an external object to the transaction.

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

879 {
880  GNCImportTransInfo * transaction_info = NULL;
881  GtkTreeModel *model;
882  GtkTreeIter iter;
883  g_assert (gui);
884  g_assert (trans);
885 
886 
887  if (gnc_import_exists_online_id (trans))
888  return;
889  else
890  {
891  transaction_info = gnc_import_TransInfo_new(trans, NULL);
892  gnc_import_TransInfo_set_ref_id(transaction_info, ref_id);
893 
894  gnc_import_TransInfo_init_matches(transaction_info,
895  gui->user_settings);
896 
897  model = gtk_tree_view_get_model(gui->view);
898  gtk_list_store_append(GTK_LIST_STORE(model), &iter);
899  refresh_model_row (gui, model, &iter, transaction_info);
900  }
901  return;
902 }/* 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's online_id already exists in its parent account.
void gnc_gen_trans_list_delete ( GNCImportMainMatcher *  info)

Deletes the given object.

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

102 {
103  GtkTreeModel *model;
104  GtkTreeIter iter;
105  GNCImportTransInfo *trans_info;
106 
107  if (info == NULL)
108  return;
109 
110  model = gtk_tree_view_get_model(info->view);
111  if (gtk_tree_model_get_iter_first(model, &iter))
112  {
113  do
114  {
115  gtk_tree_model_get(model, &iter,
116  DOWNLOADED_COL_DATA, &trans_info,
117  -1);
118 
119  if (info->transaction_processed_cb)
120  {
121  info->transaction_processed_cb(trans_info,
122  FALSE,
123  info->user_data);
124  }
125 
126  gnc_import_TransInfo_delete(trans_info);
127  }
128  while (gtk_tree_model_iter_next (model, &iter));
129  }
130 
131 
132  if (!(info->dialog == NULL))
133  {
134  gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(info->dialog));
135  gnc_import_Settings_delete (info->user_settings);
136  gtk_widget_destroy (GTK_WIDGET (info->dialog));
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.
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 506 of file import-main-matcher.c.

510 {
511  GNCImportMainMatcher *info;
512  GtkBuilder *builder;
513  GtkWidget *heading_label;
514  GtkWidget *box, *pbox;
515  gboolean show_update;
516 
517  info = g_new0 (GNCImportMainMatcher, 1);
518 
519  /* Initialize user Settings. */
520  info->user_settings = gnc_import_Settings_new ();
521  gnc_import_Settings_set_match_date_hardlimit (info->user_settings, match_date_hardlimit);
522 
523  /* Initialize the GtkDialog. */
524  builder = gtk_builder_new();
525  gnc_builder_add_from_file (builder, "dialog-import.glade", "transaction_matcher");
526  gnc_builder_add_from_file (builder, "dialog-import.glade", "transaction_matcher_content");
527  info->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "transaction_matcher"));
528  g_assert (info->dialog != NULL);
529 
530  /* Pack the content into the dialog vbox */
531  pbox = GTK_WIDGET(gtk_builder_get_object (builder, "transaction_matcher_vbox"));
532  box = GTK_WIDGET(gtk_builder_get_object (builder, "transaction_matcher_content"));
533  gtk_box_pack_start( GTK_BOX(pbox), box, TRUE, TRUE, 0);
534 
535  /* Get the view */
536  info->view = GTK_TREE_VIEW(gtk_builder_get_object (builder, "downloaded_view"));
537  g_assert (info->view != NULL);
538 
539  show_update = gnc_import_Settings_get_action_update_enabled(info->user_settings);
540  gnc_gen_trans_init_view(info, all_from_same_account, show_update);
541  heading_label = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label"));
542  g_assert (heading_label != NULL);
543 
544  /* if (parent)
545  gtk_window_set_transient_for (GTK_WINDOW (info->dialog),
546  GTK_WINDOW (parent));*/
547 
548  /*Initialise the colors */
549  gdk_color_parse(COLOR_RED, &info->color_back_red);
550  gdk_color_parse(COLOR_YELLOW, &info->color_back_yellow);
551  gdk_color_parse(COLOR_GREEN, &info->color_back_green);
552 
553  if (heading)
554  gtk_label_set_text (GTK_LABEL (heading_label), heading);
555 
556  gnc_restore_window_size(GNC_PREFS_GROUP, GTK_WINDOW(info->dialog));
557  gtk_widget_show_all (GTK_WIDGET (info->dialog));
558 
559  info->transaction_processed_cb = NULL;
560 
561  /* Connect the signals */
562  gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, info);
563 
564  g_object_unref(G_OBJECT(builder));
565 
566  return info;
567 }
GNCImportSettings * gnc_import_Settings_new(void)
Allocates a new GNCImportSettings object, and initialize it with the appropriate user prefs...
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.
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 645 of file import-main-matcher.c.

646 {
647  gboolean result;
648 
649  /* DEBUG("Begin"); */
650  result = gtk_dialog_run (GTK_DIALOG (info->dialog));
651  /* DEBUG("Result was %d", result); */
652 
653  /* No destroying here since the dialog was already destroyed through
654  the ok_clicked handlers. */
655 
656  return result;
657 }
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 470 of file import-account-matcher.c.

471 {
472  gtk_widget_set_sensitive (picker->account_tree_sw, !disable);
473  gtk_widget_set_sensitive (picker->new_button, !disable);
474 }
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 418 of file import-account-matcher.c.

419 {
420  AccountPickerDialog * picker;
421  GtkBuilder *builder;
422  GtkWidget *box, *h_box;
423 
424  /* Init the account picker structure */
425  picker = gnc_import_new_account_picker();
426 
427  /* load the interface */
428  builder = gtk_builder_new();
429  gnc_builder_add_from_file (builder, "dialog-import.glade", "account_picker_content");
430  /* connect the signals in the interface */
431  if (builder == NULL)
432  {
433  PERR("Error opening the glade builder interface");
434  }
435 
436  picker->assistant = gtk_widget_get_parent(parent);
437  /* Pack content into Assistant page widget */
438  box = GTK_WIDGET(gtk_builder_get_object (builder, "account_picker_content"));
439  gtk_box_pack_start( GTK_BOX(parent), box, TRUE, TRUE, 6);
440 
441  picker->account_tree_sw = GTK_WIDGET(gtk_builder_get_object (builder, "account_tree_sw"));
442  picker->account_online_id_label = GTK_WIDGET(gtk_builder_get_object (builder, "online_id_label"));
443 
444  /* Add the New Account Button */
445  picker->new_button = gtk_button_new_with_mnemonic ("_New Account");
446  h_box = gtk_hbox_new(TRUE, 0);
447  gtk_box_pack_start(GTK_BOX(h_box), picker->new_button, FALSE, FALSE, 0);
448  gtk_box_pack_start( GTK_BOX(box), h_box, FALSE, FALSE, 6);
449  gtk_button_set_use_stock (GTK_BUTTON(picker->new_button), TRUE);
450  gtk_widget_show (picker->new_button);
451  g_signal_connect(picker->new_button, "clicked",
452  G_CALLBACK(gnc_import_add_account), picker);
453 
454  build_acct_tree(picker);
455 
456  g_signal_connect(picker->account_tree, "row-activated",
457  G_CALLBACK(account_tree_row_activated_cb), picker);
458 
459  g_object_unref(G_OBJECT(builder));
460  return picker;
461 }
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:237
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 482 of file import-account-matcher.c.

483 {
484 #define ACCOUNT_DESCRIPTION_MAX_SIZE 255
485 
486  const gchar *retval_name = NULL;
487  gchar account_description_text[ACCOUNT_DESCRIPTION_MAX_SIZE] = "";
488 
489  ENTER("Default commodity received: %s", gnc_commodity_get_fullname( picker->new_account_default_commodity));
490  DEBUG("Default account type received: %s", xaccAccountGetTypeStr( picker->new_account_default_type));
491 
492  /*DEBUG("Looking for account with online_id: %s", picker->account_online_id_value);*/
493  if (picker->account_online_id_value != NULL)
494  {
495  picker->retAccount =
496  gnc_account_foreach_descendant_until(gnc_get_current_root_account (),
497  test_acct_online_id_match,
498  /* This argument will only be used as a "const char*" */
499  (void*)picker->account_online_id_value);
500  }
501 
502  if (picker->account_human_description != NULL)
503  {
504  strncat(account_description_text, picker->account_human_description,
505  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
506  strncat(account_description_text, "\n",
507  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
508  }
509  if (picker->account_online_id_value != NULL)
510  {
511  strncat(account_description_text, _("(Full account ID: "),
512  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
513  strncat(account_description_text, picker->account_online_id_value,
514  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
515  strncat(account_description_text, ")",
516  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
517  }
518  gtk_label_set_text(GTK_LABEL( picker->account_online_id_label), account_description_text);
519 
520  if (picker->default_account == NULL)
521  gnc_tree_view_account_set_selected_account(picker->account_tree, picker->retAccount);
522  else
523  gnc_tree_view_account_set_selected_account(picker->account_tree, picker->default_account);
524 
525  /*FIXME: DEBUG("WRITEME: Here we should check if an account type is compatible, currency matches, etc.\n"); */
526 
527  /*DEBUG("Return value: %p%s%s%s",picker->retAccount,", account name:",xaccAccountGetName(picker->retAccount),"\n");*/
528  retval_name = picker->retAccount ? xaccAccountGetName(picker->retAccount) : NULL;
529  LEAVE("Selected account %p, %s", picker->retAccount, retval_name ? retval_name : "(null)");
530  return picker->retAccount;
531 }
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:255
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 'func' on each...
Definition: Account.c:2960
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:261
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:271
const char * xaccAccountGetName(const Account *acc)
Get the account's name.
Definition: Account.c:3012
const char * xaccAccountGetTypeStr(GNCAccountType type)
The xaccAccountGetTypeStr() routine returns a string suitable for use in the GUI/Interface.
Definition: Account.c:4123
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.c:5018
Split * xaccTransGetSplit(const Transaction *trans, int i)
The xaccTransGetSplit() method returns a pointer to each of the splits in this transaction.
Definition: Transaction.c:2212
STRUCTS.
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:255
void xaccTransDestroy(Transaction *trans)
Destroys a transaction.
Definition: Transaction.c:1465
void xaccTransCommitEdit(Transaction *trans)
The xaccTransCommitEdit() method indicates that the changes to the transaction and its splits are com...
Definition: Transaction.c:1642
Account * xaccSplitGetAccount(const Split *s)
Returns the account of this split, which was set through xaccAccountInsertSplit().
Definition: Split.c:929
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 811 of file import-backend.c.

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

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
transaction_infoThe TransInfo for which the user is supposed to pick a matching transaction.

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

444 {
445  GNCImportMatchPicker *matcher;
446  gint response;
447  GNCImportMatchInfo *old;
448  g_assert (transaction_info);
449 
450  /* Create a new match_picker, even though it's stored in a
451  transmatcher struct :-) */
452  matcher = g_new0(GNCImportMatchPicker, 1);
453  /* DEBUG("Init match_picker"); */
454  init_match_picker_gui(matcher);
455 
456  /* Append this single transaction to the view and select it */
457  downloaded_transaction_append(matcher, transaction_info);
458 
459  old = gnc_import_TransInfo_get_selected_match(transaction_info);
460 
461  /* Let this dialog run and close. */
462  /*DEBUG("Right before run and close");*/
463  gtk_window_set_modal(GTK_WINDOW(matcher->transaction_matcher), TRUE);
464  response = gtk_dialog_run (GTK_DIALOG (matcher->transaction_matcher));
465  gnc_save_window_size(GNC_PREFS_GROUP,
466  GTK_WINDOW (matcher->transaction_matcher));
467  gtk_widget_destroy (matcher->transaction_matcher);
468  /*DEBUG("Right after run and close");*/
469  /* DEBUG("Response was %d.", response); */
470  if (response == GTK_RESPONSE_OK && matcher->selected_match_info != old)
471  {
472  /* OK was pressed */
473  gnc_import_TransInfo_set_selected_match (transaction_info,
474  matcher->selected_match_info,
475  TRUE);
476  }
477 }
void gnc_import_TransInfo_set_selected_match(GNCImportTransInfo *info, GNCImportMatchInfo *match, gboolean selected_manually)
Sets the currently selected match in this TransInfo.
GNCImportMatchInfo * gnc_import_TransInfo_get_selected_match(const GNCImportTransInfo *info)
Returns the currently selected match in this TransInfo.
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 246 of file import-backend.c.

247 {
248  if (info)
249  {
250  return info->probability;
251  }
252  else
253  {
254  return 0;
255  }
256 }
Split * gnc_import_MatchInfo_get_split ( const GNCImportMatchInfo *  info)

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

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

240 {
241  g_assert (info);
242  return info->split;
243 }
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 succesful 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 874 of file import-backend.c.

876 {
877  Split * other_split;
878  gnc_numeric imbalance_value;
879 
880  /* DEBUG("Begin"); */
881 
882  g_assert (trans_info);
883  /*DEBUG("Iteration %d, action %d, split %s", i,
884  trans_info->action,
885  xaccTransGetDescription (gnc_import_TransInfo_get_trans
886  (trans_info)))*/
887  switch (gnc_import_TransInfo_get_action (trans_info))
888  {
889  case GNCImport_SKIP:
890  return FALSE;
891  case GNCImport_ADD:
892  /* Transaction gets imported. */
893 
894  /* Is the transaction not balanced and there is a non-NULL destination account? */
895  if (gnc_import_TransInfo_is_balanced(trans_info) == FALSE
896  && gnc_import_TransInfo_get_destacc(trans_info) != NULL)
897  {
898  /* Create the 'other' split. */
899  Split *split =
901  (gnc_account_get_book
902  (gnc_import_TransInfo_get_destacc (trans_info)));
904  (gnc_import_TransInfo_get_trans (trans_info), split);
906  (gnc_import_TransInfo_get_destacc (trans_info), split);
907  /*xaccSplitSetBaseValue
908  (split,
909  gnc_numeric_neg(xaccTransGetImbalance
910  (gnc_import_TransInfo_get_trans (trans_info))),
911  xaccTransGetCurrency
912  (gnc_import_TransInfo_get_trans (trans_info)));*/
913  {
914  /* This is a quick workaround for the bug described in
915  http://gnucash.org/pipermail/gnucash-devel/2003-August/009982.html
916  Assume that importers won't create transactions involving two or more
917  currencies so we can use xaccTransGetImbalanceValue. */
918  imbalance_value =
920  (gnc_import_TransInfo_get_trans (trans_info)));
921  xaccSplitSetValue (split, imbalance_value);
922  xaccSplitSetAmount (split, imbalance_value);
923  }
924  /*xaccSplitSetMemo (split, _("Auto-Balance split"));
925  -- disabled due to popular request */
926  }
927 
929  /*Set reconcile date to today*/
931  gnc_time (NULL));
932  /* Done editing. */
934  return TRUE;
935  case GNCImport_UPDATE:
936  {
937  GNCImportMatchInfo *selected_match =
939 
940  /* If there is no selection, ignore this transaction. */
941  if (!selected_match)
942  {
943  PWARN("No matching translaction to be cleared was chosen. Imported transaction will be ignored.");
944  break;
945  }
946 
947  /* Transaction gets not imported but the matching one gets
948  updated and reconciled. */
949  if (gnc_import_MatchInfo_get_split(selected_match) == NULL)
950  {
951  PERR("The split I am trying to update and reconcile is NULL, shouldn't happen!");
952  }
953  else
954  {
955  /* Update and reconcile the matching transaction */
956  /*DEBUG("BeginEdit selected_match")*/
957  xaccTransBeginEdit(selected_match->trans);
958 
959  xaccTransSetDatePostedSecsNormalized(selected_match->trans,
961  gnc_import_TransInfo_get_fsplit(trans_info))));
962 
963  xaccSplitSetAmount(selected_match->split,
965  gnc_import_TransInfo_get_fsplit(trans_info)));
966  xaccSplitSetValue(selected_match->split,
968  gnc_import_TransInfo_get_fsplit(trans_info)));
969 
970  imbalance_value = xaccTransGetImbalanceValue(
971  gnc_import_TransInfo_get_trans(trans_info));
972  other_split = xaccSplitGetOtherSplit(selected_match->split);
973  if (!gnc_numeric_zero_p(imbalance_value) && other_split)
974  {
975  if (xaccSplitGetReconcile(other_split) == NREC)
976  {
977  imbalance_value = gnc_numeric_neg(imbalance_value);
978  xaccSplitSetValue(other_split, imbalance_value);
979  xaccSplitSetAmount(other_split, imbalance_value);
980  }
981  /* else GC will automatically insert a split to equity
982  to balance the transaction */
983  }
984 
985  xaccTransSetDescription(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's commodity.
Definition: Split.c:1258
#define xaccTransAppendSplit(t, s)
Add a split to the transaction.
Definition: Transaction.h:357
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:1975
time64 xaccTransGetDate(const Transaction *trans)
Retrieve the posted date of the transaction.
Definition: Transaction.c:2316
gnc_numeric gnc_numeric_neg(gnc_numeric a)
Returns a newly created gnc_numeric that is the negative of the given gnc_numeric value...
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:255
char xaccSplitGetReconcile(const Split *split)
Returns the value of the reconcile flag.
Definition: Split.c:1922
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:2143
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.
Definition: gnc-numeric.cpp:96
void xaccSplitSetReconcile(Split *split, char recn)
Set the reconcile flag.
Definition: Split.c:1768
Transaction * xaccSplitGetParent(const Split *split)
Returns the parent transaction of the split.
Definition: Split.c:1845
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:237
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:1465
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:243
Split * gnc_import_MatchInfo_get_split(const GNCImportMatchInfo *info)
Get the split ('this-side split') of this MatchInfo.
void xaccSplitSetAmount(Split *s, gnc_numeric amt)
The xaccSplitSetAmount() method sets the amount in the account's commodity that the split should have...
Definition: Split.c:1222
gnc_numeric xaccTransGetImbalanceValue(const Transaction *trans)
The xaccTransGetImbalanceValue() method returns the total value of the transaction.
Definition: Transaction.c:1043
const char * xaccTransGetDescription(const Transaction *trans)
Gets the transaction Description.
Definition: Transaction.c:2274
void xaccTransCommitEdit(Transaction *trans)
The xaccTransCommitEdit() method indicates that the changes to the transaction and its splits are com...
Definition: Transaction.c:1642
void xaccTransBeginEdit(Transaction *trans)
The xaccTransBeginEdit() method must be called before any changes are made to a transaction or any of...
Definition: Transaction.c:1443
#define CREC
The Split has been cleared.
Definition: Split.h:67
Split * xaccMallocSplit(QofBook *book)
Constructor.
Definition: Split.c:546
void xaccSplitSetDateReconciledSecs(Split *split, time64 secs)
Set the date on which this split was reconciled by specifying the time as time64. ...
Definition: Split.c:1794
gnc_numeric xaccSplitGetValue(const Split *split)
Returns the value of this split in the transaction's commodity.
Definition: Split.c:1935
#define xaccAccountInsertSplit(acc, s)
The xaccAccountInsertSplit() method will insert the indicated split into the indicated account...
Definition: Account.h:978
Split * xaccSplitGetOtherSplit(const Split *split)
The xaccSplitGetOtherSplit() is a convenience routine that returns the other of a pair of splits...
Definition: Split.c:2098
Account * gnc_import_TransInfo_get_destacc(const GNCImportTransInfo *info)
Returns the 'other account' of this transaction.
time64 gnc_time(time64 *tbuf)
get the current local time
Definition: gnc-date.cpp:238
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:70
gnc_numeric xaccSplitGetAmount(const Split *split)
Returns the amount of the split in the account's commodity.
Definition: Split.c:1929
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 224 of file import-account-matcher.c.

232 {
233 #define ACCOUNT_DESCRIPTION_MAX_SIZE 255
234  AccountPickerDialog * picker;
235  gint response;
236  Account * retval = NULL;
237  const gchar *retval_name = NULL;
238  GtkBuilder *builder;
239  GtkWidget * online_id_label, *button, *box, *pbox;
240  gchar account_description_text[ACCOUNT_DESCRIPTION_MAX_SIZE] = "";
241  gboolean ok_pressed_retval = FALSE;
242 
243  ENTER("Default commodity received: %s", gnc_commodity_get_fullname( new_account_default_commodity));
244  DEBUG("Default account type received: %s", xaccAccountGetTypeStr( new_account_default_type));
245  picker = g_new0(AccountPickerDialog, 1);
246 
247  picker->account_online_id_value = account_online_id_value;
248  picker->account_human_description = account_human_description;
249  picker->new_account_default_commodity = new_account_default_commodity;
250  picker->new_account_default_type = new_account_default_type;
251 
252  /*DEBUG("Looking for account with online_id: \"%s\"", account_online_id_value);*/
253  if (account_online_id_value != NULL)
254  {
255  retval =
256  gnc_account_foreach_descendant_until(gnc_get_current_root_account (),
257  test_acct_online_id_match,
258  /* This argument will only be used as a "const char*" */
259  (void*)account_online_id_value);
260 
261  /* BEGIN: try again without extra space at the end */
262  /*
263  * libofx, used for file import, generates online_id as
264  * ACCTID + space + ACCTKEY which differs from the online_id
265  * generated by aqbanking for online ofx transfer as ACCTID.
266  *
267  * If a gnucash account has been associated with an online_id
268  * via aqbanking data, it is not possible to construct an OFX
269  * file for gnucash import that matches the same online_id
270  * because even with no ACCTKEY in the file, there will be a
271  * trailing space.
272  *
273  * This is a hack to overcome that problem.
274  */
275  if ((retval == NULL) && g_str_has_suffix(account_online_id_value, " "))
276  {
277  gchar *trimmed = g_strndup(account_online_id_value, strlen(account_online_id_value) - 1);
278  if (trimmed)
279  {
281  gnc_get_current_root_account (),
282  test_acct_online_id_match,
283  (void *)trimmed);
284  }
285  g_free(trimmed);
286  }
287  /* END: try again without extra space at the end */
288  }
289  if (retval == NULL && auto_create != 0)
290  {
291  /* load the interface */
292  builder = gtk_builder_new();
293  gnc_builder_add_from_file (builder, "dialog-import.glade", "account_picker");
294  gnc_builder_add_from_file (builder, "dialog-import.glade", "account_picker_content");
295  /* connect the signals in the interface */
296  if (builder == NULL)
297  {
298  PERR("Error opening the glade builder interface");
299  }
300  picker->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "account_picker"));
301  if (parent)
302  gtk_window_set_transient_for (GTK_WINDOW (picker->dialog),
303  GTK_WINDOW (parent));
304 
305  /* Pack the content into the dialog vbox */
306  pbox = GTK_WIDGET(gtk_builder_get_object (builder, "account_picker_vbox"));
307  box = GTK_WIDGET(gtk_builder_get_object (builder, "account_picker_content"));
308  gtk_box_pack_start( GTK_BOX(pbox), box, TRUE, TRUE, 0);
309 
310  picker->account_tree_sw = GTK_WIDGET(gtk_builder_get_object (builder, "account_tree_sw"));
311  online_id_label = GTK_WIDGET(gtk_builder_get_object (builder, "online_id_label"));
312  button = GTK_WIDGET(gtk_builder_get_object (builder, "newbutton"));
313  gtk_button_set_use_stock (GTK_BUTTON(button), TRUE);
314 
315  //printf("gnc_import_select_account(): Fin get widget\n");
316 
317  if (account_human_description != NULL)
318  {
319  strncat(account_description_text, account_human_description,
320  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
321  strncat(account_description_text, "\n",
322  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
323  }
324  if (account_online_id_value != NULL)
325  {
326  strncat(account_description_text, _("(Full account ID: "),
327  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
328  strncat(account_description_text, account_online_id_value,
329  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
330  strncat(account_description_text, ")",
331  ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
332  }
333  gtk_label_set_text((GtkLabel*)online_id_label, account_description_text);
334  build_acct_tree(picker);
335  gnc_tree_view_account_set_selected_account(picker->account_tree, default_selection);
336 
337  gtk_window_set_modal(GTK_WINDOW(picker->dialog), TRUE);
338  g_signal_connect(picker->account_tree, "row-activated",
339  G_CALLBACK(account_tree_row_activated_cb), picker);
340  do
341  {
342  response = gtk_dialog_run(GTK_DIALOG(picker->dialog));
343  switch (response)
344  {
345  case GNC_RESPONSE_NEW:
346  gnc_import_add_account(NULL, picker);
347  response = GTK_RESPONSE_OK;
348  /* no break */
349 
350  case GTK_RESPONSE_OK:
351  retval = gnc_tree_view_account_get_selected_account(picker->account_tree);
352  if (retval == NULL)
353  {
354  response = GNC_RESPONSE_NEW;
355  break;
356  }
357  if (retval)
358  retval_name = xaccAccountGetName(retval);
359  if (!retval_name)
360  retval_name = "(null)";
361  DEBUG("Selected account %p, %s", retval, retval_name);
362 
363  /* See if the selected account is a placeholder. */
364  if (retval && xaccAccountGetPlaceholder (retval))
365  {
366  gnc_error_dialog
367  (picker->dialog,
368  _("The account %s is a placeholder account and does not allow "
369  "transactions. Please choose a different account."),
370  retval_name);
371  response = GNC_RESPONSE_NEW;
372  break;
373  }
374 
375  if ( account_online_id_value != NULL)
376  {
377  gnc_import_set_acc_online_id(retval, account_online_id_value);
378  }
379  ok_pressed_retval = TRUE;
380  break;
381 
382  default:
383  ok_pressed_retval = FALSE;
384  break;
385  }
386  }
387  while (response == GNC_RESPONSE_NEW);
388 
389  g_object_unref(G_OBJECT(builder));
390  gtk_widget_destroy(picker->dialog);
391  }
392  else
393  {
394  retval_name = retval ? xaccAccountGetName(retval) : NULL;
395  ok_pressed_retval = TRUE; /* There was no dialog involved, so the computer "pressed" ok */
396  }
397  /*FIXME: DEBUG("WRITEME: gnc_import_select_account() Here we should check if account type is compatible, currency matches, etc.\n"); */
398  g_free(picker);
399  /*DEBUG("Return value: %p%s%s%s",retval,", account name:",xaccAccountGetName(retval),"\n");*/
400  if (ok_pressed != NULL)
401  {
402  *ok_pressed = ok_pressed_retval;
403  }
404  LEAVE("Selected account %p, %s", retval, retval_name ? retval_name : "(null)");
405  return retval;
406 }
STRUCTS.
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:255
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 'func' on each...
Definition: Account.c:2960
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:237
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:261
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.c:3894
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:271
const char * xaccAccountGetName(const Account *acc)
Get the account's name.
Definition: Account.c:3012
const char * xaccAccountGetTypeStr(GNCAccountType type)
The xaccAccountGetTypeStr() routine returns a string suitable for use in the GUI/Interface.
Definition: Account.c:4123
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 
82 
83  /*Nested loop*/
84  commodity_list = gnc_commodity_table_get_commodities(commodity_table,
85  tmp_namespace);
86  commodity_list = g_list_first(commodity_list);
87  while ( commodity_list != NULL && retval == NULL)
88  {
89  tmp_commodity = commodity_list->data;
90  DEBUG("Looking at commodity %s", gnc_commodity_get_fullname(tmp_commodity));
91 
92  if (gnc_commodity_get_cusip(tmp_commodity) != NULL &&
93  cusip != NULL &&
94  strncmp(gnc_commodity_get_cusip(tmp_commodity), cusip, strlen(cusip)) == 0)
95  {
96  retval = tmp_commodity;
97  DEBUG("Commodity %s%s", gnc_commodity_get_fullname(retval), " matches.");
98  }
99  commodity_list = g_list_next(commodity_list);
100  }
101  /*End nested loop*/
102 
103  namespace_list = g_list_next(namespace_list);
104  }
105 
106 
107 
108 
109  g_list_free(commodity_list);
110  g_list_free(namespace_list);
111 
112  if (retval == NULL && ask_on_unknown != 0)
113  {
114  const gchar *message =
115  _("Please select a commodity to match the following exchange "
116  "specific code. Please note that the exchange code of the "
117  "commodity you select will be overwritten.");
119  NULL,
121  message,
122  cusip,
123  default_fullname,
124  default_mnemonic);
125 
126  }
127  /* There seems to be a problem here - if the matched commodity does not
128  have a cusip defined (gnc_commodity_get_cusip returns NULL) then
129  it does not get overwritten - which is not consistent with the
130  message - so Im adding it to do this. Looks like this is all
131  that was needed to fix the cash value used as stock units problem
132  for pre-defined commodities which didnt have the cusip defined! */
133  if (retval != NULL &&
134  gnc_commodity_get_cusip(retval) != NULL &&
135  cusip != NULL &&
136  (strncmp(gnc_commodity_get_cusip(retval), cusip, strlen(cusip)) != 0))
137  {
138  gnc_commodity_set_cusip(retval, cusip);
139  }
140  else if (gnc_commodity_get_cusip(retval) == NULL && cusip != NULL)
141  {
142  gnc_commodity_set_cusip(retval, cusip);
143  }
144  return retval;
145 };
const char * gnc_commodity_get_cusip(const gnc_commodity *cm)
Retrieve the 'exchange code' for the specified commodity.
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:255
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 'exchange code' 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.
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 };
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 }
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 }
GNCImportAction gnc_import_TransInfo_get_action ( const GNCImportTransInfo *  info)

Returns the currently selected action for this TransInfo.

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

177 {
178  g_assert (info);
179  return info->action;
180 }
Account * gnc_import_TransInfo_get_destacc ( const GNCImportTransInfo *  info)

Returns the 'other account' of this transaction.

May return NULL.

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

196 {
197  g_assert (info);
198  return info->dest_acc;
199 }
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 216 of file import-backend.c.

217 {
218  g_assert (info);
219  return info->dest_acc_selected_manually;
220 }
Split * gnc_import_TransInfo_get_fsplit ( const GNCImportTransInfo *  info)

Returns the first split of the transaction of this TransInfo.

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

146 {
147  g_assert (info);
148  return info->first_split;
149 }
GList * gnc_import_TransInfo_get_match_list ( const GNCImportTransInfo *  info)

Returns the stored list of possible matches.

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

115 {
116  g_assert (info);
117  return info->match_list;
118 }
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 169 of file import-backend.c.

170 {
171  g_assert (info);
172  return info->match_selected_manually;
173 }
guint32 gnc_import_TransInfo_get_ref_id ( const GNCImportTransInfo *  info)

Returns the reference id for this TransInfo.

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

224 {
225  g_assert (info);
226  return info->ref_id;
227 }
GNCImportMatchInfo * gnc_import_TransInfo_get_selected_match ( const GNCImportTransInfo *  info)

Returns the currently selected match in this TransInfo.

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

153 {
154  g_assert (info);
155  return info->selected_match_info;
156 }
Transaction * gnc_import_TransInfo_get_trans ( const GNCImportTransInfo *  info)

Returns the transaction of this TransInfo.

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

122 {
123  g_assert (info);
124  return info->trans;
125 }
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  trans_info->selected_match_info = best_match;
1225  }
1226  else if (best_match == NULL ||
1227  best_match->probability <= gnc_import_Settings_get_add_threshold(settings))
1228  {
1229  trans_info->action = GNCImport_ADD;
1230  }
1232  {
1233  trans_info->action = GNCImport_SKIP;
1234  }
1236  {
1237  trans_info->action = GNCImport_UPDATE;
1238  }
1239  else
1240  {
1241  trans_info->action = GNCImport_ADD;
1242  }
1243  }
1244  else
1245  {
1246  trans_info->action = GNCImport_ADD;
1247  }
1248  if (best_match &&
1249  trans_info->action == GNCImport_CLEAR &&
1251  {
1252  if (best_match->update_proposed)
1253  {
1254  trans_info->action = GNCImport_UPDATE;
1255  }
1256  }
1257 
1258  trans_info->previous_action = trans_info->action;
1259 }
gint gnc_import_Settings_get_clear_threshold(GNCImportSettings *settings)
Return the selected threshold.
gint gnc_import_Settings_get_display_threshold(GNCImportSettings *settings)
Return the selected threshold.
void gnc_import_TransInfo_set_selected_match(GNCImportTransInfo *info, GNCImportMatchInfo *match, gboolean selected_manually)
Sets the currently selected match in this TransInfo.
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.
gboolean gnc_import_TransInfo_is_balanced ( const GNCImportTransInfo *  info)

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

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

129 {
130  g_assert (info);
131  /* Assume that the importer won't create a transaction that involves two or more
132  currencies and no non-currency commodity. In that case can use the simpler
133  value imbalance check. */
135  {
136  return TRUE;
137  }
138  else
139  {
140  return FALSE;
141  }
142 }
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.
Definition: gnc-numeric.cpp:96
gnc_numeric xaccTransGetImbalanceValue(const Transaction *trans)
The xaccTransGetImbalanceValue() method returns the total value of the transaction.
Definition: Transaction.c:1043
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:2212
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).
void gnc_import_TransInfo_set_action ( GNCImportTransInfo *  info,
GNCImportAction  action 
)

Set the action for this TransInfo.

Also sets the previous action.

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

185 {
186  g_assert (info);
187  if (action != info->action)
188  {
189  info->previous_action = info->action;
190  info->action = action;
191  }
192 }
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 200 of file import-backend.c.

203 {
204  g_assert (info);
205  info->dest_acc = acc;
206  info->dest_acc_selected_manually = selected_manually;
207 
208  /* Store the mapping to the other account in the MatchMap. */
209  if (selected_manually)
210  {
211  matchmap_store_destination (NULL, info, FALSE);
212  }
213 }
void gnc_import_TransInfo_set_ref_id ( GNCImportTransInfo *  info,
guint32  ref_id 
)

Set the reference id for this TransInfo.

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

232 {
233  g_assert (info);
234  info->ref_id = ref_id;
235 }
void gnc_import_TransInfo_set_selected_match ( 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 159 of file import-backend.c.

162 {
163  g_assert (info);
164  info->selected_match_info = match;
165  info->match_selected_manually = selected_manually;
166 }
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 
210  builder = gtk_builder_new();
211  gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer2");
212  gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer3");
213  gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer4");
214  gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer5");
215  gnc_builder_add_from_file (builder, "dialog-import.glade", "matcher_help");
216 
217  box = GTK_WIDGET(gtk_builder_get_object (builder, "red"));
218  gtk_widget_modify_bg(box, GTK_STATE_NORMAL, &info->color_back_red);
219  box = GTK_WIDGET(gtk_builder_get_object (builder, "yellow"));
220  gtk_widget_modify_bg(box, GTK_STATE_NORMAL, &info->color_back_yellow);
221  box = GTK_WIDGET(gtk_builder_get_object (builder, "green"));
222  gtk_widget_modify_bg(box, GTK_STATE_NORMAL, &info->color_back_green);
223 
224  help_dialog = GTK_WIDGET(gtk_builder_get_object (builder, "matcher_help"));
225  gtk_window_set_transient_for(GTK_WINDOW(help_dialog),
226  GTK_WINDOW(info->dialog));
227 
228  /* Connect the signals */
229  gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, help_dialog);
230 
231  g_object_unref(G_OBJECT(builder));
232 
233  gtk_widget_show(help_dialog);
234 }