[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kmymoney] kmymoney/plugins/csvimport: Fix importing fees with comma as decimal separator
From:       Cristian_Oneț <onet.cristian () gmail ! com>
Date:       2016-06-18 18:09:01
Message-ID: E1bEKg1-0003pl-Iw () code ! kde ! org
[Download RAW message or body]

Git commit bbdfda2597c502ebcc3a9ce20958132abfdebec4 by Cristian Oneț, on behalf of \
Łukasz Wojniłowicz. Committed on 18/06/2016 at 18:06.
Pushed by conet into branch 'master'.

Fix importing fees with comma as decimal separator

BUG: 363954
REVIEW: 128100
(cherry picked from commit 5796089e8cc2b9951ce8e32cfb87f7a1dd9d9f20)

M  +21   -11   kmymoney/plugins/csvimport/investprocessing.cpp

http://commits.kde.org/kmymoney/bbdfda2597c502ebcc3a9ce20958132abfdebec4

diff --git a/kmymoney/plugins/csvimport/investprocessing.cpp \
b/kmymoney/plugins/csvimport/investprocessing.cpp index b266479..c182415 100644
--- a/kmymoney/plugins/csvimport/investprocessing.cpp
+++ b/kmymoney/plugins/csvimport/investprocessing.cpp
@@ -1373,19 +1373,29 @@ int InvestProcessing::processInvestLine(const QString& \
inBuffer)  }
 
     else if (m_columnTypeList[i] == "fee") {      //                Fee Col
-      MyMoneyMoney amount;
-      double percent = m_columnList[i].toDouble();// fee val or percent
-      if (percent > 0.00) {
-        if (m_csvDialog->m_wiz->m_pageInvestment->ui->checkBoxInv_feeType->isChecked()) \
                {      //   fee is percent
-          //have to use amountCol as amount field may not yet have been processed
-          txt = inBuffer.section(m_fieldDelimiterCharacter, m_amountColumn, \
                m_amountColumn);
-          amount = MyMoneyMoney(txt);
-          percent *= amount.toDouble() / 100;//               as percentage
+      txt = m_columnList[i];
+      txt = txt.remove('"');
+      if (txt.contains(')')) {
+        txt = '-' + txt.remove(QRegExp("[()]"));   //            Mark as -ve
+      }
+      newTxt = m_parse->possiblyReplaceSymbol(txt);
+      MyMoneyMoney fee = MyMoneyMoney(newTxt);
+      if (m_csvDialog->m_wiz->m_pageInvestment->ui->checkBoxInv_feeType->isChecked() \
&& +        fee.toDouble() > 0.00 ) {      //   fee is percent
+        txt = m_columnList[m_amountColumn];
+        txt = txt.remove('"');
+        if (txt.contains(')')) {
+          txt = '-' +  txt.remove(QRegExp("[()]"));   //            Mark as -ve
         }
-        txt.setNum(percent, 'f', 4);
-        m_trInvestData.fee = MyMoneyMoney(percent);
-        m_tempBuffer +=  'O' + txt + '\n';//                  fee amount
+        newTxt = m_parse->possiblyReplaceSymbol(txt);
+        MyMoneyMoney amount = MyMoneyMoney(newTxt);
+        fee *= amount / MyMoneyMoney(100) ;//               as percentage
       }
+      fee.abs();
+      m_trInvestData.fee =  fee;
+      txt.setNum(fee.toDouble(), 'f', 4);
+      newTxt = m_parse->possiblyReplaceSymbol(txt);
+      m_tempBuffer +=  'O' + newTxt + '\n';//                  fee amount
     }
 
     else if (m_columnTypeList[i] == "symbol") { //                Symbol Col


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic