File indexing completed on 2024-05-12 16:45:21

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     int nboperation = 0;
0028     {
0029         // Test export 320066
0030         SKGDocumentBank document1;
0031         SKGTESTERROR(QStringLiteral("document1.load()"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy4/320066.skg"), true)
0032         SKGTESTERROR(QStringLiteral("document1.getNbObjects()"), document1.getNbObjects(QStringLiteral("v_operation_display"), QLatin1String(""), nboperation), true)
0033         SKGError err;
0034         {
0035             // Scope of the transaction
0036             SKGBEGINTRANSACTION(document1, QStringLiteral("EXPORT_KMY"), err)
0037 
0038             SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportkmy4/320066.kmy"));
0039             SKGTESTERROR(QStringLiteral("KMY.exportFile"), imp1.exportFile(), true)
0040         }
0041     }
0042 
0043     {
0044         // Test import 320066
0045         SKGDocumentBank document1;
0046         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
0047         SKGError err;
0048         {
0049             // Scope of the transaction
0050             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err)
0051             SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportkmy4/320066.kmy"));
0052             SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true)
0053 
0054             int nboperation2 = 0;
0055             SKGTESTERROR(QStringLiteral("document1.getNbObjects()"), document1.getNbObjects(QStringLiteral("v_operation_display"), QLatin1String(""), nboperation2), true)
0056 
0057             SKGTEST(QStringLiteral("document1:nb transactions"), nboperation2, nboperation)
0058         }
0059     }
0060 
0061     {
0062         // Test import randy1
0063         SKGDocumentBank document1;
0064         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
0065         SKGError err;
0066         {
0067             // Scope of the transaction
0068             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err)
0069             SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy4/randy1.kmy"));
0070             SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true)
0071         }
0072 
0073         // Actif
0074         SKGTESTACCOUNT(document1, QStringLiteral("A000290"),  23182500.00);
0075         // Action
0076         /*SKGTESTACCOUNT(document1, QStringLiteral("A000014"),  2432032.27);
0077         SKGTESTACCOUNT(document1, QStringLiteral("A000016"),  236769.78);
0078         SKGTESTACCOUNT(document1, QStringLiteral("A000018"),  0.00);
0079         SKGTESTACCOUNT(document1, QStringLiteral("A000020"),  0.00);
0080         SKGTESTACCOUNT(document1, QStringLiteral("A000022"),  326254.23);
0081         SKGTESTACCOUNT(document1, QStringLiteral("A000023"),  459915.34);
0082         SKGTESTACCOUNT(document1, QStringLiteral("A000025"),  618975.84);
0083         SKGTESTACCOUNT(document1, QStringLiteral("A000027"),  301501.09);
0084         SKGTESTACCOUNT(document1, QStringLiteral("A000032"),  12358550.29);
0085         SKGTESTACCOUNT(document1, QStringLiteral("A000294"),  1193772.30);
0086         SKGTESTACCOUNT(document1, QStringLiteral("A000300"),  12304427.59);
0087         SKGTESTACCOUNT(document1, QStringLiteral("A000312"),  2822127.36);
0088         SKGTESTACCOUNT(document1, QStringLiteral("A000366"),  14150464.39);
0089         SKGTESTACCOUNT(document1, QStringLiteral("A000371"),  2160798.86);*/
0090         // Carte de credit
0091         SKGTESTACCOUNT(document1, QStringLiteral("A000120"),  -316721.001);
0092         SKGTESTACCOUNT(document1, QStringLiteral("A000407"),  -1438.158);
0093         SKGTESTACCOUNT(document1, QStringLiteral("A000409"),  0.00);
0094         // Cheques
0095         SKGTESTACCOUNT(document1, QStringLiteral("A000030"),  -6371673.033);
0096         SKGTESTACCOUNT(document1, QStringLiteral("A000040"),  429856.659);
0097         SKGTESTACCOUNT(document1, QStringLiteral("A000273"),  2479805.892);
0098         SKGTESTACCOUNT(document1, QStringLiteral("A000378"),  845357.871);
0099         // Especes
0100         SKGTESTACCOUNT(document1, QStringLiteral("A000314"),  0.00);
0101         SKGTESTACCOUNT(document1, QStringLiteral("A000354"),  863.232);
0102         // Epargne
0103         SKGTESTACCOUNT(document1, QStringLiteral("A000041"),  402257.682);
0104         SKGTESTACCOUNT(document1, QStringLiteral("A000301"),  951074.286);
0105         SKGTESTACCOUNT(document1, QStringLiteral("A000330"),  0.00);
0106         SKGTESTACCOUNT(document1, QStringLiteral("A000353"),  1753.44);
0107         SKGTESTACCOUNT(document1, QStringLiteral("A000379"),  4955771.076);
0108         SKGTESTACCOUNT(document1, QStringLiteral("A000387"),  849701.007);
0109         SKGTESTACCOUNT(document1, QStringLiteral("A000388"),  4681634.22);
0110         SKGTESTACCOUNT(document1, QStringLiteral("A000400"),  255912.039);
0111     }
0112 
0113     {
0114         // Test import cat
0115         SKGDocumentBank document1;
0116         SKGTESTERROR(QStringLiteral("document1.load()"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy4/bug_import_cat.skg"), true)
0117         SKGError err;
0118         {
0119             // Scope of the transaction
0120             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err)
0121             SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy4/bug_import_cat.kmy"));
0122             SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true)
0123 
0124             int nb = 0;
0125             SKGTESTERROR(QStringLiteral("document1.getNbObjects()"), document1.getNbObjects(QStringLiteral("category"), QStringLiteral("t_name='Cantine'"), nb), true)
0126 
0127             SKGTEST(QStringLiteral("document1:nb category"), nb, 1)
0128         }
0129     }
0130 
0131     // End test
0132     SKGENDTEST()
0133 }