Main Page Modules Alphabetical List Data Structures File List Data Fields Globals

# Import_Export

## Files

file | import-account-matcher.h
| Generic and very flexible account matcher/picker.

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-map.h
| Generic import mapper service, maps strings->accounts.

file | import-match-picker.h
| The transaction match picker dialog interface.

file | import-settings.h
| Import preference handling. User preference interface for transaction matching (for both the gui and the backend).

file | import-utilities.h
| Utility functions for writing import modules.

## Data Structures

struct | _accountpickerdialog
struct | _genimportsettings
struct | _GncImportMatchMap
struct | _main_matcher_info
struct | _matchinfo
struct | _split_record
struct | _transactioninfo
struct | _transpickerdialog
struct | account_info
struct | account_probability
struct | account_token_count
struct | token_accounts_info

## Some well-known categories

NOTE: You DO NOT have to use these values in your importer -- these are just "well known" values, not "mandatory" values. You are free to use these if they apply, map your own fields to these labels, or create your own category strings.
#define | GNCIMPORT_DESC "desc"
#define | GNCIMPORT_MEMO "memo"
#define | GNCIMPORT_PAYEE "payee"

## Defines

#define | _GNU_SOURCE
#define | NUM_COLUMNS_CLIST 4
#define | IMPORT_PAGE "Online Banking & Importing"
#define | BAYES_OPTION "Use Bayesian Matching?"
#define | NUM_COLUMNS_DOWNLOADED_CLIST 9
#define | DOWNLOADED_CLIST_ACTION_ADD 5
#define | DOWNLOADED_CLIST_ACTION_CLEAR 6
#define | DOWNLOADED_CLIST_ACTION_EDIT 7
#define | DOWNLOADED_CLIST_ACTION_INFO 8
#define | IMAP_FRAME "import-map"
#define | IMAP_FRAME_BAYES "import-map-bayes"
#define | PROBABILITY_FACTOR 100000
#define | threshold (.90 * PROBABILITY_FACTOR)
#define | NUM_COLUMNS_MATCHER_CLIST 5
#define | MATCHER_PREF_PAGE "Online Banking & Importing"
#define | DEFAULT_CLEAR_THRESHOLD 6
#define | DEFAULT_ADD_THRESHOLD 3
#define | DEFAULT_DISPLAY_THRESHOLD 1
#define | DEFAULT_ATM_FEE_THRESHOLD 2.00
#define | STRING_FIELD_SIZE 256

## Typedefs

typedef _transactioninfo | GNCImportTransInfo
typedef _matchinfo | GNCImportMatchInfo
typedef enum _action | GNCImportAction
typedef _main_matcher_info | GNCImportMainMatcher
typedef _GncImportMatchMap | GncImportMatchMap
typedef _transpickerdialog | GNCImportMatchPicker
typedef _genimportsettings | GNCImportSettings
typedef _split_record | split_record

## Enumerations

enum | _action { GNCImport_SKIP, GNCImport_ADD, GNCImport_CLEAR, GNCImport_EDIT, GNCImport_LAST_ACTION, GNCImport_INVALID_ACTION }

## Functions

Account * | gnc_import_select_account (char *account_online_id_value, char auto_create, char *account_human_description, gnc_commodity *new_account_default_commodity, GNCAccountType new_account_default_type, Account *default_selection, gboolean *ok_pressed)
GList * | gnc_import_TransInfo_get_match_list (const GNCImportTransInfo *info)
Transaction * | gnc_import_TransInfo_get_trans (const GNCImportTransInfo *info)
gboolean | gnc_import_TransInfo_is_balanced (const GNCImportTransInfo *info)
Split * | gnc_import_TransInfo_get_fsplit (const GNCImportTransInfo *info)
GNCImportMatchInfo * | gnc_import_TransInfo_get_selected_match (const GNCImportTransInfo *info)
void | gnc_import_TransInfo_set_selected_match (GNCImportTransInfo *info, GNCImportMatchInfo *match, gboolean selected_manually)
gboolean | gnc_import_TransInfo_get_match_selected_manually (const GNCImportTransInfo *info)
GNCImportAction | gnc_import_TransInfo_get_action (const GNCImportTransInfo *info)
void | gnc_import_TransInfo_set_action (GNCImportTransInfo *info, GNCImportAction action)
Account * | gnc_import_TransInfo_get_destacc (const GNCImportTransInfo *info)
void | gnc_import_TransInfo_set_destacc (GNCImportTransInfo *info, Account *acc, gboolean selected_manually)
gboolean | gnc_import_TransInfo_get_destacc_selected_manually (const GNCImportTransInfo *info)
Split * | gnc_import_MatchInfo_get_split (const GNCImportMatchInfo *info)
gint | gnc_import_MatchInfo_get_probability (const GNCImportMatchInfo *info)
void | gnc_import_TransInfo_delete (GNCImportTransInfo *info)
GdkPixmap * | gen_probability_pixmap (gint score_original, GNCImportSettings *settings, GtkWidget *widget)
void | gnc_import_find_split_matches (GNCImportTransInfo *trans_info, gint process_threshold, double fuzzy_amount_difference)
void | gnc_import_process_trans_clist (GtkCList *clist, GncImportMatchMap *matchmap)
gboolean | gnc_import_exists_online_id (Transaction *trans)
GNCImportTransInfo * | gnc_import_TransInfo_new (Transaction *trans, GncImportMatchMap *matchmap)
void | gnc_import_TransInfo_init_matches (GNCImportTransInfo *trans_info, GNCImportSettings *settings)
gboolean | gnc_import_TransInfo_refresh_destacc (GNCImportTransInfo *transaction_info, GncImportMatchMap *matchmap)
gnc_commodity * | gnc_import_select_commodity (char *exchange_code, char auto_create, char *default_fullname, char *default_mnemonic)
void | gnc_gen_trans_list_delete (GNCImportMainMatcher *info)
GNCImportMainMatcher * | gnc_gen_trans_list_new (GtkWidget *parent, const gchar *heading, gboolean all_from_same_account)
gboolean | gnc_gen_trans_list_run (GNCImportMainMatcher *info)
void | gnc_gen_trans_list_add_trans (GNCImportMainMatcher *gui, Transaction *trans)
GncImportMatchMap * | gnc_imap_create_from_account (Account *acc)
GncImportMatchMap * | gnc_imap_create_from_book (GNCBook *book)
void | gnc_imap_destroy (GncImportMatchMap *imap)
void | gnc_imap_clear (GncImportMatchMap *imap)
Account * | gnc_imap_find_account (GncImportMatchMap *imap, const char *category, const char *key)
void | gnc_imap_add_account (GncImportMatchMap *imap, const char *category, const char *key, Account *acc)
Account * | gnc_imap_find_account_bayes (GncImportMatchMap *imap, GList *tokens)
void | gnc_imap_add_account_bayes (GncImportMatchMap *imap, GList *tokens, Account *acc)
void | gnc_import_match_picker_run_and_close (GNCImportTransInfo *transaction_info)
GNCImportSettings * | gnc_import_Settings_new (void)
void | gnc_import_Settings_delete (GNCImportSettings *settings)
double | gnc_import_Settings_get_fuzzy_amount (GNCImportSettings *settings)
gboolean | gnc_import_Settings_get_action_skip_enabled (GNCImportSettings *settings)
gboolean | gnc_import_Settings_get_action_add_enabled (GNCImportSettings *settings)
gboolean | gnc_import_Settings_get_action_edit_enabled (GNCImportSettings *settings)
gboolean | gnc_import_Settings_get_action_clear_enabled (GNCImportSettings *settings)
gint | gnc_import_Settings_get_clear_threshold (GNCImportSettings *settings)
gint | gnc_import_Settings_get_add_threshold (GNCImportSettings *settings)
gint | gnc_import_Settings_get_display_threshold (GNCImportSettings *settings)
const gchar * | gnc_import_get_acc_online_id (Account *account)
void | gnc_import_set_acc_online_id (Account *account, const gchar *string_value)
const gchar * | gnc_import_get_trans_online_id (Transaction *transaction)
void | gnc_import_set_trans_online_id (Transaction *transaction, const gchar *string_value)
SCM | scm_gnc_file_log_replay ()
char * | libgncmod_log_replay_LTX_gnc_module_path (void)
char * | libgncmod_log_replay_LTX_gnc_module_description (void)
int | libgncmod_log_replay_LTX_gnc_module_init (int refcount)
int | libgncmod_log_replay_LTX_gnc_module_end (int refcount)
SCM | scm_gnc_file_ofx_import ()
void | gnc_file_ofx_import (void)
int | ofx_proc_status_cb (struct OfxStatusData data)
int | ofx_proc_security_cb (const struct OfxSecurityData data)
int | ofx_proc_transaction_cb (struct OfxTransactionData data)
int | ofx_proc_statement_cb (struct OfxStatementData data)
int | ofx_proc_account_cb (struct OfxAccountData data)
char * | libgncmod_ofx_LTX_gnc_module_path (void)
char * | libgncmod_ofx_LTX_gnc_module_description (void)
int | libgncmod_ofx_LTX_gnc_module_init (int refcount)
int | libgncmod_ofx_LTX_gnc_module_end (int refcount)

## Variables

const char * | delim
int | libgncmod_log_replay_LTX_gnc_module_system_interface = 0
int | libgncmod_log_replay_LTX_gnc_module_current = 0
int | libgncmod_log_replay_LTX_gnc_module_revision = 0
int | libgncmod_log_replay_LTX_gnc_module_age = 0
GNCImportMainMatcher * | gnc_ofx_importer_gui = NULL
int | libgncmod_ofx_LTX_gnc_module_system_interface = 0
int | libgncmod_ofx_LTX_gnc_module_current = 0
int | libgncmod_ofx_LTX_gnc_module_revision = 0
int | libgncmod_ofx_LTX_gnc_module_age = 0

## Define Documentation

#define DEFAULT_ADD_THRESHOLD 3

| Transaction who's best match probability is below or equal to this will be added as new by default

#define DEFAULT_CLEAR_THRESHOLD 6

| Transaction who's best match probability is equal or higher than this will reconcile their best match by default

#define DEFAULT_DISPLAY_THRESHOLD 1

| Transaction's match probability must be at least this much to be displayed in the match list. Dont set this to 0 except for debugging purposes, otherwise all transactions of every accounts will be shown in the list

## Function Documentation

GdkPixmap* gen_probability_pixmap | ( | 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:

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

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.

void gnc_gen_trans_list_add_trans | ( | GNCImportMainMatcher * | gui,
|  | Transaction * | trans
| ) |

Add a newly imported Transaction to the Transaction Importer.

Parameters:

  gui | The Transaction Importer to use.
  trans | The 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.

void gnc_gen_trans_list_delete | ( | GNCImportMainMatcher * | info | ) |

| Deletes the given object.

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

Create a new generic transaction dialog window and return it.

Parameters:

  parent | The parent GtkWidget. May be NULL.
  heading | The heading label in the Importer window. May be NULL.
  all_from_same_account | Set 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.

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.

void gnc_imap_add_account | ( | GncImportMatchMap * | imap,
|  | const char * | category,
|  | const char * | key,
|  | Account * | acc
| ) |

| Store an Account in the map. This mapping is immediatly stored in the underlying kvp frame, regardless of whether the MatchMap is destroyed later or not.

void gnc_imap_add_account_bayes | ( | GncImportMatchMap * | imap,
|  | GList * | tokens,
|  | Account * | acc
| ) |

| Store an Account in the map. This mapping is immediatly stored in the underlying kvp frame, regardless of whether the MatchMap is destroyed later or not.

void gnc_imap_clear | ( | GncImportMatchMap * | imap | ) |

| Clear an import map -- this removes ALL entries in the map

GncImportMatchMap* gnc_imap_create_from_account | ( | Account * | acc | ) |

| Obtain an ImportMatchMap object from an Account or a Book

void gnc_imap_destroy | ( | GncImportMatchMap * | imap | ) |

| Destroy an import map. But all stored entries will still continue to exist in the underlying kvp frame of the account or book.

Account* gnc_imap_find_account | ( | GncImportMatchMap * | imap,
|  | const char * | category,
|  | const char * | key
| ) |

| Look up an Account in the map

Account* gnc_imap_find_account_bayes | ( | GncImportMatchMap * | imap,
|  | GList * | tokens
| ) |

| Look up an Account in the map from a GList* of pointers to strings(tokens) from the current transaction

gboolean gnc_import_exists_online_id | ( | Transaction * | trans | ) |

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

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

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

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. This functions will only return after the user clicked Ok, Cancel, or Window-Close.

gint gnc_import_MatchInfo_get_probability | ( | const GNCImportMatchInfo * | info | ) |

Get the probability (confidence level) of this MatchInfo.

Parameters:

  info | Can be NULL, in which case the function returns 0

Split* gnc_import_MatchInfo_get_split | ( | const GNCImportMatchInfo * | info | ) |

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

void gnc_import_process_trans_clist | ( | GtkCList * | clist,
|  | GncImportMatchMap * | matchmap
| ) |

| /brief -- Processes every selected match according to its selected action.

Account* gnc_import_select_account | ( | char * | account_online_id_value,
|  | char | auto_create,
|  | char * | account_human_description,
|  | 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 kvp_frame 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's kvp_frame, so the user won't be prompted again). If the user refuses to select or create an account, NULL is returned.

Parameters:

  account_online_id_value | The string containing your unique account_id coming from some string of your module. This is the normal mode of operation.

If account_online_id_value==NULL, you basically end up with an account selector that allows you to select an account whose GUID 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 kvp_frame of the found account will not be touched. To use this mode, auto_create must NOT be set to 0.

Parameters:

  account_human_description | A 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_commodity | Default 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_type | Default account type of a new account. Can be NULL. If not NO_TYPE, it will be the account's type if a new account is created. If not NO_TYPE, the function will also warn the user if the found or created account's commodity doesn't match.
  auto_create | If 0, if the account_online_id_value in unknown, the function returns NULL, otherwise, the user will be asked to create a new account.
  default_selection | If not NULL, that account will be pre-selected by default.
  ok_pressed | A 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.

gnc_commodity* gnc_import_select_commodity | ( | char * | exchange_code,
|  | char | auto_create,
|  | char * | default_fullname,
|  | char * | default_mnemonic
| ) |

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

Parameters:

  exchange_code | The 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.
  auto_create | If 0, if the exchange_code value in unknown, the function returns NULL, otherwise, the user will be asked to create a new account.
  default_fullname | A 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_mnemonic | Usually 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 account was found or created.

void gnc_import_Settings_delete | ( | GNCImportSettings * | settings | ) |

| Destructor

gboolean gnc_import_Settings_get_action_add_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.

gboolean gnc_import_Settings_get_action_edit_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.

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.

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.

GNCImportSettings* gnc_import_Settings_new | ( | void |  | ) |

| Allocates a new GNCImportSettings object, and initialize it with the appropriate user prefs.

void gnc_import_TransInfo_delete | ( | GNCImportTransInfo * | info | ) |

| Destructor

GNCImportAction gnc_import_TransInfo_get_action | ( | const GNCImportTransInfo * | info | ) |

| Returns the currently selected action for this TransInfo.

Account* gnc_import_TransInfo_get_destacc | ( | const GNCImportTransInfo * | info | ) |

| Returns the 'other account' of this transaction. May return NULL.

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.

Split* gnc_import_TransInfo_get_fsplit | ( | const GNCImportTransInfo * | info | ) |

| Returns the first split of the transaction of this TransInfo.

GList* gnc_import_TransInfo_get_match_list | ( | const GNCImportTransInfo * | info | ) |

| Returns the stored list of possible matches.

gboolean gnc_import_TransInfo_get_match_selected_manually | ( | const GNCImportTransInfo * | info | ) |

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

GNCImportMatchInfo* gnc_import_TransInfo_get_selected_match | ( | const GNCImportTransInfo * | info | ) |

| Returns the currently selected match in this TransInfo.

Transaction* gnc_import_TransInfo_get_trans | ( | const GNCImportTransInfo * | info | ) |

| Returns the transaction of this TransInfo.

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.

gboolean gnc_import_TransInfo_is_balanced | ( | const GNCImportTransInfo * | info | ) |

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

GNCImportTransInfo* gnc_import_TransInfo_new | ( | Transaction * | trans,
|  | GncImportMatchMap * | matchmap
| ) |

| Create a new object of GNCImportTransInfo here.

gboolean gnc_import_TransInfo_refresh_destacc | ( | GNCImportTransInfo * | transaction_info,
|  | GncImportMatchMap * | matchmap
| ) |

| Try to automatch a given transaction to a destination account

void gnc_import_TransInfo_set_action | ( | GNCImportTransInfo * | info,
|  | GNCImportAction | action
| ) |

| Set the action for this TransInfo. Also sets the previous action.

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_manually | TRUE or FALSE; Was this account set as a result of a selection by the user or by an algorithm?

void gnc_import_TransInfo_set_selected_match | ( | GNCImportTransInfo * | info,
|  | GNCImportMatchInfo * | match,
|  | gboolean | selected_manually
| ) |

Sets the currently selected match in this TransInfo.

Parameters:

  selected_manually | TRUE or FALSE; Was this match set as a result of a selection by the user or by an algorithm?