File indexing completed on 2024-05-19 16:18:17

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 #include "skgtestmacro.h"
0012 #include "skgbankincludes.h"
0013 #include "skgimportexportmanager.h"
0014 
0015 /**
0016  * The main function of the unit test
0017  * @param argc the number of arguments
0018  * @param argv the list of arguments
0019  */
0020 int main(int argc, char** argv)
0021 {
0022     Q_UNUSED(argc)
0023     Q_UNUSED(argv)
0024 
0025     // Init test
0026     SKGINITTEST(true)
0027 
0028     {
0029         // Test import MT940
0030         SKGDocumentBank document1;
0031         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
0032         SKGError err;
0033         {
0034             // Scope of the transaction
0035             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MT940"), err)
0036             SKGImportExportManager impmissing(&document1, QUrl::fromLocalFile(QStringLiteral("missingfile.mt940")));
0037             SKGTESTERROR(QStringLiteral("imp1.importFile"), impmissing.importFile(), false)
0038 
0039             SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmt940/test1.sta"));
0040             SKGTESTERROR(QStringLiteral("MT940.importFile"), imp1.importFile(), true)
0041         }
0042 
0043         {
0044             SKGAccountObject account(&document1);
0045             SKGTESTERROR(QStringLiteral("MT940.setName"), account.setName(QStringLiteral("NUMERO DE COMPTE IBAN 2")), true)
0046             SKGTESTERROR(QStringLiteral("MT940.load"), account.load(), true)
0047             SKGTEST(QStringLiteral("MT940:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("11.4"))
0048         }
0049     }
0050 
0051     {
0052         // Test import MT940
0053         SKGDocumentBank document1;
0054         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
0055         SKGError err;
0056         {
0057             // Scope of the transaction
0058             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MT940"), err)
0059 
0060             SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmt940/583501.mt940"));
0061             SKGTESTERROR(QStringLiteral("MT940.importFile"), imp1.importFile(), true)
0062         }
0063 
0064         {
0065             SKGAccountObject account(&document1);
0066             SKGTESTERROR(QStringLiteral("MT940.setName"), account.setName(QStringLiteral("12345.12")), true)
0067             SKGTESTERROR(QStringLiteral("MT940.load"), account.load(), true)
0068             SKGTEST(QStringLiteral("MT940:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("12145.12"))
0069         }
0070     }
0071 
0072     {
0073         // Test import MT940
0074         SKGDocumentBank document1;
0075         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
0076         SKGError err;
0077         {
0078             // Scope of the transaction
0079             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MT940"), err)
0080 
0081             SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmt940/341076.mt940"));
0082             SKGTESTERROR(QStringLiteral("MT940.importFile"), imp1.importFile(), true)
0083         }
0084 
0085         {
0086             SKGAccountObject account(&document1);
0087             SKGTESTERROR(QStringLiteral("MT940.setName"), account.setName(QStringLiteral("2602272001")), true)
0088             SKGTESTERROR(QStringLiteral("MT940.load"), account.load(), true)
0089             SKGTEST(QStringLiteral("MT940:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-12.56"))
0090         }
0091     }
0092 
0093     {
0094         // Test import MT940
0095         SKGDocumentBank document1;
0096         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
0097         SKGError err;
0098         {
0099             // Scope of the transaction
0100             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MT940"), err)
0101 
0102             SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmt940/267442_1.mt940"));
0103             SKGTESTERROR(QStringLiteral("MT940.importFile"), imp1.importFile(), true)
0104         }
0105 
0106         {
0107             SKGAccountObject account(&document1);
0108             SKGTESTERROR(QStringLiteral("MT940.setName"), account.setName(QStringLiteral("55555.55")), true)
0109             SKGTESTERROR(QStringLiteral("MT940.load"), account.load(), true)
0110             SKGTEST(QStringLiteral("MT940:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1972.1"))
0111         }
0112     }
0113 
0114     {
0115         // Test import MT940
0116         SKGDocumentBank document1;
0117         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
0118         SKGError err;
0119         {
0120             // Scope of the transaction
0121             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MT940"), err)
0122 
0123             SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmt940/267442_2.mt940"));
0124             SKGTESTERROR(QStringLiteral("MT940.importFile"), imp1.importFile(), true)
0125         }
0126 
0127         {
0128             SKGAccountObject account(&document1);
0129             SKGTESTERROR(QStringLiteral("MT940.setName"), account.setName(QStringLiteral("54842.79")), true)
0130             SKGTESTERROR(QStringLiteral("MT940.load"), account.load(), true)
0131             SKGTEST(QStringLiteral("MT940:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1030.5"))
0132         }
0133     }
0134 
0135     {
0136         // 280897
0137         SKGDocumentBank document1;
0138         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
0139         SKGError err;
0140         {
0141             // Scope of the transaction
0142             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MT940"), err)
0143 
0144             SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmt940/test1.sta"));
0145             SKGTESTERROR(QStringLiteral("MT940.importFile"), imp1.importFile(), true)
0146         }
0147         {
0148             // Scope of the transaction
0149             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MT940"), err)
0150 
0151             SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmt940/test1.sta"));
0152             SKGTESTERROR(QStringLiteral("MT940.importFile"), imp1.importFile(), true)
0153         }
0154 
0155         {
0156             bool oExist = false;
0157             SKGTESTERROR(QStringLiteral("document1.existObjects"), document1.existObjects(QStringLiteral("operation"), QStringLiteral("rc_unit_id=0"), oExist), true)
0158             SKGTESTBOOL("document1.existObjects", oExist, false)
0159         }
0160     }
0161     // End test
0162     SKGENDTEST()
0163 }