mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-25 18:30:23 -06:00
[import matcher] Don't normalize text when appending descriptions or notes.
Another fix for Bug 798679. Normalized strings are still stored in quickfills.
This commit is contained in:
parent
65d3546f10
commit
ccd328db9a
@ -859,6 +859,27 @@ notes_append (Transaction* selected_match_trans, gchar* new_notes)
|
|||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char*
|
||||||
|
maybe_append_string (const char* match_string, const char* imp_string)
|
||||||
|
{
|
||||||
|
char *norm_match_string, *norm_imp_string;
|
||||||
|
|
||||||
|
if (!(match_string && *match_string))
|
||||||
|
return g_strdup(imp_string);
|
||||||
|
|
||||||
|
if (!(imp_string && *imp_string))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
norm_match_string = g_utf8_normalize (match_string, -1, G_NORMALIZE_ALL);
|
||||||
|
norm_imp_string = g_utf8_normalize (imp_string, -1, G_NORMALIZE_ALL);
|
||||||
|
|
||||||
|
if (g_utf8_strlen (norm_imp_string, -1) > g_utf8_strlen (norm_match_string, -1) ||
|
||||||
|
!strstr (norm_match_string, norm_imp_string))
|
||||||
|
return g_strconcat(match_string, "|", imp_string, NULL);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Append or replace transaction description and notes
|
/* Append or replace transaction description and notes
|
||||||
* depending on the Append checkbox
|
* depending on the Append checkbox
|
||||||
*/
|
*/
|
||||||
@ -868,52 +889,25 @@ update_desc_and_notes (const GNCImportTransInfo* trans_info)
|
|||||||
GNCImportMatchInfo* selected_match =
|
GNCImportMatchInfo* selected_match =
|
||||||
gnc_import_TransInfo_get_selected_match (trans_info);
|
gnc_import_TransInfo_get_selected_match (trans_info);
|
||||||
Transaction* imp_trans = gnc_import_TransInfo_get_trans (trans_info);
|
Transaction* imp_trans = gnc_import_TransInfo_get_trans (trans_info);
|
||||||
|
Transaction* match_trans = selected_match->trans;
|
||||||
|
|
||||||
if (trans_info->append_text)
|
if (trans_info->append_text)
|
||||||
{
|
{
|
||||||
gchar *desc_imported, *desc_matched, *note_imported, *note_matched;
|
gchar *repl_str;
|
||||||
const gchar* raw_str = xaccTransGetDescription (imp_trans);
|
|
||||||
|
|
||||||
desc_imported =
|
repl_str =
|
||||||
raw_str ? g_utf8_normalize (raw_str, -1, G_NORMALIZE_ALL) : NULL;
|
maybe_append_string (xaccTransGetDescription(match_trans),
|
||||||
raw_str = xaccTransGetDescription (selected_match->trans);
|
xaccTransGetDescription(imp_trans));
|
||||||
desc_matched =
|
if (repl_str)
|
||||||
raw_str ? g_utf8_normalize (raw_str, -1, G_NORMALIZE_ALL) : NULL;
|
xaccTransSetDescription(match_trans, repl_str);
|
||||||
raw_str = xaccTransGetNotes (imp_trans);
|
g_free (repl_str);
|
||||||
note_imported =
|
|
||||||
raw_str ? g_utf8_normalize (raw_str, -1, G_NORMALIZE_ALL) : NULL;
|
|
||||||
raw_str = xaccTransGetNotes (selected_match->trans);
|
|
||||||
note_matched =
|
|
||||||
raw_str ? g_utf8_normalize (raw_str, -1, G_NORMALIZE_ALL) : NULL;
|
|
||||||
|
|
||||||
// Append if desc_imported not already in desc_matched
|
repl_str =
|
||||||
if (desc_imported &&
|
maybe_append_string (xaccTransGetNotes(match_trans),
|
||||||
(!desc_matched ||
|
xaccTransGetNotes(imp_trans));
|
||||||
g_utf8_strlen (desc_imported, -1) > g_utf8_strlen (desc_matched, -1) ||
|
if (repl_str)
|
||||||
!strstr (desc_matched, desc_imported)))
|
xaccTransSetNotes (match_trans, repl_str);
|
||||||
{
|
g_free (repl_str);
|
||||||
if (desc_matched && *desc_matched)
|
|
||||||
desc_append (selected_match->trans, desc_imported);
|
|
||||||
else
|
|
||||||
xaccTransSetDescription (selected_match->trans, desc_imported);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Append if note_imported not already in note_matched
|
|
||||||
if (note_imported &&
|
|
||||||
(!note_matched ||
|
|
||||||
g_utf8_strlen (note_imported, -1) > g_utf8_strlen (note_matched, -1) ||
|
|
||||||
!strstr (note_matched, note_imported)))
|
|
||||||
{
|
|
||||||
if (note_matched && *note_matched)
|
|
||||||
notes_append (selected_match->trans, note_imported);
|
|
||||||
else
|
|
||||||
xaccTransSetNotes (selected_match->trans, note_imported);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free(desc_imported);
|
|
||||||
g_free(desc_matched);
|
|
||||||
g_free(note_imported);
|
|
||||||
g_free(note_matched);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user