diff --git a/src/basic-objects/src/monetaryamount.cpp b/src/basic-objects/src/monetaryamount.cpp index 4aa27405..a028a6b0 100644 --- a/src/basic-objects/src/monetaryamount.cpp +++ b/src/basic-objects/src/monetaryamount.cpp @@ -135,6 +135,10 @@ inline std::pair AmountIntegralFromStr(std:: if (ch == ' ') { break; } + if (ch == ',') { + // Comma can be used to separate thousands, we ignore it. + continue; + } throw exception("Amount string {} with invalid character {}", amountStr, ch); } diff --git a/src/basic-objects/test/monetaryamount_test.cpp b/src/basic-objects/test/monetaryamount_test.cpp index 71797159..262c1e64 100644 --- a/src/basic-objects/test/monetaryamount_test.cpp +++ b/src/basic-objects/test/monetaryamount_test.cpp @@ -767,6 +767,8 @@ TEST(MonetaryAmountTest, ExoticInput) { EXPECT_EQ(MonetaryAmount(" -.9 f&g "), MonetaryAmount("-0.9F&G")); + EXPECT_EQ(MonetaryAmount("2,708.89034514"), MonetaryAmount("2708.89034514")); + EXPECT_THROW(MonetaryAmount("--.9"), exception); }