File indexing completed on 2024-05-12 16:45:23
0001 /*************************************************************************** 0002 * SPDX-FileCopyrightText: 2022 S. MANKOWSKI stephane@mankowski.fr 0003 * SPDX-FileCopyrightText: 2022 G. DE BURE support@mankowski.fr 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 ***************************************************************************/ 0006 /** @file 0007 * This file is a test script. 0008 * 0009 * @author Stephane MANKOWSKI / Guillaume DE BURE 0010 */ 0011 0012 #include <klocalizedstring.h> 0013 0014 #include "skgbankincludes.h" 0015 #include "skgimportexportmanager.h" 0016 #include "skgtestmacro.h" 0017 0018 /** 0019 * The main function of the unit test 0020 * @param argc the number of arguments 0021 * @param argv the list of arguments 0022 */ 0023 int main(int argc, char** argv) 0024 { 0025 Q_UNUSED(argc) 0026 Q_UNUSED(argv) 0027 0028 // Init test 0029 SKGINITTEST(true) { 0030 // Test import QIF 1 0031 SKGDocumentBank document1; 0032 SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true) 0033 SKGError err; 0034 { 0035 // Scope of the transaction 0036 SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_STOCK_UNIT"), err) 0037 SKGUnitObject unit; 0038 SKGTESTERROR(QStringLiteral("QIF.createCurrencyUnit"), SKGUnitObject::createCurrencyUnit(&document1, QStringLiteral("FRF"), unit), true) 0039 } 0040 document1.dump(DUMPUNIT); 0041 { 0042 // Scope of the transaction 0043 SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_STOCK_1"), err) 0044 SKGUnitObject unit; 0045 SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportstockqif/La Poste GMO.qif")); 0046 SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true) 0047 SKGImportExportManager imp2(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportstockqif/La Poste GMO (Caisse).qif")); 0048 SKGTESTERROR(QStringLiteral("QIF.importFile"), imp2.importFile(), true) 0049 SKGImportExportManager imp3(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportstockqif/goog.qif")); 0050 SKGTESTERROR(QStringLiteral("QIF.importFile"), imp3.importFile(), true) 0051 } 0052 document1.dump(DUMPOPERATION | DUMPUNIT | DUMPACCOUNT); 0053 } 0054 0055 { 0056 // Test import QIF -Correction bug 2307068 0057 SKGDocumentBank document1; 0058 SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true) 0059 SKGError err; 0060 { 0061 // Scope of the transaction 0062 SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_2307068"), err) 0063 0064 SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportstockqif/2307068-BNP CC.qif")); 0065 SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true) 0066 0067 SKGImportExportManager imp12(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportstockqif/2307068-Compte Titre.qif")); 0068 SKGTESTERROR(QStringLiteral("QIF.importFile"), imp12.importFile(), true) 0069 } 0070 0071 document1.dump(DUMPOPERATION | DUMPUNIT | DUMPACCOUNT); 0072 { 0073 SKGAccountObject account(&document1); 0074 SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("BNP CC")), true) 0075 SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true) 0076 SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::toCurrencyString(account.getCurrentAmount(), QLatin1String(""), 2), QStringLiteral("-520.00")) 0077 } 0078 { 0079 SKGAccountObject account(&document1); 0080 SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("Compte Titre")), true) 0081 SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true) 0082 SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("520")) 0083 } 0084 } 0085 // End test 0086 SKGENDTEST() 0087 }