csv-impport - Allow empty amount fields

Treat empty amount fields as 0. This is necessary for example in the case the
csv import file has both a deposit and a withdrawal column.

Note this issue was masked by the bug fixed in the previus commit.
This commit is contained in:
Geert Janssens 2018-04-14 12:01:32 +02:00
parent 10f8f6a750
commit 7321c995b4

View File

@ -102,7 +102,11 @@ GncTransPropType sanitize_trans_prop (GncTransPropType prop, bool multi_split)
*/
GncNumeric parse_amount (const std::string &str, int currency_format)
{
/* If a cell is empty or just spaces return invalid amount */
/* An empty field is treated as zero */
if (str.empty())
return GncNumeric{};
/* Strings otherwise containing not digits will be considered invalid */
if(!boost::regex_search(str, boost::regex("[0-9]")))
throw std::invalid_argument (_("Value doesn't appear to contain a valid number."));