[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [skrooge] /: Avoid duplicated operation when importing attached accounts with weboob
From: Stephane Mankowski <stephane () mankowski ! fr>
Date: 2016-12-08 21:04:53
Message-ID: E1cF5s5-00038I-CQ () code ! kde ! org
[Download RAW message or body]
Git commit 361bbc2aaa58288fa59152c6ec55ec58c5dc297d by Stephane Mankowski.
Committed on 08/12/2016 at 21:04.
Pushed by smankowski into branch 'master'.
Avoid duplicated operation when importing attached accounts with weboob
M +1 -0 CHANGELOG
M +5 -1 plugins/import/skrooge_import_backend/skgimportpluginbackend.cpp
A +18 -0 tests/input/skgtestimportbackend/joint_accounts/boobank
M +25 -0 tests/skgbankmodelertest/skgtestimportweboob.cpp
https://commits.kde.org/skrooge/361bbc2aaa58288fa59152c6ec55ec58c5dc297d
diff --git a/CHANGELOG b/CHANGELOG
index 7d35e2b8..ffff59eb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -22,6 +22,7 @@ skrooge (2.6.0)
*Correction: weboob backend is now searching transactions on date AND rdate to avoid missing \
transaction
*Correction: Skrooge is now able to download addition stuff (monthly report template, quote source) \
with knewstuff
*Correction: Open file property fails when the property name contains the full path \
(https://forum.kde.org/viewtopic.php?f=210&t=137528) + *Correction: Avoid duplicated operation when \
importing attached accounts with weboob
*New feature: Addition of "nocolor" to the "money" Grantlee filter
*New feature: Remove .skg in backup file name if .skg is added in the prefix \
(https://forum.kde.org/viewtopic.php?f=210&t=136518&p=366065#p366065)
*New feature: "Alarm" dashboard widget is now compliant with QML mode
diff --git a/plugins/import/skrooge_import_backend/skgimportpluginbackend.cpp \
b/plugins/import/skrooge_import_backend/skgimportpluginbackend.cpp index de712166..192f7d9a 100644
--- a/plugins/import/skrooge_import_backend/skgimportpluginbackend.cpp
+++ b/plugins/import/skrooge_import_backend/skgimportpluginbackend.cpp
@@ -143,6 +143,7 @@ SKGError SKGImportPluginBackend::importFile()
QTextStream stream(&file);
stream.readLine(); // To avoid header
+ QStringList backendAccountsUniqueId;
while (!stream.atEnd()) {
// Read line
QString line = stream.readLine().trimmed();
@@ -151,8 +152,11 @@ SKGError SKGImportPluginBackend::importFile()
int pos = reggetaccounts.indexIn(line);
if (pos > -1) {
QString accountid = reggetaccounts.cap(1);
- if (!backendAccounts.contains(accountid)) {
+ QString uniqueid = SKGServices::splitCSVLine(accountid, QLatin1Char('@'))[0];
+
+ if (!backendAccounts.contains(accountid) && \
!backendAccountsUniqueId.contains(uniqueid)) { backendAccounts.push_back(accountid);
+ backendAccountsUniqueId.push_back(uniqueid);
// Get account balance
pos = reggetaccountbalance.indexIn(line);
diff --git a/tests/input/skgtestimportbackend/joint_accounts/boobank \
b/tests/input/skgtestimportbackend/joint_accounts/boobank new file mode 100755
index 00000000..28858096
--- /dev/null
+++ b/tests/input/skgtestimportbackend/joint_accounts/boobank
@@ -0,0 +1,18 @@
+#!/bin/bash
+if [[ $1 = "ls" ]]; then
+ #Simulate: boobank ls -q -f csv -v -s id,balance
+ echo "id;balance"
+ echo "12345@steph;1000"
+ echo "12345@vero;1000"
+else
+ if [[ $5 = "12345@steph" ]]; then
+ #Simulate: boobank -q -f csv history "47896@creditcooperatif" -s rdate,type,raw,label,amount \
--condition "rdate>%4" -n 99999 + echo "rdate;type;raw;label;amount"
+ echo "2013-05-04;0;TOTAL;TOTAL;-50"
+ fi
+ if [[ $5 = "12345@vero" ]]; then
+ #Simulate: boobank -q -f csv history "47896@creditcooperatif" -s rdate,type,raw,label,amount \
--condition "rdate>%4" -n 99999 + echo "rdate;type;raw;label;amount"
+ echo "2013-05-04;0;TOTAL;TOTAL;-50"
+ fi
+fi
diff --git a/tests/skgbankmodelertest/skgtestimportweboob.cpp \
b/tests/skgbankmodelertest/skgtestimportweboob.cpp index 3f8388f8..00203f97 100644
--- a/tests/skgbankmodelertest/skgtestimportweboob.cpp
+++ b/tests/skgbankmodelertest/skgtestimportweboob.cpp
@@ -271,6 +271,31 @@ int main(int argc, char** argv)
SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), \
SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-147994.82")); }
}
+
+
+ {
+ // Better account selection
+ SKGDocumentBank document1;
+ SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true);
+ SKGError err;
+ {
+ // Scope of the transaction
+ SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err);
+
+ SKGTESTBOOL("PUTENV.weboob", qputenv("PATH", (in + "/skgtestimportbackend/joint_accounts/:" \
+ path).toLatin1()), true); +
+ SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob")));
+ SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true);
+ }
+
+ // Check
+ {
+ SKGAccountObject account;
+ SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), \
SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("12345"), \
account), true); + SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true);
+ SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), \
SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1000")); + }
+ }
// End test
SKGENDTEST();
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic