Skip to content

Commit

Permalink
CsvImport - actually do as the warning indicates
Browse files Browse the repository at this point in the history
If an invalid column is found in a preset, replace it
with a NONE column, rather than not inserting a column
at all.
  • Loading branch information
gjanssens committed Mar 13, 2023
1 parent 37e0f40 commit 4ae15e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions gnucash/import-export/csv-imp/gnc-imp-settings-csv-price.cpp
Expand Up @@ -152,14 +152,14 @@ CsvPriceImpSettings::load (void)
{
auto col_types_it = std::find_if (gnc_price_col_type_strs.begin(),
gnc_price_col_type_strs.end(), test_price_prop_type_str (col_types_str_price[i]));
auto prop = GncPricePropType::NONE;
if (col_types_it != gnc_price_col_type_strs.end())
{
// Found a valid column type
m_column_types_price.push_back(col_types_it->first);
}
prop = col_types_it->first;
else
PWARN("Found invalid column type '%s' in group '%s'. Inserting column type 'NONE' instead'.",
col_types_str_price[i], group.c_str());
m_column_types_price.push_back(prop);
}
if (col_types_str_price)
g_strfreev (col_types_str_price);
Expand Down
7 changes: 4 additions & 3 deletions gnucash/import-export/csv-imp/gnc-imp-settings-csv-tx.cpp
Expand Up @@ -261,20 +261,21 @@ CsvTransImpSettings::load (void)
col_type_str = gnc_csv_col_type_strs[GncTransPropType::NUM];
auto col_types_it = std::find_if (gnc_csv_col_type_strs.begin(),
gnc_csv_col_type_strs.end(), test_prop_type_str (col_type_str));
auto prop = GncTransPropType::NONE;
if (col_types_it != gnc_csv_col_type_strs.end())
{
/* Found a valid column type. Now check whether it is allowed
* in the selected mode (two-split vs multi-split) */
auto prop = sanitize_trans_prop (col_types_it->first, m_multi_split);
m_column_types.push_back(prop);
prop = sanitize_trans_prop (col_types_it->first, m_multi_split);
if (prop != col_types_it->first)
PWARN("Found column type '%s', but this is blacklisted when multi-split mode is %s. "
"Inserting column type 'NONE' instead'.",
col_types_it->second, m_multi_split ? "enabled" : "disabled");
}
else
PWARN("Found invalid column type '%s'. Inserting column type 'NONE' instead'.",
col_types_str[i]);
col_types_str[i]);
m_column_types.push_back(prop);
}
if (col_types_str)
g_strfreev (col_types_str);
Expand Down

0 comments on commit 4ae15e6

Please sign in to comment.