diff --git a/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp b/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp
index 075f46389b..14a8ffaa65 100644
--- a/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp
+++ b/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp
@@ -434,7 +434,7 @@ GtkTreeModel *get_model (bool all_commodity)
/* Hide the template entry */
if (g_utf8_collate (tmp_namespace, "template" ) != 0)
{
- if ((g_utf8_collate (tmp_namespace, GNC_COMMODITY_NS_CURRENCY ) == 0) || (all_commodity == true))
+ if ((g_utf8_collate (tmp_namespace, GNC_COMMODITY_NS_CURRENCY ) == 0) || (all_commodity == true))
{
commodity_list = gnc_commodity_table_get_commodities (commodity_table, tmp_namespace);
commodity_list = g_list_first (commodity_list);
@@ -1727,10 +1727,10 @@ CsvImpPriceAssist::assist_summary_page_prepare ()
{
auto text = std::string("");
text += _("The prices were imported from the file '") + m_file_name + "'.";
- text += _("\n\nThe number of Prices added was ") + std::to_string(price_imp->m_prices_added);
- text += _(", duplicated was ") + std::to_string(price_imp->m_prices_duplicated);
- text += _(" and replaced was ") + std::to_string(price_imp->m_prices_replaced);
- text += ".";
+ text += _("\n\nThere were ") + std::to_string(price_imp->m_prices_added);
+ text += _(" Prices added, ") + std::to_string(price_imp->m_prices_duplicated);
+ text += _(" duplicated and ") + std::to_string(price_imp->m_prices_replaced);
+ text += _(" replaced.");
gtk_label_set_markup (GTK_LABEL(summary_label), text.c_str());
}
diff --git a/gnucash/import-export/csv-imp/assistant-csv-price-import.glade b/gnucash/import-export/csv-imp/assistant-csv-price-import.glade
index 764b1967a2..33db2669c5 100644
--- a/gnucash/import-export/csv-imp/assistant-csv-price-import.glade
+++ b/gnucash/import-export/csv-imp/assistant-csv-price-import.glade
@@ -43,21 +43,27 @@
+
+
+
+
+
+
@@ -1094,8 +1101,9 @@ For example
diff --git a/gnucash/import-export/csv-imp/gnc-price-import.cpp b/gnucash/import-export/csv-imp/gnc-price-import.cpp
index 38a3cbcb57..d5d3862ad7 100644
--- a/gnucash/import-export/csv-imp/gnc-price-import.cpp
+++ b/gnucash/import-export/csv-imp/gnc-price-import.cpp
@@ -62,7 +62,7 @@ const gchar* currency_format_user_price[] = {N_("Locale"),
/** Constructor for GncPriceImport.
- * @return Pointer to a new GncCSvParseData
+ * @return Pointer to a new GncCsvParseData
*/
GncPriceImport::GncPriceImport(GncImpFileFormat format)
{
@@ -142,7 +142,7 @@ bool GncPriceImport::over_write () { return m_over_write; }
/** Sets a from commodity. This is the commodity all import data relates to.
* When a from commodity is set, there can't be any from columns selected
* in the import data.
- * @param from_commodity Pointer to a commodity or NULL.
+ * @param from_commodity pointer to a commodity or NULL.
*/
void GncPriceImport::from_commodity (gnc_commodity* from_commodity)
{
@@ -164,7 +164,7 @@ gnc_commodity *GncPriceImport::from_commodity () { return m_settings.m_from_comm
/** Sets a to currency. This is the to currency all import data relates to.
* When a to currency is set, there can't be any to currency columns selected
* in the import data.
- * @param to_currency Pointer to a commodity or NULL.
+ * @param to_currency pointer to a commodity or NULL.
*/
void GncPriceImport::to_currency (gnc_commodity* to_currency)
{
@@ -221,7 +221,6 @@ int GncPriceImport::date_format () { return m_settings.m_date_format; }
*/
void GncPriceImport::encoding (const std::string& encoding)
{
-
// TODO investigate if we can catch conversion errors and report them
if (m_tokenizer)
{
@@ -309,12 +308,10 @@ void GncPriceImport::settings (const CsvTransSettings& settings)
std::copy_n (settings.m_column_types_price.begin(),
std::min (m_settings.m_column_types_price.size(), settings.m_column_types_price.size()),
m_settings.m_column_types_price.begin());
-
}
bool GncPriceImport::save_settings ()
{
-
if (trans_preset_is_reserved_name (m_settings.m_name))
return true;
@@ -327,7 +324,6 @@ bool GncPriceImport::save_settings ()
auto fwtok = dynamic_cast(m_tokenizer.get());
m_settings.m_column_widths = fwtok->get_columns();
}
-
return m_settings.save();
}
@@ -342,7 +338,6 @@ std::string GncPriceImport::settings_name () { return m_settings.m_name; }
*/
void GncPriceImport::load_file (const std::string& filename)
{
-
/* Get the raw data first and handle an error if one occurs. */
try
{
@@ -407,7 +402,6 @@ void GncPriceImport::tokenize (bool guessColTypes)
}
}
-
struct ErrorListPrice
{
public:
@@ -428,7 +422,6 @@ std::string ErrorListPrice::str()
return m_error.substr(0, m_error.size() - 1);
}
-
/* Test for the required minimum number of columns selected and
* the selection is consistent.
* @param An ErrorListPrice object to which all found issues are added.
@@ -450,7 +443,7 @@ void GncPriceImport::verify_column_selections (ErrorListPrice& error_msg)
if (!check_for_column_type(GncPricePropType::TO_CURRENCY))
{
if (!m_settings.m_to_currency)
- error_msg.add_error( _("Please select a Currency to column or set a Currency in the Currency To field."));
+ error_msg.add_error( _("Please select a 'Currency to' column or set a Currency in the 'Currency To' field."));
}
/* Verify a Commodity from column is selected.
@@ -458,11 +451,10 @@ void GncPriceImport::verify_column_selections (ErrorListPrice& error_msg)
if (!check_for_column_type(GncPricePropType::FROM_COMMODITY))
{
if (!m_settings.m_from_commodity)
- error_msg.add_error( _("Please select a Commodity from column or set a Commodity in the Commodity From field."));
+ error_msg.add_error( _("Please select a 'Commodity from' column or set a Commodity in the 'Commodity From' field."));
}
}
-
/* Check whether the chosen settings can successfully parse
* the import data. This will check:
* - there's at least one line selected for import
@@ -547,7 +539,7 @@ void GncPriceImport::create_price (std::vector::iterator& parsed_l
error_message.clear();
- // Add a CURRENCY_TO property with the default currency to if no currency to column was set by the user
+ // Add a CURRENCY_TO property with the selected 'currency to' if no 'currency to' column was set by the user
auto line_to_currency = price_props->get_to_currency();
if (!line_to_currency)
{
@@ -555,16 +547,16 @@ void GncPriceImport::create_price (std::vector::iterator& parsed_l
price_props->set_to_currency(m_settings.m_to_currency);
else
{
- // Oops - the user didn't select an Account column *and* we didn't get a default value either!
+ // Oops - the user didn't select a 'currency to' column *and* we didn't get a selected value either!
// Note if you get here this suggests a bug in the code!
- error_message = _("No Currency to column selected and no default Currency specified either.\n"
+ error_message = _("No 'Currency to' column selected and no selected Currency specified either.\n"
"This should never happen. Please report this as a bug.");
PINFO("User warning: %s", error_message.c_str());
throw std::invalid_argument(error_message);
}
}
- // Add a COMMODITY_FROM property with the default commodity from if no commodity from column was set by the user
+ // Add a COMMODITY_FROM property with the selected 'commodity from' if no 'commodity from' column was set by the user
auto line_from_commodity = price_props->get_from_commodity();
if (!line_from_commodity)
{
@@ -572,9 +564,9 @@ void GncPriceImport::create_price (std::vector::iterator& parsed_l
price_props->set_from_commodity(m_settings.m_from_commodity);
else
{
- // Oops - the user didn't select an Account column *and* we didn't get a default value either!
+ // Oops - the user didn't select a 'commodity from' column *and* we didn't get a selected value either!
// Note if you get here this suggests a bug in the code!
- error_message = _("No Commodity from column selected and no default Commodity specified either.\n"
+ error_message = _("No 'Commodity from' column selected and no selected Commodity specified either.\n"
"This should never happen. Please report this as a bug.");
PINFO("User warning: %s", error_message.c_str());
throw std::invalid_argument(error_message);
@@ -605,7 +597,6 @@ void GncPriceImport::create_price (std::vector::iterator& parsed_l
}
}
-
/** Creates a list of prices from parsed data. The parsed data
* will first be validated. If any errors are found in lines that are marked
* for processing (ie not marked to skip) this function will
@@ -697,11 +688,11 @@ GncPriceImport::set_column_type_price (uint32_t position, GncPricePropType type,
m_settings.m_column_types_price.at (position) = type;
- // If the user has set a Commodity from column, we can't have a commodity from default set
+ // If the user has set a 'commodity from' column, we can't have a commodity from selected
if (type == GncPricePropType::FROM_COMMODITY)
from_commodity (nullptr);
- // If the user has set a Currency to column, we can't have a currency to default set
+ // If the user has set a 'currency to' column, we can't have a currency to selected
if (type == GncPricePropType::TO_CURRENCY)
to_currency (nullptr);
diff --git a/gnucash/import-export/csv-imp/gnc-price-props.cpp b/gnucash/import-export/csv-imp/gnc-price-props.cpp
index d9293e13dd..2deffb3660 100644
--- a/gnucash/import-export/csv-imp/gnc-price-props.cpp
+++ b/gnucash/import-export/csv-imp/gnc-price-props.cpp
@@ -160,7 +160,7 @@ time64 parse_date_price (const std::string &date_str, int format)
}
-/** Convert str into a GncRational using the user-specified (import) currency format.
+/** Convert str into a GncNumeric using the user-specified (import) currency format.
* @param str The string to be parsed
* @param currency_format The currency format to use.
* @return a GncNumeric
@@ -200,6 +200,11 @@ GncNumeric parse_amount_price (const std::string &str, int currency_format)
return GncNumeric(val);
}
+/** Convert comm_str into a gnc_commodity.
+ * @param comm_str The string to be parsed
+ * @return a gnc_commodity
+ * @exception May throw std::invalid argument if string can't be parsed properly
+ */
gnc_commodity* parse_commodity_price_comm (const std::string& comm_str)
{
if (comm_str.empty())
@@ -324,9 +329,9 @@ std::string GncImportPrice::verify_essentials (void)
else if (m_amount == boost::none)
return _("No amount column.");
else if (m_to_currency == boost::none)
- return _("No Currency to column.");
+ return _("No 'Currency to' column.");
else if (m_from_commodity == boost::none)
- return _("No Commodity from column.");
+ return _("No 'Commodity from' column.");
else
return std::string();
}
@@ -417,7 +422,6 @@ Result GncImportPrice::create_price (QofBook* book, GNCPriceDB *pdb, bool over)
if (perr == false)
throw std::invalid_argument (_("Failed to create price from selected columns."));
-//FIXME Not sure about this, should this be a PWARN
}
else
{
diff --git a/gnucash/import-export/csv-imp/gnc-price-props.hpp b/gnucash/import-export/csv-imp/gnc-price-props.hpp
index 1d44ff6ae0..9ae485323e 100644
--- a/gnucash/import-export/csv-imp/gnc-price-props.hpp
+++ b/gnucash/import-export/csv-imp/gnc-price-props.hpp
@@ -90,6 +90,7 @@ public:
void set_date_format (int date_format) { m_date_format = date_format ;}
void set_currency_format (int currency_format) { m_currency_format = currency_format ;}
void reset (GncPricePropType prop_type);
+ std::string verify_essentials (void);
Result create_price (QofBook* book, GNCPriceDB *pdb, bool over);
gnc_commodity* get_from_commodity () { if (m_from_commodity) return *m_from_commodity; else return nullptr; }