GnuCash c935c2f+
Loading...
Searching...
No Matches
Modules | Files | Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
Import_Export

Modules

 AqBanking
 

Files

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

Data Structures

struct  AccountOnlineMatch
 
struct  AccountPickerDialog
 
struct  GNCImportSelectedMatchInfo
 
struct  GNCImportTransInfo
 
struct  GNCImportMatchInfo
 
struct  GNCImportLastSplitInfo
 
struct  GNCImportMainMatcher
 
class  TreeRowRefDestructor
 
class  RowInfo
 
struct  EntryInfo
 
struct  match_struct
 
struct  GNCImportMatchPicker
 
struct  GNCPendingMatches
 
struct  GNCImportSettings
 
struct  split_record
 
struct  ofx_info
 
struct  InvestmentAcctData
 

Macros

#define STATE_SECTION   "dialogs/import/generic_matcher/account_matcher"
 
#define GNC_PREFS_GROUP   "dialogs.import.generic.account-picker"
 
#define GNCIMPORT_DESC   "desc"
 
#define GNCIMPORT_MEMO   "memo"
 
#define GNCIMPORT_PAYEE   "payee"
 
#define GNC_PREFS_GROUP   "dialogs.import.generic.transaction-list"
 
#define IMPORT_MAIN_MATCHER_CM_CLASS   "transaction-matcher-dialog"
 
#define CSS_INT_REQUIRED_CLASS   "gnc-class-intervention-required"
 
#define CSS_INT_PROB_REQUIRED_CLASS   "gnc-class-intervention-probably-required"
 
#define CSS_INT_NOT_REQUIRED_CLASS   "gnc-class-intervention-not-required"
 
#define G_MOD_IMPORT_MATCHER   "gnc.import.main-matcher"
 
#define GNC_PREFS_GROUP   "dialogs.import.generic.match-picker"
 
#define GNC_PREF_DISPLAY_RECONCILED   "display-reconciled"
 
#define GNC_PREFS_GROUP_IMPORT   "dialogs.import.generic"
 The preferences used by the importer.
 
#define GNC_PREF_ENABLE_SKIP   "enable-skip"
 
#define GNC_PREF_ENABLE_UPDATE   "enable-update"
 
#define GNC_PREF_USE_BAYES   "use-bayes"
 
#define GNC_PREF_ATM_FEE_THRESHOLD   "atm-fee-threshold"
 
#define GNC_PREF_AUTO_CLEAR_THRESHOLD   "auto-clear-threshold"
 
#define GNC_PREF_AUTO_ADD_THRESHOLD   "auto-add-threshold"
 
#define GNC_PREF_MATCH_THRESHOLD   "match-threshold"
 
#define GNC_PREF_MATCH_DATE_THRESHOLD   "match-date-threshold"
 
#define GNC_PREF_MATCH_DATE_NOT_THRESHOLD   "match-date-not-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

using StrStrMap = std::unordered_map< std::string, std::string >
 
using TreeRowReferencePtr = std::unique_ptr< GtkTreeRowReference, TreeRowRefDestructor >
 
typedef void(* GNCTransactionProcessedCB) (GNCImportTransInfo *trans_info, gboolean imported, gpointer user_data)
 
typedef GHashTable GNCImportPendingMatches
 
typedef struct OfxTransactionData OfxTransactionData
 

Enumerations

enum  GNCImportAction {
  GNCImport_SKIP , GNCImport_ADD , GNCImport_CLEAR , GNCImport_UPDATE ,
  GNCImport_LAST_ACTION , GNCImport_INVALID_ACTION
}
 
enum  downloaded_cols {
  DOWNLOADED_COL_DATE_TXT = 0 , DOWNLOADED_COL_DATE_INT64 , DOWNLOADED_COL_ACCOUNT , DOWNLOADED_COL_AMOUNT ,
  DOWNLOADED_COL_AMOUNT_DOUBLE , DOWNLOADED_COL_DESCRIPTION , DOWNLOADED_COL_DESCRIPTION_ORIGINAL , DOWNLOADED_COL_DESCRIPTION_STYLE ,
  DOWNLOADED_COL_MEMO , DOWNLOADED_COL_MEMO_ORIGINAL , DOWNLOADED_COL_MEMO_STYLE , DOWNLOADED_COL_NOTES_ORIGINAL ,
  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 , DOWNLOADED_COL_ENABLE ,
  NUM_DOWNLOADED_COLS
}
 
enum  { COMPLETION_LIST_ORIGINAL , COMPLETION_LIST_NORMALIZED_FOLDED , NUM_COMPLETION_COLS }
 
enum  downloaded_cols {
  DOWNLOADED_COL_ACCOUNT = 0 , DOWNLOADED_COL_DATE , DOWNLOADED_COL_AMOUNT , DOWNLOADED_COL_DESCRIPTION ,
  DOWNLOADED_COL_MEMO , DOWNLOADED_COL_BALANCED , DOWNLOADED_COL_INFO_PTR , NUM_DOWNLOADED_COLS
}
 
enum  matcher_cols {
  MATCHER_COL_CONFIDENCE = 0 , MATCHER_COL_CONFIDENCE_PIXBUF , MATCHER_COL_DATE , MATCHER_COL_AMOUNT ,
  MATCHER_COL_DESCRIPTION , MATCHER_COL_MEMO , MATCHER_COL_RECONCILED , MATCHER_COL_PENDING ,
  MATCHER_COL_INFO_PTR , NUM_MATCHER_COLS
}
 
enum  GNCImportPendingMatchType { GNCImportPending_NONE , GNCImportPending_AUTO , GNCImportPending_MANUAL }
 

Functions

Accountgnc_import_select_account (GtkWidget *parent, const gchar *account_online_id_value, gboolean prompt_on_no_match, 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.
 
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.
 
void on_matcher_ok_clicked (GtkButton *button, GNCImportMainMatcher *info)
 
void on_matcher_cancel_clicked (GtkButton *button, gpointer user_data)
 
bool on_matcher_delete_event (GtkWidget *widget, GdkEvent *event, gpointer 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.
 
void on_matcher_help_close_clicked (GtkButton *button, gpointer user_data)
 
void gnc_gen_trans_list_delete (GNCImportMainMatcher *info)
 Deletes the given object.
 
bool gnc_gen_trans_list_empty (GNCImportMainMatcher *info)
 Checks whether there are no transactions to match.
 
void gnc_gen_trans_list_show_all (GNCImportMainMatcher *info)
 Shows widgets.
 
GNCImportMainMatcher * gnc_gen_trans_list_new (GtkWidget *parent, const gchar *heading, bool all_from_same_account, gint match_date_hardlimit, bool show_all)
 Create a new generic transaction dialog window and return it.
 
GNCImportMainMatcher * gnc_gen_trans_assist_new (GtkWidget *parent, GtkWidget *assistant_page, const gchar *heading, bool all_from_same_account, gint match_date_hardlimit)
 Add the Transaction matcher to an existing page of an assistant.
 
void gnc_gen_trans_assist_start (GNCImportMainMatcher *info)
 This starts the import process for transaction from an assistant.
 
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.
 
bool gnc_gen_trans_list_run (GNCImportMainMatcher *info)
 Run this dialog and return only after the user pressed Ok, Cancel, or closed the window.
 
void gnc_gen_trans_list_show_reconcile_after_close_button (GNCImportMainMatcher *info, bool reconcile_after_close, bool active)
 Show and set the reconcile after close check button.
 
GtkWidget * gnc_gen_trans_list_get_reconcile_after_close_button (GNCImportMainMatcher *info)
 Returns the reconcile after close check button.
 
void gnc_gen_trans_list_add_trans (GNCImportMainMatcher *gui, Transaction *trans)
 Add a newly imported Transaction to the Transaction Importer.
 
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.
 
void gnc_gen_trans_list_add_trans_with_split_data (GNCImportMainMatcher *gui, Transaction *trans, GNCImportLastSplitInfo *lsplit)
 Add a newly imported Transaction to the Transaction Importer.
 
GtkWidget * gnc_gen_trans_list_widget (GNCImportMainMatcher *info)
 Returns the widget of this dialog.
 
GtkWidget * gnc_gen_trans_list_append_text_widget (GNCImportMainMatcher *info)
 Returns the append_text widget of this dialog.
 
void gnc_import_match_picker_run_and_close (GtkWidget *parent, GNCImportTransInfo *transaction_info, GNCImportPendingMatches *pending_matches)
 Run a match_picker dialog so that the selected-MatchInfo in the given trans_info is updated accordingly.
 
GNCImportPendingMatches * gnc_import_PendingMatches_new (void)
 
void gnc_import_PendingMatches_delete (GNCImportPendingMatches *map)
 
void gnc_import_PendingMatches_add_match (GNCImportPendingMatches *map, GNCImportMatchInfo *match_info, gboolean selected_manually)
 
void gnc_import_PendingMatches_remove_match (GNCImportPendingMatches *map, GNCImportMatchInfo *match_info, gboolean selected_manually)
 
GNCImportPendingMatchType gnc_import_PendingMatches_get_match_type (GNCImportPendingMatches *map, GNCImportMatchInfo *match_info)
 
const char * gnc_import_PendingMatches_get_type_str (GNCImportPendingMatchType type)
 
GNCImportSettings * gnc_import_Settings_new (void)
 Allocates a new GNCImportSettings object, and initialize it with the appropriate user prefs.
 
void gnc_import_Settings_delete (GNCImportSettings *settings)
 Destructor.
 
void gnc_file_log_replay (GtkWindow *parent)
 The gnc_file_log_replay() routine will pop up a standard file selection dialogue asking the user to pick a log file to replay.
 
int ofx_proc_statement_cb (struct OfxStatementData data, void *statement_user_data)
 
int ofx_proc_security_cb (const struct OfxSecurityData data, void *security_user_data)
 
int ofx_proc_transaction_cb (OfxTransactionData data, void *user_data)
 
int ofx_proc_account_cb (struct OfxAccountData data, void *account_user_data)
 
void gnc_file_ofx_import (GtkWindow *parent)
 The gnc_file_ofx_import() routine will pop up a standard file selection dialogue asking the user to pick a OFX/QFX file.
 
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

gint GNCPendingMatches::num_manual_matches
 
gint GNCPendingMatches::num_auto_matches
 
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
 

Getters/Setters for GNCImportTransInfo

GList * gnc_import_TransInfo_get_match_list (const GNCImportTransInfo *info)
 Returns the stored list of possible matches.
 
void gnc_import_TransInfo_remove_top_match (GNCImportTransInfo *info)
 Remove the first match in the list of possible matches

 
Transaction * gnc_import_TransInfo_get_trans (const GNCImportTransInfo *info)
 Returns the transaction of this TransInfo.
 
gboolean gnc_import_TransInfo_is_balanced (const GNCImportTransInfo *info)
 Returns if the transaction stored in the TransInfo is currently balanced.
 
Split * gnc_import_TransInfo_get_fsplit (const GNCImportTransInfo *info)
 Returns the first split of the transaction of this TransInfo.
 
GNCImportMatchInfognc_import_TransInfo_get_selected_match (const GNCImportTransInfo *info)
 Returns the currently selected match in this TransInfo.
 
void gnc_import_TransInfo_set_selected_match_info (GNCImportTransInfo *info, GNCImportMatchInfo *match, gboolean selected_manually)
 Sets the currently selected match in this TransInfo.
 
gboolean gnc_import_TransInfo_get_match_selected_manually (const GNCImportTransInfo *info)
 Returns if the currently selected match was selected by the user.
 
GNCImportAction gnc_import_TransInfo_get_action (const GNCImportTransInfo *info)
 Returns the currently selected action for this TransInfo.
 
void gnc_import_TransInfo_set_action (GNCImportTransInfo *info, GNCImportAction action)
 Set the action for this TransInfo.
 
Accountgnc_import_TransInfo_get_destacc (const GNCImportTransInfo *info)
 Returns the 'other account' of this transaction.
 
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).
 
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.
 
guint32 gnc_import_TransInfo_get_ref_id (const GNCImportTransInfo *info)
 Returns the reference id for this TransInfo.
 
void gnc_import_TransInfo_set_ref_id (GNCImportTransInfo *info, guint32 ref_id)
 Set the reference id for this TransInfo.
 
gnc_numeric gnc_import_TransInfo_get_price (const GNCImportTransInfo *info)
 Returns the exchange rate for this TransInfo.
 
void gnc_import_TransInfo_set_price (GNCImportTransInfo *info, gnc_numeric lprice)
 Set the exchange rate for this TransInfo.
 
gnc_numeric gnc_import_TransInfo_get_dest_amount (const GNCImportTransInfo *info)
 Returns the destination split amount for this TransInfo.
 
gnc_numeric gnc_import_TransInfo_get_dest_value (const GNCImportTransInfo *info)
 Returns the destination split value for this TransInfo.
 
void gnc_import_TransInfo_set_last_split_info (GNCImportTransInfo *info, GNCImportLastSplitInfo *lsplit)
 Sets additional parameters to be used to generate the closing split.
 
void gnc_import_TransInfo_set_append_text (GNCImportTransInfo *info, gboolean append_text)
 Set the append_text for this TransInfo.
 
void gnc_import_TransInfo_delete (GNCImportTransInfo *info)
 Destructor.
 
GNCImportTransInfo * gnc_import_TransInfo_new (Transaction *trans, Account *base_acc)
 Create a new object of GNCImportTransInfo here.
 

Getters/Setters for GNCImportMatchInfo

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

Non-GUI Functions

GdkPixbuf * gen_probability_pixbuf (gint score, GNCImportSettings *settings, GtkWidget *widget)
 This function generates a new pixmap representing a match score.
 
void split_find_match (GNCImportTransInfo *trans_info, Split *split, gint display_threshold, gint date_threshold, gint date_not_threshold, double fuzzy_amount_difference)
 The transaction matching heuristics are here.
 
gboolean gnc_import_process_trans_item (Account *base_acc, GNCImportTransInfo *trans_info)
 /brief – Processes one match according to its selected action.
 
gboolean gnc_import_exists_online_id (Transaction *trans, GHashTable *acct_id_hash)
 Checks whether the given transaction's online_id already exists in its parent account.
 
void gnc_import_TransInfo_init_matches (GNCImportTransInfo *trans_info, GNCImportSettings *settings)
 Iterates through all splits of trans_info's originating account match list.
 

Getters/Setters for GNCImportSettings

double gnc_import_Settings_get_fuzzy_amount (GNCImportSettings *settings)
 Return the allowed amount range for fuzzy amount matching.
 
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.
 
gint gnc_import_Settings_get_date_threshold (GNCImportSettings *settings)
 
gint gnc_import_Settings_get_date_not_threshold (GNCImportSettings *settings)
 
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.
 

Detailed Description

Macro Definition Documentation

◆ CSS_INT_NOT_REQUIRED_CLASS

#define CSS_INT_NOT_REQUIRED_CLASS   "gnc-class-intervention-not-required"

Definition at line 133 of file import-main-matcher.cpp.

◆ CSS_INT_PROB_REQUIRED_CLASS

#define CSS_INT_PROB_REQUIRED_CLASS   "gnc-class-intervention-probably-required"

Definition at line 132 of file import-main-matcher.cpp.

◆ CSS_INT_REQUIRED_CLASS

#define CSS_INT_REQUIRED_CLASS   "gnc-class-intervention-required"

Definition at line 131 of file import-main-matcher.cpp.

◆ G_MOD_IMPORT_MATCHER

#define G_MOD_IMPORT_MATCHER   "gnc.import.main-matcher"

Definition at line 136 of file import-main-matcher.cpp.

◆ GNC_PREF_ATM_FEE_THRESHOLD

#define GNC_PREF_ATM_FEE_THRESHOLD   "atm-fee-threshold"

Definition at line 34 of file import-utilities.h.

◆ GNC_PREF_AUTO_ADD_THRESHOLD

#define GNC_PREF_AUTO_ADD_THRESHOLD   "auto-add-threshold"

Definition at line 36 of file import-utilities.h.

◆ GNC_PREF_AUTO_CLEAR_THRESHOLD

#define GNC_PREF_AUTO_CLEAR_THRESHOLD   "auto-clear-threshold"

Definition at line 35 of file import-utilities.h.

◆ GNC_PREF_AUTO_COMMODITY

#define GNC_PREF_AUTO_COMMODITY   "auto-create-commodity"

Definition at line 62 of file gnc-ofx-import.cpp.

◆ GNC_PREF_DISPLAY_RECONCILED

#define GNC_PREF_DISPLAY_RECONCILED   "display-reconciled"

Definition at line 45 of file import-match-picker.cpp.

◆ GNC_PREF_ENABLE_SKIP

#define GNC_PREF_ENABLE_SKIP   "enable-skip"

Definition at line 31 of file import-utilities.h.

◆ GNC_PREF_ENABLE_UPDATE

#define GNC_PREF_ENABLE_UPDATE   "enable-update"

Definition at line 32 of file import-utilities.h.

◆ GNC_PREF_MATCH_DATE_NOT_THRESHOLD

#define GNC_PREF_MATCH_DATE_NOT_THRESHOLD   "match-date-not-threshold"

Definition at line 39 of file import-utilities.h.

◆ GNC_PREF_MATCH_DATE_THRESHOLD

#define GNC_PREF_MATCH_DATE_THRESHOLD   "match-date-threshold"

Definition at line 38 of file import-utilities.h.

◆ GNC_PREF_MATCH_THRESHOLD

#define GNC_PREF_MATCH_THRESHOLD   "match-threshold"

Definition at line 37 of file import-utilities.h.

◆ GNC_PREF_USE_BAYES

#define GNC_PREF_USE_BAYES   "use-bayes"

Definition at line 33 of file import-utilities.h.

◆ GNC_PREFS_GROUP [1/5]

#define GNC_PREFS_GROUP   "dialogs.import.generic.account-picker"

Definition at line 50 of file import-account-matcher.cpp.

◆ GNC_PREFS_GROUP [2/5]

#define GNC_PREFS_GROUP   "dialogs.import.generic.transaction-list"

Definition at line 66 of file import-main-matcher.cpp.

◆ GNC_PREFS_GROUP [3/5]

#define GNC_PREFS_GROUP   "dialogs.import.generic.match-picker"

Definition at line 44 of file import-match-picker.cpp.

◆ GNC_PREFS_GROUP [4/5]

#define GNC_PREFS_GROUP   "dialogs.log-replay"

Definition at line 47 of file gnc-log-replay.cpp.

◆ GNC_PREFS_GROUP [5/5]

#define GNC_PREFS_GROUP   "dialogs.import.ofx"

Definition at line 61 of file gnc-ofx-import.cpp.

◆ GNC_PREFS_GROUP_IMPORT

#define GNC_PREFS_GROUP_IMPORT   "dialogs.import.generic"

The preferences used by the importer.

Definition at line 30 of file import-utilities.h.

◆ GNCIMPORT_DESC

#define GNCIMPORT_DESC   "desc"

Definition at line 51 of file import-backend.cpp.

◆ GNCIMPORT_MEMO

#define GNCIMPORT_MEMO   "memo"

Definition at line 52 of file import-backend.cpp.

◆ GNCIMPORT_PAYEE

#define GNCIMPORT_PAYEE   "payee"

Definition at line 53 of file import-backend.cpp.

◆ IMPORT_MAIN_MATCHER_CM_CLASS

#define IMPORT_MAIN_MATCHER_CM_CLASS   "transaction-matcher-dialog"

Definition at line 67 of file import-main-matcher.cpp.

◆ STATE_SECTION

#define STATE_SECTION   "dialogs/import/generic_matcher/account_matcher"

Definition at line 48 of file import-account-matcher.cpp.

◆ STRING_FIELD_SIZE

#define STRING_FIELD_SIZE   256

Definition at line 62 of file gnc-log-replay.cpp.

Typedef Documentation

◆ GNCImportPendingMatches

typedef GHashTable GNCImportPendingMatches

Definition at line 36 of file import-pending-matches.h.

◆ GNCTransactionProcessedCB

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

Definition at line 48 of file import-main-matcher.h.

◆ OfxTransactionData

typedef struct OfxTransactionData OfxTransactionData

Definition at line 74 of file gnc-ofx-import.cpp.

◆ StrStrMap

using StrStrMap = std::unordered_map<std::string,std::string>

Definition at line 69 of file import-main-matcher.cpp.

◆ TreeRowReferencePtr

using TreeRowReferencePtr = std::unique_ptr<GtkTreeRowReference, TreeRowRefDestructor>

Definition at line 821 of file import-main-matcher.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Definition at line 938 of file import-main-matcher.cpp.

939{
940 COMPLETION_LIST_ORIGINAL,
941 COMPLETION_LIST_NORMALIZED_FOLDED,
942 NUM_COMPLETION_COLS
943};

◆ downloaded_cols [1/2]

enum downloaded_cols

Definition at line 106 of file import-main-matcher.cpp.

107{
108 DOWNLOADED_COL_DATE_TXT = 0,
109 DOWNLOADED_COL_DATE_INT64, // used only for sorting
110 DOWNLOADED_COL_ACCOUNT,
111 DOWNLOADED_COL_AMOUNT,
112 DOWNLOADED_COL_AMOUNT_DOUBLE, // used only for sorting
113 DOWNLOADED_COL_DESCRIPTION,
114 DOWNLOADED_COL_DESCRIPTION_ORIGINAL,
115 DOWNLOADED_COL_DESCRIPTION_STYLE,
116 DOWNLOADED_COL_MEMO,
117 DOWNLOADED_COL_MEMO_ORIGINAL,
118 DOWNLOADED_COL_MEMO_STYLE,
119 DOWNLOADED_COL_NOTES_ORIGINAL,
120 DOWNLOADED_COL_ACTION_ADD,
121 DOWNLOADED_COL_ACTION_CLEAR,
122 DOWNLOADED_COL_ACTION_UPDATE,
123 DOWNLOADED_COL_ACTION_INFO,
124 DOWNLOADED_COL_ACTION_PIXBUF,
125 DOWNLOADED_COL_DATA,
126 DOWNLOADED_COL_COLOR,
127 DOWNLOADED_COL_ENABLE,
128 NUM_DOWNLOADED_COLS
129};

◆ downloaded_cols [2/2]

enum downloaded_cols

Definition at line 47 of file import-match-picker.cpp.

48{
49 DOWNLOADED_COL_ACCOUNT = 0,
50 DOWNLOADED_COL_DATE,
51 DOWNLOADED_COL_AMOUNT,
52 DOWNLOADED_COL_DESCRIPTION,
53 DOWNLOADED_COL_MEMO,
54 DOWNLOADED_COL_BALANCED,
55 DOWNLOADED_COL_INFO_PTR,
56 NUM_DOWNLOADED_COLS
57};

◆ GNCImportAction

enum GNCImportAction

Definition at line 60 of file import-backend.h.

61{
62 GNCImport_SKIP,
63 GNCImport_ADD,
64 GNCImport_CLEAR,
65 GNCImport_UPDATE,
66 GNCImport_LAST_ACTION,
67 GNCImport_INVALID_ACTION
68} GNCImportAction;

◆ GNCImportPendingMatchType

enum GNCImportPendingMatchType

Definition at line 38 of file import-pending-matches.h.

38 {
39 GNCImportPending_NONE,
40 GNCImportPending_AUTO,
41 GNCImportPending_MANUAL
42} GNCImportPendingMatchType;

◆ matcher_cols

enum matcher_cols

Definition at line 59 of file import-match-picker.cpp.

60{
61 MATCHER_COL_CONFIDENCE = 0,
62 MATCHER_COL_CONFIDENCE_PIXBUF,
63 MATCHER_COL_DATE,
64 MATCHER_COL_AMOUNT,
65 MATCHER_COL_DESCRIPTION,
66 MATCHER_COL_MEMO,
67 MATCHER_COL_RECONCILED,
68 MATCHER_COL_PENDING,
69 MATCHER_COL_INFO_PTR,
70 NUM_MATCHER_COLS
71};

Function Documentation

◆ gen_probability_pixbuf()

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

This function generates a new pixmap representing a match score.

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

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

Definition at line 360 of file import-backend.cpp.

361{
362 constexpr gint height = 15;
363 constexpr gint width_each_bar = 7;
364 constexpr gint width_first_bar = 1;
365 constexpr gint num_colors = 5;
366 constexpr size_t xpm_size = 2 + num_colors + height;
367 gchar * xpm[xpm_size];
368
369 g_assert(settings);
370 g_assert(widget);
371
372 auto score = std::max (0, score_original);
373
374 /* Add size definition to xpm */
375 xpm[0] = g_strdup_printf("%d%s%d%s%d%s", (width_each_bar * score) + width_first_bar/*width*/, " ", height, " ", num_colors, " 1"/*characters per pixel*/);
376
377 /* Define used colors */
378 xpm[1] = g_strdup(" c None");
379 xpm[2] = g_strdup("g c green");
380 xpm[3] = g_strdup("y c yellow");
381 xpm[4] = g_strdup("r c red");
382 xpm[5] = g_strdup("b c black");
383
384 auto add_threshold = gnc_import_Settings_get_add_threshold(settings);
385 auto clear_threshold = gnc_import_Settings_get_clear_threshold(settings);
386 for (int i = 0; i < height; i++)
387 {
388 xpm[num_colors+1+i] = g_new0(char, (width_each_bar * score) + width_first_bar + 1);
389 for (int j = 0; j <= score; j++)
390 {
391 if (j == 0)
392 strcat(xpm[num_colors+1+i], "b");
393 else if (i == 0 || i == height - 1)
394 strcat(xpm[num_colors+1+i], "bbbbbb ");
395 else if (j <= add_threshold)
396 strcat(xpm[num_colors+1+i], "brrrrb ");
397 else if (j >= clear_threshold)
398 strcat(xpm[num_colors+1+i], "bggggb ");
399 else
400 strcat(xpm[num_colors+1+i], "byyyyb ");
401 }
402 }
403 GError *err = nullptr;
404 std::string xpm_str = "/* XPM */\nstatic char * XFACE[] = {\n";
405
406 for (auto i = 0UL; i < xpm_size - 1; i++)
407 {
408 xpm_str += "\"";
409 xpm_str += xpm[i];
410 xpm_str += "\",\n";
411 g_free(xpm[i]);
412 }
413 xpm_str += "};";
414
415 auto gstream = g_memory_input_stream_new_from_data(xpm_str.c_str(), -1,
416 nullptr);
417 auto retval =
418 gdk_pixbuf_new_from_stream(G_INPUT_STREAM(gstream), nullptr, &err);
419 g_object_unref(gstream);
420
421 if (!retval && err)
422 PERR("Failed to create pixbuf from XPM data: %s", err->message);
423
424 return retval;
425}
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.
#define PERR(format, args...)
Log a serious error.
Definition qoflog.h:244

◆ gnc_file_log_replay()

void gnc_file_log_replay ( GtkWindow *  parent)

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

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

Definition at line 542 of file gnc-log-replay.cpp.

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

◆ gnc_file_ofx_import()

void gnc_file_ofx_import ( GtkWindow *  parent)

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

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

Definition at line 1451 of file gnc-ofx-import.cpp.

1452{
1453 extern int ofx_PARSER_msg;
1454 extern int ofx_DEBUG_msg;
1455 extern int ofx_WARNING_msg;
1456 extern int ofx_ERROR_msg;
1457 extern int ofx_INFO_msg;
1458 extern int ofx_STATUS_msg;
1459 GSList* selected_filenames = NULL;
1460 char *default_dir;
1461 GList *filters = NULL;
1462 ofx_info* info = NULL;
1463 GtkFileFilter* filter = gtk_file_filter_new ();
1464
1465
1466 ofx_PARSER_msg = false;
1467 ofx_DEBUG_msg = false;
1468 ofx_WARNING_msg = true;
1469 ofx_ERROR_msg = true;
1470 ofx_INFO_msg = true;
1471 ofx_STATUS_msg = false;
1472
1473 DEBUG("gnc_file_ofx_import(): Begin...\n");
1474
1475 default_dir = gnc_get_default_directory(GNC_PREFS_GROUP);
1476 gtk_file_filter_set_name (filter, _("Open/Quicken Financial Exchange file (*.ofx, *.qfx)"));
1477 gtk_file_filter_add_pattern (filter, "*.[oqOQ][fF][xX]");
1478 filters = g_list_prepend( filters, filter );
1479
1480 selected_filenames = gnc_file_dialog_multi (parent,
1481 _("Select one or multiple OFX/QFX file(s) to process"),
1482 filters,
1483 default_dir,
1484 GNC_FILE_DIALOG_IMPORT);
1485 g_free(default_dir);
1486
1487 if (selected_filenames)
1488 {
1489 /* Remember the directory as the default. */
1490 default_dir = g_path_get_dirname(static_cast<char*>(selected_filenames->data));
1491 gnc_set_default_directory(GNC_PREFS_GROUP, default_dir);
1492 g_free(default_dir);
1493
1494 /* Look up the needed preferences */
1495 auto_create_commodity =
1496 gnc_prefs_get_bool (GNC_PREFS_GROUP_IMPORT, GNC_PREF_AUTO_COMMODITY);
1497
1498 DEBUG("Opening selected file(s)");
1499 // Create the structure that holds the list of files to process and the statement info.
1500 info = g_new(ofx_info,1);
1501 info->num_trans_processed = 0;
1502 info->statement = NULL;
1503 info->last_investment_account = NULL;
1504 info->last_import_account = NULL;
1505 info->last_income_account = NULL;
1506 info->parent = parent;
1507 info->run_reconcile = FALSE;
1508 info->file_list = selected_filenames;
1509 info->trans_list = NULL;
1510 info->response = 0;
1511 // Call the aux import function.
1512 gnc_file_ofx_import_process_file (info);
1513 }
1514}
#define GNC_PREFS_GROUP_IMPORT
The preferences used by the importer.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.

◆ gnc_gen_trans_assist_new()

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

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

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

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

Definition at line 1810 of file import-main-matcher.cpp.

1815{
1816 GNCImportMainMatcher *info = g_new0 (GNCImportMainMatcher, 1);
1817 info->main_widget = GTK_WIDGET(parent);
1818
1819 /* load the interface */
1820 GtkBuilder *builder = gtk_builder_new ();
1821 gnc_builder_add_from_file (builder, "dialog-import.glade", "transaction_matcher_content");
1822
1823 /* Pack content into Assistant page widget */
1824 GtkWidget *box = GTK_WIDGET(gtk_builder_get_object (builder, "transaction_matcher_content"));
1825 g_assert (box != NULL);
1826 gtk_box_pack_start (GTK_BOX(assistant_page), box, true, true, 6);
1827
1828 // Set the name for this dialog so it can be easily manipulated with css
1829 gtk_widget_set_name (GTK_WIDGET(box), "gnc-id-import-transaction-content");
1830
1831 /* setup the common parts */
1832 gnc_gen_trans_common_setup (info, parent, builder, heading,
1833 all_from_same_account, match_date_hardlimit);
1834
1835 return info;
1836}

◆ gnc_gen_trans_assist_start()

void gnc_gen_trans_assist_start ( GNCImportMainMatcher *  info)

This starts the import process for transaction from an assistant.

assistant button callback.

Parameters
info.A pointer to the GNCImportMainMatcher structure

Definition at line 1839 of file import-main-matcher.cpp.

1840{
1841 on_matcher_ok_clicked (NULL, info);
1842}

◆ gnc_gen_trans_list_add_tp_cb()

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

Add transaction processed callback to the transaction importer.

Parameters
infoThe Transaction Importer to use.
trans_processed_cbThe callback function.

Definition at line 1849 of file import-main-matcher.cpp.

1852{
1853 info->user_data = user_data;
1854 info->transaction_processed_cb = trans_processed_cb;
1855}

◆ gnc_gen_trans_list_add_trans()

void gnc_gen_trans_list_add_trans ( GNCImportMainMatcher *  gui,
Transaction *  trans 
)

Add a newly imported Transaction to the Transaction Importer.

The Importer takes over ownership of the passed transaction.

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

Definition at line 2286 of file import-main-matcher.cpp.

2287{
2288 gnc_gen_trans_list_add_trans_internal (gui, trans, 0, NULL);
2289}

◆ gnc_gen_trans_list_add_trans_with_ref_id()

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

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

The Importer takes over ownership of the passed transaction.

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

Definition at line 2292 of file import-main-matcher.cpp.

2293{
2294 gnc_gen_trans_list_add_trans_internal (gui, trans, ref_id, NULL);
2295}

◆ gnc_gen_trans_list_add_trans_with_split_data()

void gnc_gen_trans_list_add_trans_with_split_data ( GNCImportMainMatcher *  gui,
Transaction *  trans,
GNCImportLastSplitInfo lsplit 
)

Add a newly imported Transaction to the Transaction Importer.

The Importer takes over ownership of the passed transaction.

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

Definition at line 2297 of file import-main-matcher.cpp.

2300{
2301 gnc_gen_trans_list_add_trans_internal (gui, trans, 0, lsplit);
2302}

◆ gnc_gen_trans_list_append_text_widget()

GtkWidget * gnc_gen_trans_list_append_text_widget ( GNCImportMainMatcher *  info)

Returns the append_text widget of this dialog.

Parameters
infoA pointer to the GNCImportMainMatcher structure.
Returns
A GtkWidget pointer to the append_text widget.

Definition at line 2471 of file import-main-matcher.cpp.

2472{
2473 g_assert (info);
2474 return info->append_text;
2475}

◆ gnc_gen_trans_list_delete()

void gnc_gen_trans_list_delete ( GNCImportMainMatcher *  info)

Deletes the given object.

Definition at line 203 of file import-main-matcher.cpp.

204{
205
206 if (info == NULL)
207 return;
208
209 GtkTreeModel *model = gtk_tree_view_get_model (info->view);
210 GtkTreeIter iter;
211 if (gtk_tree_model_get_iter_first (model, &iter))
212 {
213 do
214 {
215 GNCImportTransInfo *trans_info;
216 gtk_tree_model_get (model, &iter,
217 DOWNLOADED_COL_DATA, &trans_info,
218 -1);
219
220 if (info->transaction_processed_cb)
221 {
222 info->transaction_processed_cb (trans_info, false,
223 info->user_data);
224 }
225 }
226 while (gtk_tree_model_iter_next (model, &iter));
227 }
228
229 if (GTK_IS_DIALOG(info->main_widget))
230 {
231 gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->main_widget));
232 gnc_import_Settings_delete (info->user_settings);
233 gnc_unregister_gui_component (info->id);
234 gtk_widget_destroy (GTK_WIDGET(info->main_widget));
235 }
236 else
237 gnc_import_Settings_delete (info->user_settings);
238
239 g_slist_free_full (info->temp_trans_list, (GDestroyNotify) gnc_import_TransInfo_delete);
240 info->temp_trans_list = NULL;
241
242 // We've deferred balance computations on many accounts. Let's do it now that we're done.
243 update_all_balances (info);
244
245 gnc_import_PendingMatches_delete (info->pending_matches);
246 g_hash_table_destroy (info->acct_id_hash);
247 g_hash_table_destroy (info->desc_hash);
248 g_hash_table_destroy (info->notes_hash);
249 g_hash_table_destroy (info->memo_hash);
250 info->colormap.~StrStrMap();
251
252 g_list_free_full (info->new_strings, (GDestroyNotify)g_free);
253
254 g_free (info);
255
256 if (!gnc_gui_refresh_suspended ())
257 gnc_gui_refresh_all ();
258}
void gnc_import_TransInfo_delete(GNCImportTransInfo *info)
Destructor.
void gnc_import_Settings_delete(GNCImportSettings *settings)
Destructor.

◆ gnc_gen_trans_list_empty()

bool gnc_gen_trans_list_empty ( GNCImportMainMatcher *  info)

Checks whether there are no transactions to match.

Parameters
infoA pointer to the GNCImportMainMatcher structure.
Returns
A boolean indicating whether the transaction list is empty.

Definition at line 261 of file import-main-matcher.cpp.

262{
263 g_assert (info);
264
265 GtkTreeIter iter;
266 GtkTreeModel *model = gtk_tree_view_get_model (info->view);
267 // Check that both the tree model and the temporary list are empty.
268 return !gtk_tree_model_get_iter_first (model, &iter) && !info->temp_trans_list;
269}

◆ gnc_gen_trans_list_get_reconcile_after_close_button()

GtkWidget * gnc_gen_trans_list_get_reconcile_after_close_button ( GNCImportMainMatcher *  info)

Returns the reconcile after close check button.

Parameters
infoA pointer to the GNCImportMainMatcher structure.
Returns
The check button.

Definition at line 2250 of file import-main-matcher.cpp.

2251{
2252 return info->reconcile_after_close;
2253}

◆ gnc_gen_trans_list_new()

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

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.
show_allif true, all widgets are shown
Returns
A pointer to the GNCImportMainMatcher which has been setup.

Definition at line 1756 of file import-main-matcher.cpp.

1761{
1762 GNCImportMainMatcher *info = g_new0 (GNCImportMainMatcher, 1);
1763
1764 /* Initialize the GtkDialog. */
1765 GtkBuilder *builder = gtk_builder_new ();
1766 gnc_builder_add_from_file (builder, "dialog-import.glade", "transaction_matcher_dialog");
1767 gnc_builder_add_from_file (builder, "dialog-import.glade", "transaction_matcher_content");
1768
1769 info->main_widget = GTK_WIDGET(gtk_builder_get_object (builder, "transaction_matcher_dialog"));
1770 g_assert (info->main_widget != NULL);
1771
1772 /* Pack the content into the dialog vbox */
1773 GtkWidget *pbox = GTK_WIDGET(gtk_builder_get_object (builder, "transaction_matcher_vbox"));
1774 GtkWidget *box = GTK_WIDGET(gtk_builder_get_object (builder, "transaction_matcher_content"));
1775 gtk_box_pack_start (GTK_BOX(pbox), box, true, true, 0);
1776
1777 // Set the name for this dialog so it can be easily manipulated with css
1778 gtk_widget_set_name (GTK_WIDGET(info->main_widget), "gnc-id-import-matcher-transactions");
1779 gtk_widget_set_name (GTK_WIDGET(box), "gnc-id-import-transaction-content");
1780 gnc_widget_style_context_add_class (GTK_WIDGET(info->main_widget), "gnc-class-imports");
1781
1782 /* setup the common parts */
1783 gnc_gen_trans_common_setup (info, parent, builder, heading,
1784 all_from_same_account, match_date_hardlimit);
1785
1786 if (parent)
1787 gtk_window_set_transient_for (GTK_WINDOW(info->main_widget), GTK_WINDOW(parent));
1788
1789 gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->main_widget), GTK_WINDOW(parent));
1790
1791 if (show_all)
1792 gtk_widget_show_all (GTK_WIDGET(info->main_widget));
1793
1794 // Register this UI, it needs to be closed when the session is closed.
1795 info->id = gnc_register_gui_component (IMPORT_MAIN_MATCHER_CM_CLASS,
1796 NULL, /* no refresh handler */
1797 (GNCComponentCloseHandler)gnc_gen_trans_list_delete,
1798 info);
1799 // This ensure this dialog is closed when the session is closed.
1800 gnc_gui_component_set_session (info->id, gnc_get_current_session());
1801
1802 return info;
1803}
void gnc_gen_trans_list_delete(GNCImportMainMatcher *info)
Deletes the given object.

◆ gnc_gen_trans_list_run()

bool 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.

Parameters
infoA pointer to the GNCImportMainMatcher structure.
Returns
The boolean return value of the dialog run.

Definition at line 1858 of file import-main-matcher.cpp.

1859{
1860 /* DEBUG("Begin"); */
1861 bool result = gtk_dialog_run (GTK_DIALOG (info->main_widget));
1862 /* DEBUG("Result was %d", result); */
1863
1864 /* No destroying here since the dialog was already destroyed through
1865 the ok_clicked handlers. */
1866
1867 return result;
1868}

◆ gnc_gen_trans_list_show_all()

void gnc_gen_trans_list_show_all ( GNCImportMainMatcher *  info)

Shows widgets.

Parameters
infoA pointer to the GNCImportMainMatcher structure.

Definition at line 500 of file import-main-matcher.cpp.

501{
502 g_assert (info);
503
504 // Set initial state of Append checkbox to same as last import for this account.
505 // Get the import account from the first split in first transaction.
506 GSList *temp_trans_list = info->temp_trans_list;
507 if (!temp_trans_list)
508 {
509 gnc_info_dialog (GTK_WINDOW (info->main_widget), "%s", _("No new transactions were found in this import."));
510 return;
511 }
512 auto trans_info = static_cast<GNCImportTransInfo *>(temp_trans_list->data);
513 Split *first_split = gnc_import_TransInfo_get_fsplit (trans_info);
514 Account *account = xaccSplitGetAccount(first_split);
515 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (info->append_text),
516 xaccAccountGetAppendText(account));
517
518 gnc_gen_trans_list_create_matches (info);
519 load_hash_tables (info);
520 resolve_conflicts (info);
521 gtk_widget_show_all (GTK_WIDGET(info->main_widget));
522 gnc_gen_trans_list_show_accounts_column (info);
523}
gboolean xaccAccountGetAppendText(const Account *acc)
Get the "import-append-text" flag for an account.
Definition Account.cpp:4131
Split * gnc_import_TransInfo_get_fsplit(const GNCImportTransInfo *info)
Returns the first split of the transaction of this TransInfo.
Account * xaccSplitGetAccount(const Split *split)
Returns the account of this split, which was set through xaccAccountInsertSplit().
STRUCTS.

◆ gnc_gen_trans_list_show_reconcile_after_close_button()

void gnc_gen_trans_list_show_reconcile_after_close_button ( GNCImportMainMatcher *  info,
bool  reconcile_after_close,
bool  active 
)

Show and set the reconcile after close check button.

Parameters
infoA pointer to the GNCImportMainMatcher structure.
reconcile_after_closeA bool that shows or hides the button.
activeA bool to set or clear the check button.

Definition at line 2241 of file import-main-matcher.cpp.

2244{
2245 gtk_widget_set_visible (info->reconcile_after_close, reconcile_after_close);
2246 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (info->reconcile_after_close), active);
2247}

◆ gnc_gen_trans_list_widget()

GtkWidget * gnc_gen_trans_list_widget ( GNCImportMainMatcher *  info)

Returns the widget of this dialog.

Parameters
infoA pointer to the GNCImportMainMatcher structure.
Returns
A GtkWidget pointer to the dialog's widget.

Definition at line 2464 of file import-main-matcher.cpp.

2465{
2466 g_assert (info);
2467 return info->main_widget;
2468}

◆ gnc_import_exists_online_id()

gboolean gnc_import_exists_online_id ( Transaction *  trans,
GHashTable *  acct_id_hash 
)

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 1050 of file import-backend.cpp.

1051{
1052
1053 /* Look for an online_id in the first split */
1054 auto source_split = xaccTransGetSplit(trans, 0);
1055 g_assert(source_split);
1056
1057 auto source_online_id = xaccSplitGetOnlineID (source_split);
1058
1059 // No online id, no point in continuing. We'd crash if we tried.
1060 if (!source_online_id)
1061 return false;
1062
1063 // Create a hash per account of a hash of all split IDs. Then the
1064 // test below will be fast if we have many transactions to import.
1065 auto dest_acct = xaccSplitGetAccount (source_split);
1066
1067 auto online_id_hash = static_cast<GHashTable*>(g_hash_table_lookup (acct_id_hash, dest_acct));
1068
1069 if (!online_id_hash)
1070 {
1071 online_id_hash = hash_account_online_ids (dest_acct);
1072 g_hash_table_insert (acct_id_hash, dest_acct, online_id_hash);
1073 }
1074
1075 auto online_id_exists = g_hash_table_contains (online_id_hash, source_online_id);
1076 if (online_id_exists)
1077 {
1078 auto date_str = qof_print_date(xaccTransGetDate(trans));
1079 DEBUG("Transaction with online ID %s already exists, date: %s", source_online_id, date_str);
1080 g_free (date_str);
1081 }
1082 return online_id_exists;
1083}
char * qof_print_date(time64 t)
Convenience; calls through to qof_print_date_dmy_buff().
Definition gnc-date.cpp:610
Split * xaccTransGetSplit(const Transaction *trans, int i)
Return a pointer to the indexed split in this transaction's split list.
time64 xaccTransGetDate(const Transaction *trans)
Retrieve the posted date of the transaction.
const char * xaccSplitGetOnlineID(const Split *split)
Returns the split's online_id.

◆ gnc_import_match_picker_run_and_close()

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

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

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

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

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

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

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

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

Definition at line 432 of file import-match-picker.cpp.

434{
435 GNCImportMatchPicker *matcher;
436 gint response;
438 gboolean old_selected_manually;
439 g_assert (transaction_info);
440
441 /* Create a new match_picker, even though it's stored in a
442 transmatcher struct :-) */
443 matcher = g_new0(GNCImportMatchPicker, 1);
444
445 matcher->pending_matches = pending_matches;
446
447 /* DEBUG("Init match_picker"); */
448 init_match_picker_gui(parent, matcher);
449
450 /* Append this single transaction to the view and select it */
451 downloaded_transaction_append(matcher, transaction_info);
452
453 old = gnc_import_TransInfo_get_selected_match (transaction_info);
454 old_selected_manually =
456
457 /* Let this dialog run and close. */
458 /*DEBUG("Right before run and close");*/
459 gtk_window_set_modal(GTK_WINDOW(matcher->transaction_matcher), TRUE);
460 response = gtk_dialog_run (GTK_DIALOG (matcher->transaction_matcher));
461
462 gnc_save_window_size(GNC_PREFS_GROUP,
463 GTK_WINDOW (matcher->transaction_matcher));
464 gtk_widget_destroy (matcher->transaction_matcher);
465 /*DEBUG("Right after run and close");*/
466 /* DEBUG("Response was %d.", response); */
467 if (response == GTK_RESPONSE_OK && matcher->selected_match_info != old)
468 {
469 /* OK was pressed */
471 matcher->selected_match_info,
472 TRUE);
473
474 gnc_import_PendingMatches_remove_match (pending_matches,
475 old,
476 old_selected_manually);
477 gnc_import_PendingMatches_add_match (pending_matches,
478 matcher->selected_match_info,
479 TRUE);
480 }
481 gnc_import_Settings_delete (matcher->user_settings);
482 g_free (matcher);
483}
gboolean gnc_import_TransInfo_get_match_selected_manually(const GNCImportTransInfo *info)
Returns if the currently selected match was selected by the user.
void gnc_import_TransInfo_set_selected_match_info(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.

◆ gnc_import_MatchInfo_get_probability()

gint gnc_import_MatchInfo_get_probability ( const GNCImportMatchInfo info)

Get the probability (confidence level) of this MatchInfo.

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

Definition at line 333 of file import-backend.cpp.

334{
335 if (info)
336 return info->probability;
337 else
338 return 0;
339}

◆ gnc_import_MatchInfo_get_split()

Split * gnc_import_MatchInfo_get_split ( const GNCImportMatchInfo info)

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

Definition at line 326 of file import-backend.cpp.

327{
328 g_assert (info);
329 return info->split;
330}

◆ gnc_import_PendingMatches_add_match()

void gnc_import_PendingMatches_add_match ( GNCImportPendingMatches *  map,
GNCImportMatchInfo match_info,
gboolean  selected_manually 
)

Definition at line 89 of file import-pending-matches.cpp.

92{
93 GNCPendingMatches *pending_matches;
94 const GncGUID *match_guid;
95 GncGUID *key;
96
97 g_return_if_fail (map);
98 g_return_if_fail (match_info);
99
100
101 pending_matches = gnc_import_PendingMatches_get_value (map, match_info);
102 match_guid = gnc_import_PendingMatches_get_key (match_info);
103
104 if (pending_matches == NULL)
105 {
106 pending_matches = g_new0 (GNCPendingMatches, 1);
107 key = g_new (GncGUID, 1);
108 *key = *match_guid;
109 g_hash_table_insert (map, key, pending_matches);
110 }
111
112 if (selected_manually)
113 {
114 pending_matches->num_manual_matches++;
115 }
116 else
117 {
118 pending_matches->num_auto_matches++;
119 }
120}
The type used to store guids in C.
Definition guid.h:75

◆ gnc_import_PendingMatches_delete()

void gnc_import_PendingMatches_delete ( GNCImportPendingMatches *  map)

Definition at line 53 of file import-pending-matches.cpp.

54{
55 g_return_if_fail (map);
56
57 g_hash_table_destroy (map);
58}

◆ gnc_import_PendingMatches_get_match_type()

GNCImportPendingMatchType gnc_import_PendingMatches_get_match_type ( GNCImportPendingMatches *  map,
GNCImportMatchInfo match_info 
)

Definition at line 155 of file import-pending-matches.cpp.

157{
158 GNCPendingMatches *pending_matches;
159
160 g_return_val_if_fail (map, GNCImportPending_NONE);
161 g_return_val_if_fail (match_info, GNCImportPending_NONE);
162
163 pending_matches = gnc_import_PendingMatches_get_value (map, match_info);
164
165 if (pending_matches == NULL)
166 {
167 return GNCImportPending_NONE;
168 }
169
170 if (pending_matches->num_manual_matches > 0)
171 {
172 return GNCImportPending_MANUAL;
173 }
174
175 if (pending_matches->num_auto_matches > 0)
176 {
177 return GNCImportPending_AUTO;
178 }
179
180 g_assert_not_reached();
181}

◆ gnc_import_PendingMatches_get_type_str()

const char * gnc_import_PendingMatches_get_type_str ( GNCImportPendingMatchType  type)

Definition at line 184 of file import-pending-matches.cpp.

185{
186 switch (type)
187 {
188 case GNCImportPending_NONE:
189 return _("None");
190 case GNCImportPending_MANUAL:
191 return _("Manual");
192 case GNCImportPending_AUTO:
193 return _("Auto");
194 default:
195 g_assert_not_reached();
196 return NULL;
197 }
198}

◆ gnc_import_PendingMatches_new()

GNCImportPendingMatches * gnc_import_PendingMatches_new ( void  )

Definition at line 42 of file import-pending-matches.cpp.

43{
44 /* Can't use guid_hash_table_new() here since we want values to be taken
45 care of for us on destroy. */
46 return g_hash_table_new_full (guid_hash_to_guint,
48 g_free,
49 g_free
50 );
51}
guint guid_hash_to_guint(gconstpointer ptr)
Hash function for a GUID.
Definition guid.cpp:255
gint guid_g_hash_table_equal(gconstpointer guid_a, gconstpointer guid_b)
Equality function for two GUIDs in a GHashTable.
Definition guid.cpp:269

◆ gnc_import_PendingMatches_remove_match()

void gnc_import_PendingMatches_remove_match ( GNCImportPendingMatches *  map,
GNCImportMatchInfo match_info,
gboolean  selected_manually 
)

Definition at line 123 of file import-pending-matches.cpp.

126{
127 GNCPendingMatches *pending_matches;
128
129 g_return_if_fail (map);
130 g_return_if_fail (match_info);
131
132 pending_matches = gnc_import_PendingMatches_get_value (map, match_info);
133
134 g_return_if_fail (pending_matches);
135
136 if (selected_manually)
137 {
138 pending_matches->num_manual_matches--;
139 }
140 else
141 {
142 pending_matches->num_auto_matches--;
143 }
144
145 if (pending_matches->num_auto_matches == 0 &&
146 pending_matches->num_manual_matches == 0)
147 {
148 /* Key & Value are freed for us */
149 g_hash_table_remove (map,
150 gnc_import_PendingMatches_get_key (match_info));
151 }
152}

◆ gnc_import_process_trans_item()

gboolean gnc_import_process_trans_item ( Account base_acc,
GNCImportTransInfo *  trans_info 
)

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

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


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

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

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

Definition at line 886 of file import-backend.cpp.

888{
889 g_assert (trans_info);
890 /*DEBUG("Iteration %d, action %d, split %s", i,
891 trans_info->action,
892 xaccTransGetDescription (gnc_import_TransInfo_get_trans
893 (trans_info)))*/
894 switch (gnc_import_TransInfo_get_action (trans_info))
895 {
896 case GNCImport_SKIP:
897 return false;
898 case GNCImport_ADD:
899 /* Transaction gets imported. */
900 if (!gnc_import_TransInfo_is_balanced(trans_info)
902 {
903 /* Create the 'other' split. */
904 auto trans = gnc_import_TransInfo_get_trans (trans_info);
905 auto acct = gnc_import_TransInfo_get_destacc (trans_info);
906 auto split = xaccMallocSplit (gnc_account_get_book (acct));
907 xaccTransAppendSplit (trans, split);
908 xaccAccountInsertSplit (acct, split);
909 xaccSplitSetValue (split, trans_info->lsplit_value);
910 if (!gnc_numeric_zero_p (trans_info->lsplit_amount))
911 xaccSplitSetAmount (split, trans_info->lsplit_amount);
912 else
913 {
914 /* Bad! user asked to create a balancing split in an account with
915 * different currency/commodit than the transaction but didn't provide
916 * an exchange rate.
917 * Continue anyway pretenting split is in transaction currency. */
918 xaccSplitSetAmount (split, trans_info->lsplit_value);
919 PWARN("Missing exchange rate while adding transaction '%s', will assume rate of 1",
921 }
922 }
923
925 /*Set reconcile date to today*/
927 gnc_time (nullptr));
928 /* Done editing. */
929 xaccTransCommitEdit(trans_info->trans);
930 xaccTransRecordPrice(trans_info->trans, PRICE_SOURCE_SPLIT_IMPORT);
931 return true;
932 case GNCImport_UPDATE:
933 {
934 auto selected_match = gnc_import_TransInfo_get_selected_match(trans_info);
935
936 /* If there is no selection, ignore this transaction. */
937 if (!selected_match)
938 {
939 PWARN("No matching transaction to be cleared was chosen. Imported transaction will be ignored.");
940 break;
941 }
942
943 /* Transaction gets not imported but the matching one gets
944 updated and reconciled. */
945 if (!gnc_import_MatchInfo_get_split(selected_match))
946 PERR("The split I am trying to update and reconcile is nullptr, shouldn't happen!");
947 else
948 {
949 /* Update and reconcile the matching transaction */
950 /*DEBUG("BeginEdit selected_match")*/
951 xaccTransBeginEdit(selected_match->trans);
952
953 auto fsplit = gnc_import_TransInfo_get_fsplit(trans_info);
954 xaccTransSetDatePostedSecsNormalized(selected_match->trans,
956
957 auto match_split_amount = xaccSplitGetAmount(selected_match->split);
958 xaccSplitSetAmount(selected_match->split, xaccSplitGetAmount(fsplit));
959 xaccSplitSetValue(selected_match->split, xaccSplitGetValue(fsplit));
960
961 auto imbalance_value = gnc_import_TransInfo_get_dest_value(trans_info);
962 auto other_split = xaccSplitGetOtherSplit(selected_match->split);
963 if (!gnc_numeric_zero_p(imbalance_value) && other_split)
964 {
965 if (xaccSplitGetReconcile(other_split) == NREC)
966 {
967 xaccSplitSetValue(other_split, imbalance_value);
968 auto new_amt = gnc_import_TransInfo_get_dest_value(trans_info);
969 if (gnc_numeric_zero_p(new_amt))
970 {
971 auto other_split_amount = xaccSplitGetAmount(other_split);
972 auto price = gnc_numeric_div(match_split_amount, other_split_amount,
974 GNC_HOW_RND_ROUND_HALF_UP);
975
976 new_amt = gnc_numeric_mul(xaccSplitGetAmount(fsplit), price,
978 GNC_HOW_RND_ROUND_HALF_UP);;
979 }
980 xaccSplitSetAmount(other_split, new_amt);
981 }
982 else
983 {
984 /* else GC will automatically insert a split to equity
985 to balance the transaction */
986 PWARN("Updated transaction '%s', but not other split.",
987 xaccTransGetDescription(selected_match->trans));
988 }
989 }
990
991 auto fs_memo = xaccSplitGetMemo (trans_info->first_split);
992 if (fs_memo && *fs_memo)
993 xaccSplitSetMemo(selected_match->split, fs_memo);
994
995 update_desc_and_notes(trans_info);
996
997 /*DEBUG("CommitEdit selected_match")*/
998 xaccTransCommitEdit(selected_match->trans);
999
1000 process_reconcile (base_acc, trans_info, selected_match);
1001 }
1002 }
1003 return true;
1004 case GNCImport_CLEAR:
1005 {
1006 auto selected_match = gnc_import_TransInfo_get_selected_match (trans_info);
1007
1008 /* If there is no selection, ignore this transaction. */
1009 if (!selected_match)
1010 {
1011 PWARN("No matching translaction to be cleared was chosen. Imported transaction will be ignored.");
1012 break;
1013 }
1014
1015 /* Transaction gets not imported but the matching one gets
1016 reconciled. */
1017 if (!gnc_import_MatchInfo_get_split (selected_match))
1018 PERR("The split I am trying to reconcile is nullptr, shouldn't happen!");
1019 else
1020 {
1021 /* Reconcile the matching transaction */
1022 process_reconcile(base_acc, trans_info, selected_match);
1023 }
1024 }
1025 return true;
1026 default:
1027 DEBUG("Invalid GNCImportAction for this imported transaction.");
1028 break;
1029 }
1030 /*DEBUG("End");*/
1031 return false;
1032}
time64 gnc_time(time64 *tbuf)
get the current time
Definition gnc-date.cpp:262
#define xaccTransAppendSplit(t, s)
Add a split to the transaction.
void xaccTransCommitEdit(Transaction *trans)
The xaccTransCommitEdit() method indicates that the changes to the transaction and its splits are com...
const char * xaccTransGetDescription(const Transaction *trans)
Gets the transaction Description.
void xaccTransSetDatePostedSecsNormalized(Transaction *trans, time64 time)
This function sets the posted date of the transaction, specified by a time64 (see ctime(3)).
#define xaccAccountInsertSplit(acc, s)
The xaccAccountInsertSplit() method will insert the indicated split into the indicated account.
Definition Account.h:1069
void xaccTransRecordPrice(Transaction *trans, PriceSource source)
The xaccTransRecordPrice() method iterates through the splits and and record the non-currency equival...
void xaccTransBeginEdit(Transaction *trans)
The xaccTransBeginEdit() method must be called before any changes are made to a transaction or any of...
GNCImportAction gnc_import_TransInfo_get_action(const GNCImportTransInfo *info)
Returns the currently selected action for this TransInfo.
gnc_numeric gnc_import_TransInfo_get_dest_value(const GNCImportTransInfo *info)
Returns the destination split value for this TransInfo.
Transaction * gnc_import_TransInfo_get_trans(const GNCImportTransInfo *info)
Returns the transaction of this TransInfo.
Account * gnc_import_TransInfo_get_destacc(const GNCImportTransInfo *info)
Returns the 'other account' of this transaction.
gboolean gnc_import_TransInfo_is_balanced(const GNCImportTransInfo *info)
Returns if the transaction stored in the TransInfo is currently balanced.
Split * gnc_import_MatchInfo_get_split(const GNCImportMatchInfo *info)
Get the split ('this-side split') of this MatchInfo.
#define PWARN(format, args...)
Log a warning.
Definition qoflog.h:250
#define GNC_DENOM_AUTO
Values that can be passed as the 'denom' argument.
gnc_numeric gnc_numeric_div(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Division.
gnc_numeric gnc_numeric_mul(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Multiply a times b, returning the product.
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
Transaction * xaccSplitGetParent(const Split *split)
Returns the parent transaction of the split.
void xaccSplitSetReconcile(Split *split, char recn)
Set the reconcile flag.
char xaccSplitGetReconcile(const Split *split)
Returns the value of the reconcile flag.
void xaccSplitSetMemo(Split *split, const char *memo)
The memo is an arbitrary string associated with a split.
void xaccSplitSetValue(Split *split, gnc_numeric val)
The xaccSplitSetValue() method sets the value of this split in the transaction's commodity.
Split * xaccMallocSplit(QofBook *book)
Constructor.
void xaccSplitSetAmount(Split *split, gnc_numeric amt)
The xaccSplitSetAmount() method sets the amount in the account's commodity that the split should have...
gnc_numeric xaccSplitGetValue(const Split *split)
Returns the value of this split in the transaction's commodity.
const char * xaccSplitGetMemo(const Split *split)
Returns the memo string.
void xaccSplitSetDateReconciledSecs(Split *split, time64 secs)
Set the date on which this split was reconciled by specifying the time as time64.
#define NREC
not reconciled or cleared
Definition Split.h:76
Split * xaccSplitGetOtherSplit(const Split *split)
The xaccSplitGetOtherSplit() is a convenience routine that returns the other of a pair of splits.
#define CREC
The Split has been cleared
Definition Split.h:73
gnc_numeric xaccSplitGetAmount(const Split *split)
Returns the amount of the split in the account's commodity.

◆ gnc_import_select_account()

Account * gnc_import_select_account ( GtkWidget *  parent,
const gchar *  account_online_id_value,
gboolean  prompt_on_no_match,
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, prompt_on_no_match 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.
prompt_on_no_matchOnly 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 prompt_on_no_match is TRUE (nonzero), the user will be asked to create a new account. If prompt_on_no_match 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 329 of file import-account-matcher.cpp.

337{
338#define ACCOUNT_DESCRIPTION_MAX_SIZE 255
339 AccountPickerDialog * picker;
340 gint response;
341 Account * retval = NULL;
342 const gchar *retval_name = NULL;
343 GtkBuilder *builder;
344 GtkTreeSelection *selection;
345 GtkWidget * online_id_label;
346 gchar account_description_text[ACCOUNT_DESCRIPTION_MAX_SIZE + 1] = "";
347 gboolean ok_pressed_retval = FALSE;
348
349 ENTER("Default commodity received: %s", gnc_commodity_get_fullname( new_account_default_commodity));
350 DEBUG("Default account type received: %s", xaccAccountGetTypeStr( new_account_default_type));
351 picker = g_new0(AccountPickerDialog, 1);
352
353 picker->account_human_description = account_human_description;
354 picker->new_account_default_commodity = new_account_default_commodity;
355 picker->new_account_default_type = new_account_default_type;
356
357 /*DEBUG("Looking for account with online_id: \"%s\"", account_online_id_value);*/
358 if (account_online_id_value)
359 {
360 AccountOnlineMatch match = {NULL, 0, account_online_id_value};
361 retval = static_cast<Account*>(gnc_account_foreach_descendant_until (gnc_get_current_root_account (),
362 test_acct_online_id_match,
363 (void*)&match));
364 if (!retval && match.count == 1 &&
365 new_account_default_type == ACCT_TYPE_NONE)
366 retval = match.partial_match;
367 }
368 if (!retval && prompt_on_no_match)
369 {
370 /* load the interface */
371 builder = gtk_builder_new();
372 gnc_builder_add_from_file (builder, "dialog-import.glade", "account_new_icon");
373 gnc_builder_add_from_file (builder, "dialog-import.glade", "account_picker_dialog");
374 /* connect the signals in the interface */
375 if (builder == NULL)
376 {
377 PERR("Error opening the glade builder interface");
378 }
379 picker->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "account_picker_dialog"));
380 picker->whbox = GTK_WIDGET(gtk_builder_get_object (builder, "warning_hbox"));
381 picker->warning = GTK_WIDGET(gtk_builder_get_object (builder, "warning_label"));
382 picker->ok_button = GTK_WIDGET(gtk_builder_get_object (builder, "okbutton"));
383
384 // Set the name for this dialog so it can be easily manipulated with css
385 gtk_widget_set_name (GTK_WIDGET(picker->dialog), "gnc-id-import-account-picker");
386 gnc_widget_style_context_add_class (GTK_WIDGET(picker->dialog), "gnc-class-imports");
387
388 if (parent)
389 gtk_window_set_transient_for (GTK_WINDOW (picker->dialog),
390 GTK_WINDOW (parent));
391
392 gnc_restore_window_size (GNC_PREFS_GROUP,
393 GTK_WINDOW(picker->dialog), GTK_WINDOW (parent));
394
395 picker->account_tree_sw = GTK_WIDGET(gtk_builder_get_object (builder, "account_tree_sw"));
396 online_id_label = GTK_WIDGET(gtk_builder_get_object (builder, "online_id_label"));
397
398 //printf("gnc_import_select_account(): Fin get widget\n");
399
400 if (account_human_description != NULL)
401 {
402 strncat(account_description_text, account_human_description,
403 ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
404 strncat(account_description_text, "\n",
405 ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
406 }
407 if (account_online_id_value != NULL)
408 {
409 strncat(account_description_text, _("(Full account ID: "),
410 ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
411 strncat(account_description_text, account_online_id_value,
412 ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
413 strncat(account_description_text, ")",
414 ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
415 }
416 gtk_label_set_text((GtkLabel*)online_id_label, account_description_text);
417 build_acct_tree(picker);
418 gtk_window_set_modal(GTK_WINDOW(picker->dialog), TRUE);
419 g_signal_connect(picker->account_tree, "row-activated",
420 G_CALLBACK(account_tree_row_activated_cb), picker);
421
422 /* Connect key press event so we can expand the tree when the user starts typing, allowing
423 * any subaccount to match */
424 g_signal_connect (picker->account_tree, "key-press-event", G_CALLBACK (account_tree_key_press_cb), picker->account_tree);
425
426 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(picker->account_tree));
427 g_signal_connect(selection, "changed",
428 G_CALLBACK(account_tree_row_changed_cb), picker);
429
430 gnc_tree_view_account_set_selected_account(picker->account_tree, default_selection);
431
432 do
433 {
434 response = gtk_dialog_run(GTK_DIALOG(picker->dialog));
435 switch (response)
436 {
437 case GNC_RESPONSE_NEW:
438 gnc_import_add_account(NULL, picker);
439 response = GTK_RESPONSE_OK;
440 /* no break */
441
442 case GTK_RESPONSE_OK:
443 retval = gnc_tree_view_account_get_selected_account(picker->account_tree);
444 if (!retval)
445 {
446 response = GNC_RESPONSE_NEW;
447 break;
448 }
449 retval_name = xaccAccountGetName(retval);
450 DEBUG("Selected account %p, %s", retval, retval_name ? retval_name : "(null)");
451
452 /* See if the selected account is a placeholder. */
453 if (retval && xaccAccountGetPlaceholder (retval))
454 {
455 show_placeholder_warning (picker, retval_name);
456 response = GNC_RESPONSE_NEW;
457 break;
458 }
459
460 if (account_online_id_value)
461 {
462 xaccAccountSetOnlineID(retval, account_online_id_value);
463 }
464 ok_pressed_retval = TRUE;
465 break;
466
467 default:
468 ok_pressed_retval = FALSE;
469 break;
470 }
471 }
472 while (response == GNC_RESPONSE_NEW);
473
474 g_object_unref(G_OBJECT(builder));
475 gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(picker->dialog));
476 gtk_widget_destroy(picker->dialog);
477 }
478 else
479 {
480 retval_name = retval ? xaccAccountGetName(retval) : NULL;
481 ok_pressed_retval = TRUE; /* There was no dialog involved, so the computer "pressed" ok */
482 }
483 /*FIXME: DEBUG("WRITEME: gnc_import_select_account() Here we should check if account type is compatible, currency matches, etc.\n"); */
484 g_free(picker);
485 /*DEBUG("Return value: %p%s%s%s",retval,", account name:",xaccAccountGetName(retval),"\n");*/
486 if (ok_pressed != NULL)
487 {
488 *ok_pressed = ok_pressed_retval;
489 }
490 LEAVE("Selected account %p, %s", retval, retval_name ? retval_name : "(null)");
491 return retval;
492}
const char * xaccAccountGetName(const Account *acc)
Get the account's name.
Definition Account.cpp:3289
void xaccAccountSetOnlineID(Account *acc, const char *id)
Set the account's online_id, the identifier (e.g.
Definition Account.cpp:2661
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.cpp:3244
@ ACCT_TYPE_NONE
Not a type.
Definition Account.h:105
const char * gnc_commodity_get_fullname(const gnc_commodity *cm)
Retrieve the full name for the specified commodity.
gboolean xaccAccountGetPlaceholder(const Account *acc)
Get the "placeholder" flag for an account.
Definition Account.cpp:4119
const char * xaccAccountGetTypeStr(GNCAccountType type)
The xaccAccountGetTypeStr() routine returns a string suitable for use in the GUI/Interface.
Definition Account.cpp:4357
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.
void gnc_tree_view_account_set_selected_account(GncTreeViewAccount *view, Account *account)
This function selects an account in the account tree view.

◆ gnc_import_select_commodity()

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

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

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

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

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

57{
58 const gnc_commodity_table * commodity_table = gnc_get_current_commodities ();
59 gnc_commodity * retval = NULL;
60 DEBUG("Default fullname received: %s", default_fullname);
61 DEBUG("Default mnemonic received: %s", default_mnemonic);
62
63 g_return_val_if_fail(cusip, NULL);
64 DEBUG("Looking for commodity with exchange_code: %s", cusip);
65
66 g_assert(commodity_table);
67 GList *namespace_list = gnc_commodity_table_get_namespaces(commodity_table);
68
69 for (GList *n = namespace_list; !retval && n; n = g_list_next (n))
70 {
71 auto ns = static_cast<const char*>(n->data);
72 DEBUG("Looking at namespace %s", ns);
73 GList *comm_list = gnc_commodity_table_get_commodities (commodity_table, ns);
74 for (GList *m = comm_list; !retval && m; m = g_list_next (m))
75 {
76 auto com = static_cast<gnc_commodity*>(m->data);
77 DEBUG("Looking at commodity %s", gnc_commodity_get_fullname (com));
78 if (!g_strcmp0 (gnc_commodity_get_cusip (com), cusip))
79 {
80 retval = com;
81 DEBUG("Commodity %s matches.", gnc_commodity_get_fullname (com));
82 }
83 }
84 g_list_free (comm_list);
85 }
86
87 g_list_free(namespace_list);
88
89 if (retval == NULL && ask_on_unknown != 0)
90 {
91 const gchar *message =
92 _("Please select a commodity to match the following exchange "
93 "specific code. Please note that the exchange code of the "
94 "commodity you select will be overwritten.");
96 NULL,
98 message,
99 cusip,
100 default_fullname,
101 default_mnemonic);
102
103 }
104 /* There seems to be a problem here - if the matched commodity does not
105 have a cusip defined (gnc_commodity_get_cusip returns NULL) then
106 it does not get overwritten - which is not consistent with the
107 message - so Im adding it to do this. Looks like this is all
108 that was needed to fix the cash value used as stock units problem
109 for pre-defined commodities which didn't have the cusip defined! */
110 if (retval != NULL &&
111 gnc_commodity_get_cusip(retval) != NULL &&
112 cusip != NULL &&
113 (strncmp(gnc_commodity_get_cusip(retval), cusip, strlen(cusip)) != 0))
114 {
115 gnc_commodity_set_cusip(retval, cusip);
116 }
117 else if (gnc_commodity_get_cusip(retval) == NULL && cusip != NULL)
118 {
119 gnc_commodity_set_cusip(retval, cusip);
120 }
121 return retval;
122}
void gnc_commodity_set_cusip(gnc_commodity *cm, const char *cusip)
Set the 'exchange code' for the specified commodity.
const char * gnc_commodity_get_cusip(const gnc_commodity *cm)
Retrieve the 'exchange code' for the specified commodity.
GList * gnc_commodity_table_get_namespaces(const gnc_commodity_table *table)
Return a list of all namespaces in the commodity table.
CommodityList * gnc_commodity_table_get_commodities(const gnc_commodity_table *table, const char *name_space)
Return a list of all commodities in the commodity table that are in the given namespace.
gnc_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.
@ DIAG_COMM_ALL
Dialog box should allow selection of anything.

◆ gnc_import_Settings_delete()

void gnc_import_Settings_delete ( GNCImportSettings *  settings)

Destructor.

Definition at line 113 of file import-settings.cpp.

114{
115 if (settings)
116 {
117 g_free(settings);
118 }
119}

◆ gnc_import_Settings_get_action_add_enabled()

gboolean gnc_import_Settings_get_action_add_enabled ( GNCImportSettings *  settings)

Return the selected action is enable state.

Definition at line 134 of file import-settings.cpp.

135{
136 g_assert (settings);
137 return settings->action_add_enabled;
138}

◆ gnc_import_Settings_get_action_clear_enabled()

gboolean gnc_import_Settings_get_action_clear_enabled ( GNCImportSettings *  settings)

Return the selected action is enable state.

Definition at line 146 of file import-settings.cpp.

147{
148 g_assert (settings);
149 return settings->action_clear_enabled;
150}

◆ gnc_import_Settings_get_action_skip_enabled()

gboolean gnc_import_Settings_get_action_skip_enabled ( GNCImportSettings *  settings)

Return the selected action is enable state.

Definition at line 128 of file import-settings.cpp.

129{
130 g_assert (settings);
131 return settings->action_skip_enabled;
132}

◆ gnc_import_Settings_get_action_update_enabled()

gboolean gnc_import_Settings_get_action_update_enabled ( GNCImportSettings *  settings)

Return the selected action is enable state.

Definition at line 140 of file import-settings.cpp.

141{
142 g_assert (settings);
143 return settings->action_update_enabled;
144}

◆ gnc_import_Settings_get_add_threshold()

gint gnc_import_Settings_get_add_threshold ( GNCImportSettings *  settings)

Return the selected threshold.

Definition at line 158 of file import-settings.cpp.

159{
160 g_assert (settings);
161 return settings->add_threshold;
162}

◆ gnc_import_Settings_get_clear_threshold()

gint gnc_import_Settings_get_clear_threshold ( GNCImportSettings *  settings)

Return the selected threshold.

Definition at line 152 of file import-settings.cpp.

153{
154 g_assert (settings);
155 return settings->clear_threshold;
156}

◆ gnc_import_Settings_get_date_not_threshold()

gint gnc_import_Settings_get_date_not_threshold ( GNCImportSettings *  settings)

Definition at line 176 of file import-settings.cpp.

177{
178 g_assert (settings);
179 return settings->date_not_threshold;
180}

◆ gnc_import_Settings_get_date_threshold()

gint gnc_import_Settings_get_date_threshold ( GNCImportSettings *  settings)

Definition at line 170 of file import-settings.cpp.

171{
172 g_assert (settings);
173 return settings->date_threshold;
174}

◆ gnc_import_Settings_get_display_threshold()

gint gnc_import_Settings_get_display_threshold ( GNCImportSettings *  settings)

Return the selected threshold.

Definition at line 164 of file import-settings.cpp.

165{
166 g_assert (settings);
167 return settings->display_threshold;
168}

◆ gnc_import_Settings_get_fuzzy_amount()

double gnc_import_Settings_get_fuzzy_amount ( GNCImportSettings *  settings)

Return the allowed amount range for fuzzy amount matching.

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

Definition at line 122 of file import-settings.cpp.

123{
124 g_assert (settings);
125 return settings->fuzzy_amount;
126}

◆ gnc_import_Settings_get_match_date_hardlimit()

gint gnc_import_Settings_get_match_date_hardlimit ( const GNCImportSettings *  s)

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

Definition at line 188 of file import-settings.cpp.

189{
190 g_assert(s);
191 return s->match_date_hardlimit;
192}

◆ gnc_import_Settings_new()

GNCImportSettings * gnc_import_Settings_new ( void  )

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

Definition at line 82 of file import-settings.cpp.

83{
84 GNCImportSettings * settings;
85
86 settings = g_new0 ( GNCImportSettings, 1);
87
88
89 settings->action_skip_enabled =
90 gnc_prefs_get_bool (GNC_PREFS_GROUP_IMPORT, GNC_PREF_ENABLE_SKIP);
91 settings->action_update_enabled =
92 gnc_prefs_get_bool (GNC_PREFS_GROUP_IMPORT, GNC_PREF_ENABLE_UPDATE);
93 settings->action_add_enabled = DEFAULT_ACTION_ADD_ENABLED;
94 settings->action_clear_enabled = DEFAULT_ACTION_CLEAR_ENABLED;
95 settings->clear_threshold =
96 (int)gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_AUTO_CLEAR_THRESHOLD);
97 settings->add_threshold =
98 (int)gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_AUTO_ADD_THRESHOLD);
99 settings->display_threshold =
100 (int)gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_MATCH_THRESHOLD);
101 settings->date_threshold =
102 (int)gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_MATCH_DATE_THRESHOLD);
103 settings->date_not_threshold =
104 (int)gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_MATCH_DATE_NOT_THRESHOLD);
105 settings->fuzzy_amount =
106 gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_ATM_FEE_THRESHOLD);
107
108 settings->match_date_hardlimit = 42; /* 6 weeks */
109 return settings;
110}
gdouble gnc_prefs_get_float(const gchar *group, const gchar *pref_name)
Get an float value from the preferences backend.

◆ gnc_import_Settings_set_match_date_hardlimit()

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

Definition at line 182 of file import-settings.cpp.

183{
184 g_assert(s);
185 s->match_date_hardlimit = m;
186}

◆ gnc_import_TransInfo_delete()

void gnc_import_TransInfo_delete ( GNCImportTransInfo *  info)

Destructor.

Definition at line 341 of file import-backend.cpp.

342{
343 if (info)
344 {
345 g_list_free_full (info->match_list, g_free);
346 /*If the transaction exists and is still open, it must be destroyed*/
347 if (xaccTransIsOpen(info->trans))
348 {
349 xaccTransDestroy(info->trans);
350 xaccTransCommitEdit(info->trans);
351 }
352 g_list_free_full (info->match_tokens, g_free);
353 g_free(info->lsplit_action);
354 g_free(info->lsplit_memo);
355
356 g_free(info);
357 }
358}
void xaccTransDestroy(Transaction *trans)
Destroys a transaction.
gboolean xaccTransIsOpen(const Transaction *trans)
The xaccTransIsOpen() method returns TRUE if the transaction is open for editing.

◆ gnc_import_TransInfo_get_action()

GNCImportAction gnc_import_TransInfo_get_action ( const GNCImportTransInfo *  info)

Returns the currently selected action for this TransInfo.

Definition at line 193 of file import-backend.cpp.

194{
195 g_assert (info);
196 return info->action;
197}

◆ gnc_import_TransInfo_get_dest_amount()

gnc_numeric gnc_import_TransInfo_get_dest_amount ( const GNCImportTransInfo *  info)

Returns the destination split amount for this TransInfo.

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

279{
280 g_assert (info);
281 return info->lsplit_amount;
282}

◆ gnc_import_TransInfo_get_dest_value()

gnc_numeric gnc_import_TransInfo_get_dest_value ( const GNCImportTransInfo *  info)

Returns the destination split value for this TransInfo.

Definition at line 285 of file import-backend.cpp.

286{
287 g_assert (info);
288 return info->lsplit_value;
289}

◆ gnc_import_TransInfo_get_destacc()

Account * gnc_import_TransInfo_get_destacc ( const GNCImportTransInfo *  info)

Returns the 'other account' of this transaction.

May return NULL.

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

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

◆ gnc_import_TransInfo_get_destacc_selected_manually()

gboolean gnc_import_TransInfo_get_destacc_selected_manually ( const GNCImportTransInfo *  info)

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

Definition at line 233 of file import-backend.cpp.

234{
235 g_assert (info);
236 return info->dest_acc_selected_manually;
237}

◆ gnc_import_TransInfo_get_fsplit()

Split * gnc_import_TransInfo_get_fsplit ( const GNCImportTransInfo *  info)

Returns the first split of the transaction of this TransInfo.

Definition at line 162 of file import-backend.cpp.

163{
164 g_assert (info);
165 return info->first_split;
166}

◆ gnc_import_TransInfo_get_match_list()

GList * gnc_import_TransInfo_get_match_list ( const GNCImportTransInfo *  info)

Returns the stored list of possible matches.

Definition at line 127 of file import-backend.cpp.

128{
129 g_assert (info);
130 return info->match_list;
131}

◆ gnc_import_TransInfo_get_match_selected_manually()

gboolean gnc_import_TransInfo_get_match_selected_manually ( const GNCImportTransInfo *  info)

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

Definition at line 186 of file import-backend.cpp.

187{
188 g_assert (info);
189 return info->selected_match_info.selected_manually;
190}

◆ gnc_import_TransInfo_get_price()

gnc_numeric gnc_import_TransInfo_get_price ( const GNCImportTransInfo *  info)

Returns the exchange rate for this TransInfo.

Definition at line 255 of file import-backend.cpp.

256{
257 g_assert (info);
258 return info->lsplit_price;
259}

◆ gnc_import_TransInfo_get_ref_id()

guint32 gnc_import_TransInfo_get_ref_id ( const GNCImportTransInfo *  info)

Returns the reference id for this TransInfo.

Definition at line 240 of file import-backend.cpp.

241{
242 g_assert (info);
243 return info->ref_id;
244}

◆ gnc_import_TransInfo_get_selected_match()

GNCImportMatchInfo * gnc_import_TransInfo_get_selected_match ( const GNCImportTransInfo *  info)

Returns the currently selected match in this TransInfo.

Definition at line 169 of file import-backend.cpp.

170{
171 g_assert (info);
172 return info->selected_match_info.selected_match;
173}

◆ gnc_import_TransInfo_get_trans()

Transaction * gnc_import_TransInfo_get_trans ( const GNCImportTransInfo *  info)

Returns the transaction of this TransInfo.

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

149{
150 g_assert (info);
151 return info->trans;
152}

◆ gnc_import_TransInfo_init_matches()

void gnc_import_TransInfo_init_matches ( GNCImportTransInfo *  trans_info,
GNCImportSettings *  settings 
)

Iterates through all splits of trans_info's originating account match list.

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 1163 of file import-backend.cpp.

1165{
1166 g_assert (trans_info);
1167
1168 if (trans_info->match_list)
1169 {
1170 DEBUG("Number of matches %d", g_list_length(trans_info->match_list));
1171
1172 trans_info->match_list = g_list_sort(trans_info->match_list,
1173 compare_probability);
1174 auto best_match = static_cast<GNCImportMatchInfo*>(g_list_nth_data(trans_info->match_list, 0));
1175 gnc_import_TransInfo_set_selected_match_info (trans_info, best_match, false);
1176 if (best_match &&
1177 best_match->probability >= gnc_import_Settings_get_clear_threshold(settings))
1178 {
1180 best_match->update_proposed)
1181 trans_info->action = GNCImport_UPDATE;
1182 else
1183 trans_info->action = GNCImport_CLEAR;
1184 }
1185 else if (!best_match ||
1186 best_match->probability <= gnc_import_Settings_get_add_threshold(settings))
1187 trans_info->action = GNCImport_ADD;
1189 trans_info->action = GNCImport_SKIP;
1191 trans_info->action = GNCImport_UPDATE;
1192 else
1193 trans_info->action = GNCImport_ADD;
1194 }
1195 else
1196 trans_info->action = GNCImport_ADD;
1197
1198
1199 trans_info->previous_action = trans_info->action;
1200}
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.

◆ gnc_import_TransInfo_is_balanced()

gboolean gnc_import_TransInfo_is_balanced ( const GNCImportTransInfo *  info)

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

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

156{
157 g_assert (info);
159}
gnc_numeric xaccTransGetImbalanceValue(const Transaction *trans)
The xaccTransGetImbalanceValue() method returns the total value of the transaction.

◆ gnc_import_TransInfo_new()

GNCImportTransInfo * gnc_import_TransInfo_new ( Transaction *  trans,
Account base_acc 
)

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 account's match map for automated destination account matching. The given account may be NULL, in which case the match map of the originating account will be used.

Parameters
transThe transaction that this TransInfo should work with.
base_accAccount that will provide the match map to lookup a destination account. This may be NULL, in which case the match map of the originating account will be used.

Definition at line 1128 of file import-backend.cpp.

1129{
1130 g_assert (trans);
1131
1132 auto t_info = g_new0(GNCImportTransInfo, 1);
1133
1134 t_info->trans = trans;
1135 /* Only use first split, the source split */
1136 auto split = xaccTransGetSplit(trans, 0);
1137 g_assert(split);
1138 t_info->first_split = split;
1139
1140 /* Try to find a previously selected destination account
1141 string match for the ADD action */
1143 matchmap_find_destination (base_acc, t_info),
1144 false);
1145
1146 return t_info;
1147}
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).

◆ gnc_import_TransInfo_remove_top_match()

void gnc_import_TransInfo_remove_top_match ( GNCImportTransInfo *  info)

Remove the first match in the list of possible matches

Definition at line 134 of file import-backend.cpp.

135{
136 g_return_if_fail (info);
137 info->match_list = g_list_remove (info->match_list, static_cast<gpointer>(info->match_list->data));
138 if (info->match_list)
139 info->selected_match_info.selected_match = static_cast<GNCImportMatchInfo*>(info->match_list->data);
140 else
141 {
142 info->selected_match_info.selected_match = nullptr;
143 gnc_import_TransInfo_set_action (info, GNCImport_ADD);
144 };
145}
void gnc_import_TransInfo_set_action(GNCImportTransInfo *info, GNCImportAction action)
Set the action for this TransInfo.

◆ gnc_import_TransInfo_set_action()

void gnc_import_TransInfo_set_action ( GNCImportTransInfo *  info,
GNCImportAction  action 
)

Set the action for this TransInfo.

Also sets the previous action.

Definition at line 200 of file import-backend.cpp.

202{
203 g_assert (info);
204 if (action != info->action)
205 {
206 info->previous_action = info->action;
207 info->action = action;
208 }
209}

◆ gnc_import_TransInfo_set_append_text()

void gnc_import_TransInfo_set_append_text ( GNCImportTransInfo *  info,
gboolean  append_text 
)

Set the append_text for this TransInfo.

Definition at line 317 of file import-backend.cpp.

319{
320 g_assert (info);
321 info->append_text = append_text;
322}

◆ gnc_import_TransInfo_set_destacc()

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

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

May be set to NULL.

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

Definition at line 217 of file import-backend.cpp.

220{
221 g_assert (info);
222 info->dest_acc = acc;
223 info->dest_acc_selected_manually = selected_manually;
224
225 /* Store the mapping to the other account in the MatchMap. */
226 if (selected_manually)
227 matchmap_store_destination (nullptr, info, false);
228
229 trans_info_calculate_dest_amount (info);
230}

◆ gnc_import_TransInfo_set_last_split_info()

void gnc_import_TransInfo_set_last_split_info ( GNCImportTransInfo *  info,
GNCImportLastSplitInfo lsplit 
)

Sets additional parameters to be used to generate the closing split.

Definition at line 292 of file import-backend.cpp.

294{
295 g_assert (info);
296 if (lsplit)
297 {
298 info->lsplit_price = lsplit->price;
299 info->lsplit_action = g_strdup(lsplit->action);
300 info->lsplit_memo = g_strdup(lsplit->memo);
301 if (gnc_numeric_check (lsplit->amount) == 0)
302 {
303 info->lsplit_amount = lsplit->amount;
304 info->lsplit_amount_selected_manually = true;
305 }
306 /* Bayesian matching may have already set a candidate destination
307 * account. However if the csv data also provides one, the one from the
308 * csv data is preferred. */
309 if (lsplit->account)
310 info->dest_acc = lsplit->account;
311 info->lsplit_rec_state = lsplit->rec_state;
312 info->lsplit_rec_date = lsplit->rec_date;
313 }
314}

◆ gnc_import_TransInfo_set_price()

void gnc_import_TransInfo_set_price ( GNCImportTransInfo *  info,
gnc_numeric  lprice 
)

Set the exchange rate for this TransInfo.

Definition at line 262 of file import-backend.cpp.

264{
265 g_assert (info);
266 info->lsplit_price = lprice;
267 /* if a valid price is explicitly set, assume the user wants to
268 * use it to calculate balance split amount.
269 * Ensure this gets recalculated */
270 if (gnc_numeric_check (lprice) == 0)
271 {
272 info->lsplit_amount_selected_manually = false;
273 trans_info_calculate_dest_amount(info);
274 }
275}

◆ gnc_import_TransInfo_set_ref_id()

void gnc_import_TransInfo_set_ref_id ( GNCImportTransInfo *  info,
guint32  ref_id 
)

Set the reference id for this TransInfo.

Definition at line 247 of file import-backend.cpp.

249{
250 g_assert (info);
251 info->ref_id = ref_id;
252}

◆ gnc_import_TransInfo_set_selected_match_info()

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

Sets the currently selected match in this TransInfo.

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

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

179{
180 g_assert (info);
181 info->selected_match_info.selected_match = match;
182 info->selected_match_info.selected_manually = selected_manually;
183}

◆ libgncmod_ofx_gnc_module_description()

char * libgncmod_ofx_gnc_module_description ( void  )

Definition at line 56 of file gncmod-ofx-import.c.

57{
58 return g_strdup("Gnome GUI and C code for OFX importer using libofx");
59}

◆ libgncmod_ofx_gnc_module_end()

int libgncmod_ofx_gnc_module_end ( int  refcount)

Definition at line 71 of file gncmod-ofx-import.c.

72{
73 return TRUE;
74}

◆ libgncmod_ofx_gnc_module_init()

int libgncmod_ofx_gnc_module_init ( int  refcount)

Definition at line 62 of file gncmod-ofx-import.c.

63{
64 /* Add menu items with C callbacks */
65 gnc_plugin_ofx_create_plugin();
66
67 return TRUE;
68}

◆ libgncmod_ofx_gnc_module_path()

char * libgncmod_ofx_gnc_module_path ( void  )

Definition at line 50 of file gncmod-ofx-import.c.

51{
52 return g_strdup("gnucash/import-export/ofx");
53}

◆ ofx_proc_account_cb()

int ofx_proc_account_cb ( struct OfxAccountData  data,
void *  account_user_data 
)

Definition at line 1029 of file gnc-ofx-import.cpp.

1030{
1031 gnc_commodity_table * commodity_table;
1032 gnc_commodity * default_commodity;
1033 GNCAccountType default_type = ACCT_TYPE_NONE;
1034 gchar * account_description;
1035 GtkWidget * main_widget;
1036 GtkWidget * parent;
1037 /* In order to trigger a book options display on the creation of a new book,
1038 * we need to detect when we are dealing with a new book. */
1039 gboolean new_book = gnc_is_new_book();
1040 ofx_info* info = (ofx_info*) account_user_data;
1041 Account* account = NULL;
1042
1043 const gchar * account_type_name = _("Unknown OFX account");
1044
1045 if (data.account_id_valid)
1046 {
1047 commodity_table = gnc_get_current_commodities ();
1048 if (data.currency_valid)
1049 {
1050 DEBUG("Currency from libofx: %s", data.currency);
1051 default_commodity = gnc_commodity_table_lookup(commodity_table,
1052 GNC_COMMODITY_NS_CURRENCY,
1053 data.currency);
1054 }
1055 else
1056 {
1057 default_commodity = NULL;
1058 }
1059
1060 if (data.account_type_valid)
1061 {
1062 switch (data.account_type)
1063 {
1064 case OfxAccountData::OFX_CHECKING:
1065 default_type = ACCT_TYPE_BANK;
1066 account_type_name = _("Unknown OFX checking account");
1067 break;
1068 case OfxAccountData::OFX_SAVINGS:
1069 default_type = ACCT_TYPE_BANK;
1070 account_type_name = _("Unknown OFX savings account");
1071 break;
1072 case OfxAccountData::OFX_MONEYMRKT:
1073 default_type = ACCT_TYPE_MONEYMRKT;
1074 account_type_name = _("Unknown OFX money market account");
1075 break;
1076 case OfxAccountData::OFX_CREDITLINE:
1077 default_type = ACCT_TYPE_CREDITLINE;
1078 account_type_name = _("Unknown OFX credit line account");
1079 break;
1080 case OfxAccountData::OFX_CMA:
1081 default_type = ACCT_TYPE_NONE;
1082 /* Cash Management Account */
1083 account_type_name = _("Unknown OFX CMA account");
1084 break;
1085 case OfxAccountData::OFX_CREDITCARD:
1086 default_type = ACCT_TYPE_CREDIT;
1087 account_type_name = _("Unknown OFX credit card account");
1088 break;
1089 case OfxAccountData::OFX_INVESTMENT:
1090 default_type = ACCT_TYPE_BANK;
1091 account_type_name = _("Unknown OFX investment account");
1092 break;
1093 default:
1094 PERR("WRITEME: ofx_proc_account() This is an unknown account type!");
1095 break;
1096 }
1097 }
1098
1099 /* If the OFX importer was started in Gnucash in a 'new_book' situation,
1100 * as described above, the first time the 'ofx_proc_account_cb' function
1101 * is called a book is created. (This happens after the 'new_book' flag
1102 * is set in 'gnc_get_current_commodities', called above.) So, before
1103 * calling 'gnc_import_select_account', allow the user to set book
1104 * options. */
1105 if (new_book)
1106 gnc_new_book_option_display (GTK_WIDGET (gnc_ui_get_main_window (NULL)));
1107
1108 gnc_utf8_strip_invalid(data.account_name);
1109 gnc_utf8_strip_invalid(data.account_id);
1110 account_description = g_strdup_printf (/* This string is a default account
1111 name. It MUST NOT contain the
1112 character ':' anywhere in it or
1113 in any translation. */
1114 "%s \"%s\"",
1115 account_type_name,
1116 data.account_name);
1117
1118 main_widget = gnc_gen_trans_list_widget (info->gnc_ofx_importer_gui);
1119
1120 /* On first use, the import-main-matcher is hidden / not realized so to
1121 * get a parent use the transient parent of the matcher */
1122 if (gtk_widget_get_realized (main_widget))
1123 parent = main_widget;
1124 else
1125 parent = GTK_WIDGET(gtk_window_get_transient_for (GTK_WINDOW(main_widget)));
1126
1127 account = gnc_import_select_account (parent,
1128 data.account_id, 1,
1129 account_description, default_commodity,
1130 default_type, NULL, NULL);
1131
1132 if (account)
1133 {
1134 info->last_import_account = account;
1135 }
1136
1137 g_free(account_description);
1138 }
1139 else
1140 {
1141 PERR("account online ID not available");
1142 }
1143
1144 return 0;
1145}
GNCAccountType
The account types are used to determine how the transaction data in the account is displayed.
Definition Account.h:103
@ ACCT_TYPE_CREDITLINE
line of credit – don't use this for now, see NUM_ACCOUNT_TYPES
Definition Account.h:171
@ ACCT_TYPE_BANK
The bank account type denotes a savings or checking account held at a bank.
Definition Account.h:107
@ ACCT_TYPE_MONEYMRKT
bank account type – don't use this for now, see NUM_ACCOUNT_TYPES
Definition Account.h:169
@ ACCT_TYPE_CREDIT
The Credit card account is used to denote credit (e.g.
Definition Account.h:113
GtkWindow * gnc_ui_get_main_window(GtkWidget *widget)
Get a pointer to the final GncMainWindow widget is rooted in.
void gnc_utf8_strip_invalid(gchar *str)
Strip any non-UTF-8 characters from a string.
Account * gnc_import_select_account(GtkWidget *parent, const gchar *account_online_id_value, gboolean prompt_on_no_match, 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.
GtkWidget * gnc_gen_trans_list_widget(GNCImportMainMatcher *info)
Returns the widget of this dialog.

◆ ofx_proc_security_cb()

int ofx_proc_security_cb ( const struct OfxSecurityData  data,
void *  security_user_data 
)

Definition at line 246 of file gnc-ofx-import.cpp.

247{
248 char* cusip = NULL;
249 char* default_fullname = NULL;
250 char* default_mnemonic = NULL;
251
252 if (data.unique_id_valid)
253 {
254 cusip = gnc_utf8_strip_invalid_strdup (data.unique_id);
255 }
256 if (data.secname_valid)
257 {
258 default_fullname = gnc_utf8_strip_invalid_strdup (data.secname);
259 }
260 if (data.ticker_valid)
261 {
262 default_mnemonic = gnc_utf8_strip_invalid_strdup (data.ticker);
263 }
264
265 if (auto_create_commodity)
266 {
267 gnc_commodity *commodity =
269 FALSE,
270 default_fullname,
271 default_mnemonic);
272
273 if (!commodity)
274 {
275 QofBook *book = gnc_get_current_book();
276 gnc_quote_source *source;
277 gint source_selection = 0; // FIXME: This is just a wild guess
278 char *commodity_namespace = NULL;
279 int fraction = 1;
280
281 if (data.unique_id_type_valid)
282 {
283 commodity_namespace = gnc_utf8_strip_invalid_strdup (data.unique_id_type);
284 }
285
286 g_warning("Creating a new commodity, cusip=%s", cusip);
287 /* Create the new commodity */
288 commodity = gnc_commodity_new(book,
289 default_fullname,
290 commodity_namespace,
291 default_mnemonic,
292 cusip,
293 fraction);
294
295 /* Also set a single quote source */
296 gnc_commodity_begin_edit(commodity);
297 gnc_commodity_user_set_quote_flag (commodity, TRUE);
298 source = gnc_quote_source_lookup_by_ti (SOURCE_SINGLE, source_selection);
299 gnc_commodity_set_quote_source(commodity, source);
300 gnc_commodity_commit_edit(commodity);
301
302 /* Remember the commodity */
303 gnc_commodity_table_insert(gnc_get_current_commodities(), commodity);
304
305 g_free (commodity_namespace);
306
307 }
308 }
309 else
310 {
312 TRUE,
313 default_fullname,
314 default_mnemonic);
315 }
316
317 g_free (cusip);
318 g_free (default_mnemonic);
319 g_free (default_fullname);
320 return 0;
321}
gnc_commodity * gnc_commodity_new(QofBook *book, const char *fullname, const char *name_space, const char *mnemonic, const char *cusip, int fraction)
Create a new commodity.
void gnc_commodity_set_quote_source(gnc_commodity *cm, gnc_quote_source *src)
Set the automatic price quote source for the specified commodity.
gnc_quote_source * gnc_quote_source_lookup_by_ti(QuoteSourceType type, gint index)
Given the type/index of a quote source, find the data structure identified by this pair.
gnc_commodity * gnc_commodity_table_insert(gnc_commodity_table *table, gnc_commodity *comm)
Add a new commodity to the commodity table.
void gnc_commodity_user_set_quote_flag(gnc_commodity *cm, const gboolean flag)
Set the automatic price quote flag for the specified commodity, based on user input.
@ SOURCE_SINGLE
This quote source pulls from a single specific web site.
gchar * gnc_utf8_strip_invalid_strdup(const gchar *str)
Returns a newly allocated copy of the given string but with any non-UTF-8 character stripped from it.
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.
QofBook reference.
Definition qofbook-p.hpp:47

◆ ofx_proc_statement_cb()

int ofx_proc_statement_cb ( struct OfxStatementData  data,
void *  statement_user_data 
)

Definition at line 1019 of file gnc-ofx-import.cpp.

1020{
1021 ofx_info* info = (ofx_info*) statement_user_data;
1022 struct OfxStatementData *statement = g_new (struct OfxStatementData, 1);
1023 *statement = data;
1024 info->statement = g_list_prepend (info->statement, statement);
1025 return 0;
1026}

◆ ofx_proc_transaction_cb()

int ofx_proc_transaction_cb ( OfxTransactionData  data,
void *  user_data 
)

Definition at line 912 of file gnc-ofx-import.cpp.

913{
914 Account *import_account;
915 gnc_commodity *currency = NULL;
916 QofBook *book;
917 Transaction *transaction;
918 ofx_info* info = (ofx_info*) user_data;
919
920 g_assert(info->parent);
921
922 if (!data.amount_valid)
923 {
924 PERR("The transaction doesn't have a valid amount");
925 return 0;
926 }
927
928 if (!data.account_id_valid)
929 {
930 PERR("account ID for this transaction is unavailable!");
931 return 0;
932 }
933
934 gnc_utf8_strip_invalid (data.account_id);
935
936 import_account = gnc_import_select_account(GTK_WIDGET(info->parent),
937 data.account_id,
938 0, NULL, NULL, ACCT_TYPE_NONE,
939 info->last_import_account, NULL);
940 if (import_account == NULL)
941 {
942 PERR("Unable to find account for id %s", data.account_id);
943 return 0;
944 }
945 info->last_import_account = import_account;
946 /***** Validate the input strings to ensure utf8 *****/
947 if (data.name_valid)
948 gnc_utf8_strip_invalid(data.name);
949 if (data.memo_valid)
950 gnc_utf8_strip_invalid(data.memo);
951 if (data.check_number_valid)
952 gnc_utf8_strip_invalid(data.check_number);
953 if (data.reference_number_valid)
954 gnc_utf8_strip_invalid(data.reference_number);
955
956 /***** Create the transaction and setup transaction data *******/
957 book = gnc_account_get_book(import_account);
958 transaction = xaccMallocTransaction(book);
959 xaccTransBeginEdit(transaction);
960
961 set_transaction_dates(transaction, &data);
962 fill_transaction_description(transaction, &data);
963 fill_transaction_notes(transaction, &data);
964
965 if (data.account_ptr && data.account_ptr->currency_valid)
966 {
967 DEBUG("Currency from libofx: %s", data.account_ptr->currency);
968 currency = gnc_commodity_table_lookup( gnc_get_current_commodities (),
969 GNC_COMMODITY_NS_CURRENCY,
970 data.account_ptr->currency);
971 }
972 else
973 {
974 DEBUG("Currency from libofx unavailable, defaulting to account's default");
975 currency = xaccAccountGetCommodity(import_account);
976 }
977
978 xaccTransSetCurrency(transaction, currency);
979
980 if (!data.invtransactiontype_valid
981#ifdef HAVE_LIBOFX_VERSION_0_10
982 || data.invtransactiontype == OFX_INVBANKTRAN
983#endif
984 )
985 process_bank_transaction(transaction, import_account, &data, info);
986 else if (data.unique_id_valid
987 && data.security_data_valid
988 && data.security_data_ptr != NULL
989 && data.security_data_ptr->secname_valid)
990 process_investment_transaction(transaction, import_account,
991 &data, info);
992 else
993 {
994 PERR("Unsupported OFX transaction type.");
995 xaccTransDestroy(transaction);
996 xaccTransCommitEdit(transaction);
997 return 0;
998 }
999
1000 /* Send transaction to importer GUI. */
1001 if (xaccTransCountSplits(transaction) > 0)
1002 {
1003 DEBUG("%d splits sent to the importer gui",
1004 xaccTransCountSplits(transaction));
1005 info->trans_list = g_list_prepend (info->trans_list, transaction);
1006 }
1007 else
1008 {
1009 PERR("No splits in transaction (missing account?), ignoring.");
1010 xaccTransDestroy(transaction);
1011 xaccTransCommitEdit(transaction);
1012 }
1013
1014 info->num_trans_processed += 1;
1015 return 0;
1016}//end ofx_proc_transaction()
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity
Definition Account.cpp:3408
Transaction * xaccMallocTransaction(QofBook *book)
The xaccMallocTransaction() will malloc memory and initialize it.
void xaccTransSetCurrency(Transaction *trans, gnc_commodity *curr)
Set a new currency on a transaction.
int xaccTransCountSplits(const Transaction *trans)
Returns the number of splits in this transaction.

◆ on_matcher_cancel_clicked()

void on_matcher_cancel_clicked ( GtkButton *  button,
gpointer  user_data 
)

Definition at line 607 of file import-main-matcher.cpp.

608{
609 auto info = static_cast<GNCImportMainMatcher *>(user_data);
611}

◆ on_matcher_delete_event()

bool on_matcher_delete_event ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  data 
)

Definition at line 614 of file import-main-matcher.cpp.

615{
616 auto info = static_cast<GNCImportMainMatcher *>(data);
618 return false;
619}

◆ on_matcher_help_clicked()

void on_matcher_help_clicked ( GtkButton *  button,
gpointer  user_data 
)

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

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

Definition at line 630 of file import-main-matcher.cpp.

631{
632 auto info = static_cast<GNCImportMainMatcher*>(user_data);
633
634 GtkBuilder *builder = gtk_builder_new ();
635 gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer2");
636 gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer3");
637 gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer4");
638 gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer5");
639 gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer1");
640 gnc_builder_add_from_file (builder, "dialog-import.glade", "matcher_help_dialog");
641
642 const gchar *class_extension = NULL;
643 if (info->dark_theme == true)
644 class_extension = "-dark";
645
646 gchar *int_required_class = g_strconcat (CSS_INT_REQUIRED_CLASS, class_extension, NULL);
647 gchar *int_prob_required_class = g_strconcat (CSS_INT_PROB_REQUIRED_CLASS, class_extension, NULL);
648 gchar *int_not_required_class = g_strconcat (CSS_INT_NOT_REQUIRED_CLASS, class_extension, NULL);
649
650 GtkWidget *box = GTK_WIDGET(gtk_builder_get_object (builder, "intervention_required_box"));
651 gnc_widget_style_context_add_class (GTK_WIDGET(box), int_required_class);
652
653 box = GTK_WIDGET(gtk_builder_get_object (builder, "intervention_probably_required_box"));
654 gnc_widget_style_context_add_class (GTK_WIDGET(box), int_prob_required_class);
655
656 box = GTK_WIDGET(gtk_builder_get_object (builder, "intervention_not_required_box"));
657 gnc_widget_style_context_add_class (GTK_WIDGET(box), int_not_required_class);
658
659 GtkWidget *help_dialog = GTK_WIDGET(gtk_builder_get_object (builder, "matcher_help_dialog"));
660 gtk_window_set_transient_for (GTK_WINDOW(help_dialog), GTK_WINDOW(info->main_widget));
661
662 // Set the name for this dialog so it can be easily manipulated with css
663 gtk_widget_set_name (GTK_WIDGET(help_dialog), "gnc-id-import-matcher-help");
664 gnc_widget_style_context_add_class (GTK_WIDGET(help_dialog), "gnc-class-imports");
665
666 /* Connect the signals */
667 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, help_dialog);
668
669 g_object_unref (G_OBJECT(builder));
670
671 g_free (int_required_class);
672 g_free (int_prob_required_class);
673 g_free (int_not_required_class);
674
675 gtk_widget_show (help_dialog);
676}

◆ on_matcher_help_close_clicked()

void on_matcher_help_close_clicked ( GtkButton *  button,
gpointer  user_data 
)

Definition at line 622 of file import-main-matcher.cpp.

623{
624 auto help_dialog = static_cast<GtkWidget *>(user_data);
625
626 gtk_widget_destroy (help_dialog);
627}

◆ on_matcher_ok_clicked()

void on_matcher_ok_clicked ( GtkButton *  button,
GNCImportMainMatcher *  info 
)

Definition at line 535 of file import-main-matcher.cpp.

536{
537 g_assert (info);
538
539 DEBUG ("Begin");
540
541 GtkTreeModel *model = gtk_tree_view_get_model (info->view);
542 GtkTreeIter iter;
543 if (!gtk_tree_model_get_iter_first (model, &iter))
544 {
545 // No transaction, we can just close the dialog.
547 return;
548 }
549
550 /* Don't run any queries and/or split sorts while processing the matcher
551 results. */
552 gnc_suspend_gui_refresh ();
553 bool first_tran = true;
554 bool append_text = gtk_toggle_button_get_active ((GtkToggleButton*) info->append_text);
555 GList *accounts_modified = NULL;
556 do
557 {
558 GNCImportTransInfo *trans_info;
559 gtk_tree_model_get (model, &iter,
560 DOWNLOADED_COL_DATA, &trans_info,
561 -1);
562
563 Split* first_split = gnc_import_TransInfo_get_fsplit (trans_info);
564 Transaction *trans = xaccSplitGetParent (first_split);
565
566 for (GList *n = xaccTransGetSplitList (trans); n; n = g_list_next (n))
567 acc_begin_edit (&accounts_modified, xaccSplitGetAccount (static_cast<Split*>(n->data)));
568
569 // Allow the backend to know if the Append checkbox is ticked or unticked
570 // by propagating info->append_text to every trans_info->append_text
571 gnc_import_TransInfo_set_append_text( trans_info, append_text);
572
573 // When processing the first transaction,
574 // save the state of the Append checkbox to an account kvp so the same state can be
575 // defaulted next time this account is imported.
576 // Get the import account from the first split.
577 if (first_tran)
578 {
579 xaccAccountSetAppendText (xaccSplitGetAccount(first_split), append_text);
580 first_tran = false;
581 }
582
583 Account *dest_acc = gnc_import_TransInfo_get_destacc (trans_info);
584 acc_begin_edit (&accounts_modified, dest_acc);
585
586 if (gnc_import_process_trans_item (NULL, trans_info))
587 {
588 if (info->transaction_processed_cb)
589 {
590 info->transaction_processed_cb (trans_info, true,
591 info->user_data);
592 }
593 }
594 }
595 while (gtk_tree_model_iter_next (model, &iter));
596
598
599 DEBUG ("End");
600 g_list_free_full (accounts_modified, (GDestroyNotify)xaccAccountCommitEdit);
601
602 /* Allow GUI refresh again upon commit completion. */
603 gnc_resume_gui_refresh ();
604}
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition Account.cpp:1516
void xaccAccountSetAppendText(Account *acc, gboolean val)
Set the "import-append-text" flag for an account.
Definition Account.cpp:4137
SplitList * xaccTransGetSplitList(const Transaction *trans)
The xaccTransGetSplitList() method returns a GList of the splits in a transaction.
gboolean gnc_import_process_trans_item(Account *base_acc, GNCImportTransInfo *trans_info)
/brief – Processes one match according to its selected action.
void gnc_import_TransInfo_set_append_text(GNCImportTransInfo *info, gboolean append_text)
Set the append_text for this TransInfo.

◆ split_find_match()

void split_find_match ( GNCImportTransInfo *  trans_info,
Split *  split,
gint  display_threshold,
gint  date_threshold,
gint  date_not_threshold,
double  fuzzy_amount_difference 
)

The transaction matching heuristics are here.

Evaluates the match between trans_info and split using the provided parameters.

Parameters
trans_infoThe TransInfo for the imported transaction
splitThe register split that should be evaluated for a match.
display_thresholdMinimum match score to include split in the list of matches.
date_thresholdMaximum number of days a match considered likely.
date_not_thresholdMinimum number of days a match is considered unlikely.
fuzzy_amount_differenceMaximum amount difference to consider the match good.

Definition at line 579 of file import-backend.cpp.

585{
586 gint prob = 0;
587
588 auto new_trans = gnc_import_TransInfo_get_trans (trans_info);
589 auto new_trans_fsplit = gnc_import_TransInfo_get_fsplit (trans_info);
590
591 /* Matching heuristics */
592
593 /* Amount heuristics */
594 auto downloaded_split_amount =
595 gnc_numeric_to_double (xaccSplitGetAmount(new_trans_fsplit));
596 DEBUG(" downloaded_split_amount=%f", downloaded_split_amount);
597 auto match_split_amount = gnc_numeric_to_double(xaccSplitGetAmount(split));
598 DEBUG(" match_split_amount=%f", match_split_amount);
599 if (fabs(downloaded_split_amount - match_split_amount) < 1e-6)
600 /* bug#347791: Double type shouldn't be compared for exact
601 equality, so we're using fabs() instead. */
602 /*if (gnc_numeric_equal(xaccSplitGetAmount
603 (new_trans_fsplit),
604 xaccSplitGetAmount(split)))
605 -- gnc_numeric_equal is an expensive function call */
606 {
607 prob = prob + 3;
608 DEBUG("heuristics: probability + 3 (amount)");
609 }
610 else if (fabs (downloaded_split_amount - match_split_amount) <=
611 fuzzy_amount_difference)
612 {
613 /* ATM fees are sometimes added directly in the transaction.
614 So you withdraw 100$ and get charged 101,25$ in the same
615 transaction */
616 prob = prob + 2;
617 DEBUG("heuristics: probability + 2 (amount)");
618 }
619 else
620 {
621 /* If a transaction's amount doesn't match within the
622 threshold, it's very unlikely to be the same transaction
623 so we give it an extra -5 penalty */
624 prob = prob - 5;
625 DEBUG("heuristics: probability - 1 (amount)");
626 }
627
628 /* Date heuristics */
629 auto match_time = xaccTransGetDate (xaccSplitGetParent (split));
630 auto download_time = xaccTransGetDate (new_trans);
631 auto datediff_day = llabs(match_time - download_time) / 86400;
632 /* Sorry, there are not really functions around at all that
633 provide for less hacky calculation of days of date
634 differences. Whatever. On the other hand, the difference
635 calculation itself will work regardless of month/year
636 turnarounds. */
637 auto download_time_str = qof_print_date(download_time);
638 auto match_time_str = qof_print_date(match_time);
639 DEBUG("Date download: %s vs match: %s", download_time_str, match_time_str);
640 g_free (download_time_str);
641 g_free (match_time_str);
642 DEBUG("diff day %lld", datediff_day);
643 if (datediff_day == 0)
644 {
645 prob = prob + 3;
646 DEBUG("heuristics: probability + 3 (date)");
647 }
648 else if (datediff_day <= date_threshold)
649 {
650 prob = prob + 2;
651 DEBUG("heuristics: probability + 2 (date)");
652 }
653 else if (datediff_day > date_not_threshold)
654 {
655 /* Extra penalty if that split lies awfully far away from
656 the given one. */
657 prob = prob - 5;
658 DEBUG("heuristics: probability - 5 (date)");
659 /* Changed 2005-02-21: Revert the hard-limiting behaviour
660 back to the previous large penalty. (Changed 2004-11-27:
661 The penalty is so high that we can forget about this
662 split anyway and skip the rest of the tests.) */
663 }
664
665 /* Check if date and amount are identical */
666 auto update_proposed = (prob < 6);
667
668 /* Check number heuristics */
669 auto new_trans_str = gnc_get_num_action(new_trans, new_trans_fsplit);
670 auto split_str = gnc_get_num_action (xaccSplitGetParent (split), split);
671 DEBUG("number download: '%s' to match: '%s'", new_trans_str, split_str);
672 if (new_trans_str && *new_trans_str && split_str && *split_str)
673 {
674 char *endptr;
675 auto conversion_ok = true;
676
677 /* To distinguish success/failure after strtol call */
678 errno = 0;
679 auto new_trans_number = strtol(new_trans_str, &endptr, 10);
680 /* Possible addressed problems: over/underflow, only non
681 numbers on string and string empty */
682 conversion_ok = !(errno || endptr == new_trans_str);
683
684 errno = 0;
685 auto split_number = strtol(split_str, &endptr, 10);
686 conversion_ok = !(errno || endptr == split_str);
687
688 if ( (conversion_ok && (split_number == new_trans_number)) ||
689 (g_strcmp0(new_trans_str, split_str) == 0) )
690 {
691 /* An exact match of the Check number gives a +4 */
692 prob += 4;
693 DEBUG("heuristics: probability + 4 (Check number)");
694 }
695 else if (strlen(new_trans_str) > 0 && strlen(split_str) > 0)
696 {
697 /* If both number are not empty yet do not match, add a
698 little extra penalty */
699 prob -= 2;
700 }
701 }
702
703 /* Memo heuristics */
704 auto memo = xaccSplitGetMemo(new_trans_fsplit);
705 auto match_memo = xaccSplitGetMemo(split);
706 if (memo && *memo && match_memo && *match_memo)
707 {
708 DEBUG("memo download: '%s' to match: '%s'", memo, match_memo);
709 if (safe_strcasecmp(memo, match_memo) == 0)
710 {
711 /* An exact match of memo gives a +2 */
712 prob = prob + 2;
713 DEBUG("heuristics: probability + 2 (memo)");
714 }
715 else
716 {
717 const size_t match_memo_len = strlen(match_memo);
718 const size_t memo_len = strlen(memo);
719 const size_t max_memo_len = match_memo_len > memo_len ? match_memo_len : memo_len;
720 if (match_memo_len > 1 && memo_len > 1
721 && (strncasecmp(memo, match_memo, max_memo_len / 2) == 0))
722 {
723 /* Very primitive fuzzy match worth +1. This matches up to the
724 first 50% of the longest string to skip annoying transaction
725 number some banks seem to include in the memo but someone
726 should write something more sophisticated */
727 prob = prob + 1;
728 DEBUG("heuristics: probability + 1 (memo)");
729 }
730 }
731 }
732
733 /* Description heuristics */
734 auto descr = xaccTransGetDescription(new_trans);
735 auto match_descr = xaccTransGetDescription(xaccSplitGetParent(split));
736 if (descr && *descr && match_descr && *match_descr)
737 {
738 DEBUG("description: download: '%s' to match: '%s'", descr, match_descr);
739 if (safe_strcasecmp(descr, match_descr) == 0)
740 {
741 /*An exact match of Description gives a +2 */
742 prob = prob + 2;
743 DEBUG("heuristics: probability + 2 (description)");
744 }
745 else
746 {
747 const size_t match_descr_len = strlen(match_descr);
748 const size_t descr_len = strlen(descr);
749 const size_t max_descr_len = match_descr_len > descr_len ? match_descr_len : descr_len;
750 if (match_descr_len > 1 && descr_len > 1
751 && (strncasecmp(descr, match_descr, max_descr_len / 2) == 0))
752 {
753 /* Very primitive fuzzy match worth +1. This matches up to the
754 first 50% of the longest string to skip annoying transaction
755 number some banks seem to include in the description but someone
756 should write something more sophisticated */
757 prob = prob + 1;
758 DEBUG("heuristics: probability + 1 (description)");
759 }
760 }
761 }
762
763 /* Is the probability high enough? Otherwise do nothing and return. */
764 if (prob < display_threshold) {
765 DEBUG("below threshold: %d", prob);
766 return;
767 }
768
769 /* The probability is high enough, so allocate an object
770 here. Allocating it only when it's actually being used is
771 probably quite some performance gain. */
772 auto match_info = g_new0(GNCImportMatchInfo, 1);
773
774 match_info->probability = prob;
775 match_info->update_proposed = update_proposed;
776 match_info->split = split;
777 match_info->trans = xaccSplitGetParent(split);
778
779
780 /* Append that to the list. Do not use g_list_append because
781 it is slow. The list is sorted afterwards anyway. */
782 trans_info->match_list = g_list_prepend(trans_info->match_list, match_info);
783 DEBUG("Added to list of possible matches: %d", prob);
784}
double gnc_numeric_to_double(gnc_numeric in)
Convert numeric to floating-point value.
gint safe_strcasecmp(const gchar *da, const gchar *db)
case sensitive comparison of strings da and db - either may be NULL.
Definition qofutil.cpp:100

Variable Documentation

◆ libgncmod_ofx_gnc_module_age

int libgncmod_ofx_gnc_module_age = 0

Definition at line 43 of file gncmod-ofx-import.c.

◆ libgncmod_ofx_gnc_module_current

int libgncmod_ofx_gnc_module_current = 0

Definition at line 41 of file gncmod-ofx-import.c.

◆ libgncmod_ofx_gnc_module_revision

int libgncmod_ofx_gnc_module_revision = 0

Definition at line 42 of file gncmod-ofx-import.c.

◆ libgncmod_ofx_gnc_module_system_interface

int libgncmod_ofx_gnc_module_system_interface = 0

Definition at line 38 of file gncmod-ofx-import.c.

◆ num_auto_matches

gint GNCPendingMatches::num_auto_matches

Definition at line 39 of file import-pending-matches.cpp.

◆ num_manual_matches

gint GNCPendingMatches::num_manual_matches

Definition at line 38 of file import-pending-matches.cpp.