[Kmymoney-devel] [kmymoney4] [Bug 342047] New: Price quote importer does not take into account locale settings

David Houlden djhoulden at gmail.com
Sat Dec 20 12:54:49 UTC 2014


            Bug ID: 342047
           Summary: Price quote importer does not take into account locale
           Product: kmymoney4
           Version: git master
          Platform: Compiled Sources
                OS: Linux
            Status: UNCONFIRMED
          Severity: wishlist
          Priority: NOR
         Component: general
          Assignee: kmymoney-devel at kde.org
          Reporter: djhoulden at gmail.com

In webpricequote.cpp there is the following code and comment.

if (priceRegExp.indexIn(quotedata) > -1) {
      gotprice = true;

      // Deal with european quotes that come back as X.XXX,XX or XX,XXX
      // We will make the assumption that ALL prices have a decimal separator.
      // So "1,000" always means 1.0, not 1000.0.
      // Remove all non-digits from the price string except the last one, and
      // set the last one to a period.
      QString pricestr = priceRegExp.cap(1);

      int pos = pricestr.lastIndexOf(QRegExp("\\D"));
      if (pos > 0) {
        pricestr[pos] = '.';
        pos = pricestr.lastIndexOf(QRegExp("\\D"), pos - 1);
      while (pos > 0) {
        pricestr.remove(pos, 1);
        pos = pricestr.lastIndexOf(QRegExp("\\D"), pos);

      d->m_price = pricestr.toDouble();
      kDebug(Private::dbgArea()) << "Price" << pricestr;
      emit status(i18n("Price found: %1 (%2)", pricestr, d->m_price));

This causes problems with a quote source I have which doesn't return decimal
places if they are zero.

e.g. The source returns 1,065.25 and this correctly gets interpreted as 1065.25
but if the source returns 1,065 this is interpreted as 1.065 instead of 1065.00

Could KMyMoney use the locale thousand separator and decimal indicator when
interpreting prices from quote sources?

Reproducible: Always

You are receiving this mail because:
You are the assignee for the bug.

More information about the KMyMoney-devel mailing list