Commit dfe4d61d authored by Stephane Mankowski's avatar Stephane Mankowski
Browse files

BUG:324972

Import fails without an error when account is defined in CSV
New warning in case of operation not imported because before the last imported one
parent c7447ecc
......@@ -18,6 +18,7 @@ skrooge (1.8.0)
*Correction bug 322069: Designer plugins should be unversioned .so files
*Correction bug 323380: Minor date bug when using the stock portfolio widgets
*Correction bug 320066: Crash importing KmyMoney exported file from Skrooge
*Correction bug 324972: Import fails without an error when account is defined in CSV
*Correction: KMyMoney exports does not need a check of integrity anymore
*Correction: Addition of all icons in size 256 and 512
*Correction: Block drop of a bookmark under an other bookmark
......
......@@ -269,7 +269,7 @@ SKGError SKGImportExportManager::finalizeImportation()
int nbOperations;
err = m_document->getNbObjects("v_operation", wc, nbOperations);
if (!err && nbOperations) {
err = m_document->sendMessage(i18np("one operation not imported because it already exists", "%1 operations not imported because they already exists", nbOperations), SKGDocument::Warning);
err = m_document->sendMessage(i18np("One operation not imported because it already exists", "%1 operations not imported because they already exists", nbOperations), SKGDocument::Warning);
// Remove operations imported for nothing
IFOKDO(err, m_document->executeSqliteOrder("DELETE from operation WHERE id IN (SELECT id from v_operation WHERE " % wc % ')'))
......@@ -278,8 +278,18 @@ SKGError SKGImportExportManager::finalizeImportation()
// Delete operations before the last import
if (m_since_last_import && !err) {
SKGTRACEINRC(2, "SKGImportExportManager::finalizeImportation-deletebeforelastimport", err);
err = m_document->executeSqliteOrder("DELETE FROM operation WHERE operation.t_imported='T' AND "
"EXISTS(SELECT 1 FROM operation o INDEXED BY idx_operation_rd_account_id_t_imported WHERE o.rd_account_id=operation.rd_account_id AND o.t_imported IN ('Y', 'P') AND o.d_date>operation.d_date)");
// Count the number of operations before the last import
QString wc2 = "operation.t_imported='T' AND "
"EXISTS(SELECT 1 FROM operation o INDEXED BY idx_operation_rd_account_id_t_imported WHERE o.rd_account_id=operation.rd_account_id AND o.t_imported IN ('Y', 'P') AND o.d_date>operation.d_date)";
int nbOperations2;
err = m_document->getNbObjects("operation", wc2, nbOperations2);
if (!err && nbOperations2) {
err = m_document->sendMessage(i18np("One operation not imported because before the last imported one, you can uncheck the option to avoid this", "%1 operations not imported because before the last imported one, you can uncheck the option to avoid this", nbOperations2), SKGDocument::Warning);
// Remove operations imported for nothing
IFOKDO(err, m_document->executeSqliteOrder("DELETE from operation WHERE " % wc2))
}
}
// For performances
......
account;amount;date
My account;1000;08.08.2013
\ No newline at end of file
account;amount;date
My account;2000;06.06.2013
\ No newline at end of file
......@@ -55,6 +55,43 @@ int main(int argc, char** argv)
}
}
{
// Test bug 324972
SKGDocumentBank document1;
SKGTESTERROR("document1.initialize()", document1.initialize(), true);
SKGError err;
{
// Scope of the transaction
SKGBEGINTRANSACTION(document1, "IMPORT_CSV", err);
SKGImportExportManager imp1(&document1, KUrl::fromLocalFile(SKGTest::getTestPath("IN") % "/skgtestvariousbugs/324972_1.csv"));
SKGTESTERROR("imp1.importFile", imp1.importFile(), true);
}
{
// Scope of the transaction
SKGBEGINTRANSACTION(document1, "IMPORT_CSV", err);
SKGImportExportManager imp1(&document1, KUrl::fromLocalFile(SKGTest::getTestPath("IN") % "/skgtestvariousbugs/324972_2.csv"));
SKGTESTERROR("imp1.importFile", imp1.importFile(), true);
QStringList messages;
QList<SKGDocument::MessageType> types;
SKGTESTERROR("DOC.getMessages", document1.getMessages(document1.getCurrentTransaction(), messages, types, true), true);
bool test = false;
foreach(const QString & msg, messages) {
SKGTRACE << "Message:" << msg << endl;
if (msg.contains("last imported one")) test = true;
}
SKGTEST("message.last imported one", static_cast<unsigned int>(test), 1);
}
SKGAccountObject account;
SKGTESTERROR("ACCOUNT.getObjectByName", SKGNamedObject::getObjectByName(&document1, "v_account", "My account", account), true);
SKGTESTERROR("ACCOUNT.load", account.load(), true);
SKGTEST("ACCOUNT:getCurrentAmount", SKGServices::doubleToString(account.getCurrentAmount()), "1000");
}
{
// Test import Weboob
SKGDocumentBank document1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment