| #define PROBABILITY_FACTOR 100000 |
convert a hash table of account names and (struct account_probability*) into a hash table of 100000x the percentage match value, ie. 10% would be 0.10 * 100000 = 10000
Definition at line 223 of file import-match-map.c.
| enum _action |
| GNCImport_SKIP | |
| GNCImport_ADD | |
| GNCImport_CLEAR | |
| GNCImport_EDIT | |
| GNCImport_LAST_ACTION | |
| GNCImport_INVALID_ACTION |
Definition at line 38 of file import-backend.h.
00038 { 00039 GNCImport_SKIP, 00040 GNCImport_ADD, 00041 GNCImport_CLEAR, 00042 GNCImport_EDIT, 00043 GNCImport_LAST_ACTION, 00044 GNCImport_INVALID_ACTION 00045 } GNCImportAction;
| enum downloaded_cols |
Definition at line 47 of file import-match-picker.c.
00047 { 00048 DOWNLOADED_COL_ACCOUNT = 0, 00049 DOWNLOADED_COL_DATE, 00050 DOWNLOADED_COL_AMOUNT, 00051 DOWNLOADED_COL_DESCRIPTION, 00052 DOWNLOADED_COL_MEMO, 00053 DOWNLOADED_COL_BALANCED, 00054 DOWNLOADED_COL_INFO_PTR, 00055 NUM_DOWNLOADED_COLS 00056 };
| enum downloaded_cols |
Definition at line 58 of file import-main-matcher.c.
00058 { 00059 DOWNLOADED_COL_DATE = 0, 00060 DOWNLOADED_COL_ACCOUNT, 00061 DOWNLOADED_COL_AMOUNT, 00062 DOWNLOADED_COL_DESCRIPTION, 00063 DOWNLOADED_COL_MEMO, 00064 DOWNLOADED_COL_ACTION_ADD, 00065 DOWNLOADED_COL_ACTION_CLEAR, 00066 DOWNLOADED_COL_ACTION_EDIT, 00067 DOWNLOADED_COL_ACTION_INFO, 00068 DOWNLOADED_COL_ACTION_PIXBUF, 00069 DOWNLOADED_COL_DATA, 00070 DOWNLOADED_COL_COLOR, 00071 NUM_DOWNLOADED_COLS 00072 };
| enum matcher_cols |
| MATCHER_COL_CONFIDENCE | |
| MATCHER_COL_CONFIDENCE_PIXBUF | |
| MATCHER_COL_DATE | |
| MATCHER_COL_AMOUNT | |
| MATCHER_COL_DESCRIPTION | |
| MATCHER_COL_MEMO | |
| MATCHER_COL_INFO_PTR | |
| NUM_MATCHER_COLS |
Definition at line 58 of file import-match-picker.c.
00058 { 00059 MATCHER_COL_CONFIDENCE = 0, 00060 MATCHER_COL_CONFIDENCE_PIXBUF, 00061 MATCHER_COL_DATE, 00062 MATCHER_COL_AMOUNT, 00063 MATCHER_COL_DESCRIPTION, 00064 MATCHER_COL_MEMO, 00065 MATCHER_COL_INFO_PTR, 00066 NUM_MATCHER_COLS 00067 };
| 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
| score | The score for which to generate a pixmap. | |
| settings | The user settings from which to get the threshold | |
| widget | The parent widget in which the pixmap will eventually be added. Will be used to generate the colormap. |
Definition at line 262 of file import-backend.c.
00263 { 00264 GdkPixbuf* retval = NULL; 00265 gint i, j; 00266 gint score; 00267 const gint height = 15; 00268 const gint width_each_bar = 7; 00269 gchar * green_bar = ("bggggb "); 00270 gchar * yellow_bar = ("byyyyb "); 00271 gchar * red_bar = ("brrrrb "); 00272 gchar * black_bar = ("bbbbbb "); 00273 const gint width_first_bar = 1; 00274 gchar * black_first_bar = ("b"); 00275 const gint num_colors = 5; 00276 gchar * size_str; 00277 gchar * none_color_str = g_strdup_printf(" c None"); 00278 gchar * green_color_str = g_strdup_printf("g c green"); 00279 gchar * yellow_color_str = g_strdup_printf("y c yellow"); 00280 gchar * red_color_str = g_strdup_printf("r c red"); 00281 gchar * black_color_str = g_strdup_printf("b c black"); 00282 gchar * xpm[2+num_colors+height]; 00283 gint add_threshold, clear_threshold; 00284 00285 g_assert(settings); 00286 g_assert(widget); 00287 if (score_original < 0) 00288 { 00289 score = 0; 00290 } 00291 else 00292 { 00293 score=score_original; 00294 } 00295 size_str = g_strdup_printf("%d%s%d%s%d%s",(width_each_bar*score)+width_first_bar/*width*/," ",height," ",num_colors," 1"/*characters per pixel*/); 00296 00297 /*DEBUG("Begin");*/ 00298 xpm[0]=size_str; 00299 xpm[1]=none_color_str; 00300 xpm[2]=green_color_str; 00301 xpm[3]=yellow_color_str; 00302 xpm[4]=red_color_str; 00303 xpm[5]=black_color_str; 00304 add_threshold = gnc_import_Settings_get_add_threshold(settings); 00305 clear_threshold = gnc_import_Settings_get_clear_threshold(settings); 00306 00307 for(i=0;i<height;i++) 00308 { 00309 xpm[num_colors+1+i]= g_new0(char,(width_each_bar*score)+width_first_bar+1); 00310 for(j=0;j<=score;j++) 00311 { 00312 if(i==0||i==height-1) 00313 { 00314 if (j==0) 00315 { 00316 strcat(xpm[num_colors+1+i],black_first_bar); 00317 } 00318 else 00319 { 00320 strcat(xpm[num_colors+1+i],black_bar); 00321 } 00322 } 00323 else 00324 { 00325 if (j==0) 00326 { 00327 strcat(xpm[num_colors+1+i],black_first_bar); 00328 } 00329 else if (j <= add_threshold) 00330 { 00331 strcat(xpm[num_colors+1+i],red_bar); 00332 } 00333 else if (j >= clear_threshold) 00334 { 00335 strcat(xpm[num_colors+1+i],green_bar); 00336 } 00337 else 00338 { 00339 strcat(xpm[num_colors+1+i],yellow_bar); 00340 } 00341 } 00342 } 00343 } 00344 00345 retval = gdk_pixbuf_new_from_xpm_data((const gchar **)xpm); 00346 for(i=0;i<=num_colors+height;i++) 00347 { 00348 /*DEBUG("free_loop i=%d%s%s",i,": ",xpm[i]);*/ 00349 g_free(xpm[i]); 00350 } 00351 00352 return retval; 00353 }
| void gnc_file_aqbanking_import | ( | const gchar * | aqbanking_importername, | |
| const gchar * | aqbanking_formatname, | |||
| gboolean | exec_as_aqbanking_jobs | |||
| ) |
This routine will pop up a standard file selection dialog asking the user to pick a file to import. This file will be opened and read. Its contents will be imported into the current book, using the import matcher from import-main-matcher.h.
| aqbanking_importername | The aqbanking importer module that should be used. Possible values: "dtaus", "csv", "swift", or more. | |
| aqbanking_formatname | In aqbanking, each importer has one or more data formats available which define the actual data fields that should be used. In aqbanking, such a different format is called a "profile". Possible values for swift: "swift-mt940" or "swift-mt942", but for all others: "default", or more precisely: Look into $datadir/aqbanking/imexporters and look into the "name" field of the foo.conf files. | |
| exec_as_aqbanking_jobs | If TRUE, additionally queue the imported transactions as online jobs over aqbanking/HBCI. If FALSE, just import the transactions and that's it. |
Definition at line 65 of file gnc-file-aqb-import.c.
00068 { 00069 char *selected_filename; 00070 char *default_dir; 00071 int dtaus_fd; 00072 00073 DEBUG("gnc_file_dtaus_import(): Begin...\n"); 00074 00075 default_dir = gnc_get_default_directory(GCONF_SECTION); 00076 selected_filename = gnc_file_dialog(_("Select a file to import"), 00077 NULL, 00078 default_dir, 00079 GNC_FILE_DIALOG_IMPORT); 00080 g_free(default_dir); 00081 00082 if(selected_filename!=NULL) { 00083 /* Remember the directory as the default. */ 00084 default_dir = g_path_get_dirname(selected_filename); 00085 gnc_set_default_directory(GCONF_SECTION, default_dir); 00086 g_free(default_dir); 00087 00088 /*strncpy(file,selected_filename, 255);*/ 00089 DEBUG("Filename found: %s",selected_filename); 00090 00091 DEBUG("Opening selected file"); 00092 dtaus_fd = g_open(selected_filename, O_RDONLY, 0); 00093 if (dtaus_fd == -1) { 00094 DEBUG("Could not open file %s", selected_filename); 00095 return; 00096 } 00097 g_free(selected_filename); 00098 00099 { 00100 int result; 00101 AB_BANKING *ab; 00102 AB_IMEXPORTER *importer; 00103 AB_IMEXPORTER_CONTEXT *ctx=0; 00104 GWEN_BUFFEREDIO *buffio; 00105 GWEN_DB_NODE *dbProfiles; 00106 GWEN_DB_NODE *dbProfile; 00107 GNCInteractor *interactor = NULL; 00108 const char *importerName = aqbanking_importername; 00109 const char *profileName = aqbanking_profilename; 00110 00111 /* Get API */ 00112 ab = gnc_AB_BANKING_new_currentbook (NULL, &interactor); 00113 if (ab == NULL) { 00114 g_message("gnc_file_dtaus_import: Couldn't get HBCI API. Nothing will happen.\n"); 00115 return; 00116 } 00117 g_assert (interactor); 00118 00119 /* get import module */ 00120 importer=AB_Banking_GetImExporter(ab, importerName); 00121 if (!importer) { 00122 DEBUG("Import module %s not found", importerName); 00123 gnc_error_dialog(NULL, "%s",("Import module for DTAUS import not found.")); 00124 return; 00125 } 00126 g_assert(importer); 00127 00128 /* load the import profile */ 00129 dbProfiles=AB_Banking_GetImExporterProfiles(ab, importerName); 00130 00131 /* select profile */ 00132 dbProfile=GWEN_DB_GetFirstGroup(dbProfiles); 00133 while(dbProfile) { 00134 const char *name; 00135 00136 name=GWEN_DB_GetCharValue(dbProfile, "name", 0, 0); 00137 g_assert(name); 00138 if (strcasecmp(name, profileName)==0) 00139 break; 00140 dbProfile=GWEN_DB_GetNextGroup(dbProfile); 00141 } 00142 if (!dbProfile) { 00143 g_warning("Profile \"%s\" for importer \"%s\" not found\n", 00144 profileName, importerName); 00145 /* For debugging: Print those available names that have been found. */ 00146 dbProfile=GWEN_DB_GetFirstGroup(dbProfiles); 00147 while(dbProfile) { 00148 const char *name; 00149 name=GWEN_DB_GetCharValue(dbProfile, "name", 0, 0); 00150 g_assert(name); 00151 g_warning("Only found profile \"%s\"\n", name); 00152 dbProfile=GWEN_DB_GetNextGroup(dbProfile); 00153 } 00154 return; 00155 } 00156 g_assert(dbProfile); 00157 00158 /* import new context */ 00159 ctx=AB_ImExporterContext_new(); 00160 g_assert(ctx); 00161 00162 /* Wrap file in gwen_bufferedio */ 00163 buffio = GWEN_BufferedIO_File_new(dtaus_fd); 00164 g_assert(buffio); 00165 GWEN_BufferedIO_SetReadBuffer(buffio, 0, 1024); 00166 00167 result = AB_ImExporter_Import(importer, 00168 ctx, 00169 buffio, 00170 dbProfile); 00171 00172 DEBUG("Parsing result: %d\n", result); 00173 00174 GWEN_BufferedIO_Close(buffio); 00175 GWEN_BufferedIO_free(buffio); 00176 GWEN_DB_Group_free(dbProfiles); 00177 00178 { 00179 /* Now get all accountinfos */ 00180 GNCImportMainMatcher *importer_generic_gui; 00181 GtkWidget *parent = NULL; 00182 gboolean successful = FALSE; 00183 GList *ab_job_list; 00184 00185 /* Create importer GUI */ 00186 importer_generic_gui = gnc_gen_trans_list_new(parent, NULL, TRUE, 14); 00187 00188 /* Import the transactions from the ctx into gnucash. */ 00189 ab_job_list = gnc_hbci_import_ctx(ab, ctx, importer_generic_gui, 00190 execute_transactions); 00191 /* Finished importing. */ 00192 00193 /* We clean up here. */ 00194 AB_ImExporterContext_free(ctx); 00195 00196 if (execute_transactions) { 00197 /* Wait for the gnucash importer to be finished (it is being 00198 run anyway). */ 00199 result = gnc_gen_trans_list_run (importer_generic_gui); 00200 00201 if (result) 00202 /* Execute these jobs now. This function already delete()s the 00203 job. */ 00204 /* no parent so far; otherwise add this: GNCInteractor_reparent (interactor, parent); */ 00205 successful = gnc_hbci_multijob_execute (parent, ab, ab_job_list, interactor); 00206 /* else */ 00207 00208 /* Delete all jobs from queue in any case. */ 00209 gnc_hbci_clearqueue (ab, ab_job_list); 00210 } 00211 else { 00212 successful = TRUE; 00213 } 00214 00215 if (successful) { 00216 /* If execution was not successful, leave the log window 00217 still intact and open. */ 00218 gnc_AB_BANKING_fini (ab); 00219 gnc_AB_BANKING_delete (ab); 00220 } 00221 } 00222 } 00223 } 00224 }
| void gnc_file_log_replay | ( | void | ) |
The gnc_file_log_replay() routine will pop up a standard file selection dialogue asking the user to pick a log file to replay. If one is selected the the .log file is opened and read. It's contents are then silently merged in the current log file.
Definition at line 495 of file gnc-log-replay.c.
00496 { 00497 char *selected_filename; 00498 char *default_dir; 00499 char read_buf[256]; 00500 char *read_retval; 00501 GtkFileFilter *filter; 00502 FILE *log_file; 00503 char * record_start_str = "===== START"; 00504 /* NOTE: This string must match src/engine/TransLog.c (sans newline) */ 00505 char * expected_header_orig = "mod\ttrans_guid\tsplit_guid\ttime_now\t" 00506 "date_entered\tdate_posted\tacc_guid\tacc_name\tnum\tdescription\t" 00507 "notes\tmemo\taction\treconciled\tamount\tvalue\tdate_reconciled"; 00508 static char *expected_header = NULL; 00509 00510 /* Use g_strdup_printf so we don't get accidental tab -> space conversion */ 00511 if (!expected_header) 00512 expected_header = g_strdup_printf(expected_header_orig); 00513 00514 qof_log_set_level(GNC_MOD_IMPORT, QOF_LOG_DEBUG); 00515 ENTER(" "); 00516 00517 default_dir = gnc_get_default_directory(GCONF_SECTION); 00518 00519 filter = gtk_file_filter_new(); 00520 gtk_file_filter_set_name(filter, "*.log"); 00521 gtk_file_filter_add_pattern(filter, "*.[Ll][Oo][Gg]"); 00522 selected_filename = gnc_file_dialog(_("Select a .log file to replay"), 00523 g_list_prepend(NULL, filter), 00524 default_dir, 00525 GNC_FILE_DIALOG_OPEN); 00526 g_free(default_dir); 00527 00528 if(selected_filename!=NULL) 00529 { 00530 /* Remember the directory as the default. */ 00531 default_dir = g_path_get_dirname(selected_filename); 00532 gnc_set_default_directory(GCONF_SECTION, default_dir); 00533 g_free(default_dir); 00534 00535 /*strncpy(file,selected_filename, 255);*/ 00536 DEBUG("Filename found: %s",selected_filename); 00537 if (xaccFileIsCurrentLog(selected_filename)) { 00538 g_warning("Cannot open the current log file: %s", selected_filename); 00539 gnc_error_dialog(NULL, 00540 /* Translators: %s is the file name. */ 00541 _("Cannot open the current log file: %s"), 00542 selected_filename); 00543 } else { 00544 DEBUG("Opening selected file"); 00545 log_file = g_fopen(selected_filename, "r"); 00546 if(!log_file || ferror(log_file)!=0) { 00547 int err = errno; 00548 perror("File open failed"); 00549 gnc_error_dialog(NULL, 00550 /* Translation note: 00551 * First argument is the filename, 00552 * second argument is the error. 00553 */ 00554 _("Failed to open log file: %s: %s"), 00555 selected_filename, 00556 strerror(err)); 00557 } else { 00558 if((read_retval = fgets(read_buf,sizeof(read_buf),log_file)) == NULL) { 00559 DEBUG("Read error or EOF"); 00560 gnc_info_dialog(NULL, "%s", 00561 _("The log file you selected was empty.")); 00562 } else { 00563 if(strncmp(expected_header,read_buf,strlen(expected_header))!=0) { 00564 PERR("File header not recognised:\n%s",read_buf); 00565 PERR("Expected:\n%s",expected_header); 00566 gnc_error_dialog(NULL, "%s", 00567 _("The log file you selected cannot be read. " 00568 "The file header was not recognized.")); 00569 } else { 00570 do { 00571 read_retval = fgets(read_buf,sizeof(read_buf),log_file); 00572 /*DEBUG("Chunk read: %s",read_retval);*/ 00573 if(strncmp(record_start_str,read_buf,strlen(record_start_str))==0) {/* If a record started */ 00574 process_trans_record(log_file); 00575 } 00576 }while(feof(log_file)==0); 00577 } 00578 } 00579 fclose(log_file); 00580 } 00581 } 00582 g_free(selected_filename); 00583 } 00584 LEAVE(""); 00585 }
| void gnc_file_ofx_import | ( | void | ) |
The gnc_file_ofx_import() routine will pop up a standard file selection dialogue asking the user to pick a OFX/QFX file. If one is selected the the OFX file is opened and read. It's contents are merged into the existing session (if any). The current session continues to remain open for editing.
Definition at line 635 of file gnc-ofx-import.c.
00636 { 00637 extern int ofx_PARSER_msg; 00638 extern int ofx_DEBUG_msg; 00639 extern int ofx_WARNING_msg; 00640 extern int ofx_ERROR_msg; 00641 extern int ofx_INFO_msg; 00642 extern int ofx_STATUS_msg; 00643 char *selected_filename; 00644 char *default_dir; 00645 LibofxContextPtr libofx_context = libofx_get_new_context(); 00646 00647 ofx_PARSER_msg = false; 00648 ofx_DEBUG_msg = false; 00649 ofx_WARNING_msg = true; 00650 ofx_ERROR_msg = true; 00651 ofx_INFO_msg = true; 00652 ofx_STATUS_msg = false; 00653 00654 DEBUG("gnc_file_ofx_import(): Begin...\n"); 00655 00656 default_dir = gnc_get_default_directory(GCONF_SECTION); 00657 selected_filename = gnc_file_dialog(_("Select an OFX/QFX file to process"), 00658 NULL, 00659 default_dir, 00660 GNC_FILE_DIALOG_IMPORT); 00661 g_free(default_dir); 00662 00663 if(selected_filename!=NULL)