Rex Dieter a58b0a0
From 5796089e8cc2b9951ce8e32cfb87f7a1dd9d9f20 Mon Sep 17 00:00:00 2001
Rex Dieter a58b0a0
From: =?UTF-8?q?=C5=81ukasz=20Wojni=C5=82owicz?=
Rex Dieter a58b0a0
 <lukasz.wojnilowicz@gmail.com>
Rex Dieter a58b0a0
Date: Sat, 18 Jun 2016 19:22:23 +0200
Rex Dieter a58b0a0
Subject: [PATCH 11/22] Fix importing fees with comma as decimal separator
Rex Dieter a58b0a0
Rex Dieter a58b0a0
BUG: 363954
Rex Dieter a58b0a0
REVIEW: 128100
Rex Dieter a58b0a0
---
Rex Dieter a58b0a0
 kmymoney/plugins/csvimport/investprocessing.cpp | 32 ++++++++++++++++---------
Rex Dieter a58b0a0
 1 file changed, 21 insertions(+), 11 deletions(-)
Rex Dieter a58b0a0
Rex Dieter a58b0a0
diff --git a/kmymoney/plugins/csvimport/investprocessing.cpp b/kmymoney/plugins/csvimport/investprocessing.cpp
Rex Dieter a58b0a0
index 7562c73..49fc81d 100644
Rex Dieter a58b0a0
--- a/kmymoney/plugins/csvimport/investprocessing.cpp
Rex Dieter a58b0a0
+++ b/kmymoney/plugins/csvimport/investprocessing.cpp
Rex Dieter a58b0a0
@@ -1368,19 +1368,29 @@ int InvestProcessing::processInvestLine(const QString& inBuffer)
Rex Dieter a58b0a0
     }
Rex Dieter a58b0a0
 
Rex Dieter a58b0a0
     else if (m_columnTypeList[i] == "fee") {      //                Fee Col
Rex Dieter a58b0a0
-      MyMoneyMoney amount;
Rex Dieter a58b0a0
-      double percent = m_columnList[i].toDouble();// fee val or percent
Rex Dieter a58b0a0
-      if (percent > 0.00) {
Rex Dieter a58b0a0
-        if (m_csvDialog->m_wiz->m_pageInvestment->ui->checkBoxInv_feeType->isChecked()) {      //   fee is percent
Rex Dieter a58b0a0
-          //have to use amountCol as amount field may not yet have been processed
Rex Dieter a58b0a0
-          txt = inBuffer.section(m_fieldDelimiterCharacter, m_amountColumn, m_amountColumn);
Rex Dieter a58b0a0
-          amount = MyMoneyMoney(txt);
Rex Dieter a58b0a0
-          percent *= amount.toDouble() / 100;//               as percentage
Rex Dieter a58b0a0
+      txt = m_columnList[i];
Rex Dieter a58b0a0
+      txt = txt.remove('"');
Rex Dieter a58b0a0
+      if (txt.contains(')')) {
Rex Dieter a58b0a0
+        txt = '-' + txt.remove(QRegExp("[()]"));   //            Mark as -ve
Rex Dieter a58b0a0
+      }
Rex Dieter a58b0a0
+      newTxt = m_parse->possiblyReplaceSymbol(txt);
Rex Dieter a58b0a0
+      MyMoneyMoney fee = MyMoneyMoney(newTxt);
Rex Dieter a58b0a0
+      if (m_csvDialog->m_wiz->m_pageInvestment->ui->checkBoxInv_feeType->isChecked() &&
Rex Dieter a58b0a0
+        fee.toDouble() > 0.00 ) {      //   fee is percent
Rex Dieter a58b0a0
+        txt = m_columnList[m_amountColumn];
Rex Dieter a58b0a0
+        txt = txt.remove('"');
Rex Dieter a58b0a0
+        if (txt.contains(')')) {
Rex Dieter a58b0a0
+          txt = '-' +  txt.remove(QRegExp("[()]"));   //            Mark as -ve
Rex Dieter a58b0a0
         }
Rex Dieter a58b0a0
-        txt.setNum(percent, 'f', 4);
Rex Dieter a58b0a0
-        m_trInvestData.fee = MyMoneyMoney(percent);
Rex Dieter a58b0a0
-        m_tempBuffer +=  'O' + txt + '\n';//                  fee amount
Rex Dieter a58b0a0
+        newTxt = m_parse->possiblyReplaceSymbol(txt);
Rex Dieter a58b0a0
+        MyMoneyMoney amount = MyMoneyMoney(newTxt);
Rex Dieter a58b0a0
+        fee *= amount / MyMoneyMoney(100) ;//               as percentage
Rex Dieter a58b0a0
       }
Rex Dieter a58b0a0
+      fee.abs();
Rex Dieter a58b0a0
+      m_trInvestData.fee =  fee;
Rex Dieter a58b0a0
+      txt.setNum(fee.toDouble(), 'f', 4);
Rex Dieter a58b0a0
+      newTxt = m_parse->possiblyReplaceSymbol(txt);
Rex Dieter a58b0a0
+      m_tempBuffer +=  'O' + newTxt + '\n';//                  fee amount
Rex Dieter a58b0a0
     }
Rex Dieter a58b0a0
 
Rex Dieter a58b0a0
     else if (m_columnTypeList[i] == "symbol") { //                Symbol Col
Rex Dieter a58b0a0
-- 
Rex Dieter a58b0a0
2.7.4
Rex Dieter a58b0a0