1 /***************************************************************************
2  * SPDX-FileCopyrightText: 2021 S. MANKOWSKI stephane@mankowski.fr
3  * SPDX-FileCopyrightText: 2021 G. DE BURE support@mankowski.fr
4  * SPDX-License-Identifier: GPL-3.0-or-later
5  ***************************************************************************/
6 /** @file
7  * This file is a test script.
8  *
9  * @author Stephane MANKOWSKI / Guillaume DE BURE
10  */
11 #include "skgtestmacro.h"
12 #include "skgbankincludes.h"
13 #include "skgimportexportmanager.h"
14 
15 /**
16  * The main function of the unit test
17  * @param argc the number of arguments
18  * @param argv the list of arguments
19  */
main(int argc,char ** argv)20 int main(int argc, char** argv)
21 {
22     Q_UNUSED(argc)
23     Q_UNUSED(argv)
24 
25     // Init test
26     SKGINITTEST(true)
27     QString path = qgetenv("PATH");
28     QString in = qgetenv("IN");
29 
30     {
31         // Test import Weboob
32         SKGDocumentBank document1;
33         SKGTESTERROR(QStringLiteral("document1.load()"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportbackend/fake1/fake1.skg"), true)
34         SKGError err;
35         {
36             SKGTESTBOOL("PUTENV.fake1", qputenv("PATH", (in + "/skgtestimportbackend/fake1/:" + path).toLatin1()), true)
37 
38             // Scope of the transaction
39             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err)
40 
41             SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob")));
42             SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true)
43         }
44 
45         // Check
46         {
47             SKGAccountObject account;
48             SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("12345"), account), true)
49             SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true)
50             SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1523.99"))
51             SKGTEST(QStringLiteral("ACCOUNT:getAmount"), SKGServices::doubleToString(account.getAmount(QDate(2013, 5, 1))), QStringLiteral("1471.22"))
52 
53             SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("47896"), account), true)
54             SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true)
55             SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-30"))
56             SKGTEST(QStringLiteral("ACCOUNT:getAmount"), SKGServices::doubleToString(account.getAmount(QDate(2013, 5, 1))), QStringLiteral("0"))
57 
58             SKGObjectBase::SKGListSKGObjectBase result;
59             SKGTESTERROR(QStringLiteral("DOC.getObjects"), document1.getObjects(QStringLiteral("v_operation"), QStringLiteral("t_comment='SNCF'"), result), true)
60             SKGTEST(QStringLiteral("DOC.getObjects.count"), result.count(), 2)
61 
62             SKGTESTERROR(QStringLiteral("DOC.getObjects"), document1.getObjects(QStringLiteral("v_operation"), QStringLiteral("d_date='2013-05-26'"), result), true)
63             SKGTEST(QStringLiteral("DOC.getObjects.count"), result.count(), 1)
64         }
65     }
66 
67     {
68         // BUG: 320716
69         SKGDocumentBank document1;
70         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
71         SKGError err;
72         {
73             SKGTESTBOOL("PUTENV.320716_1", qputenv("PATH", (in + "/skgtestimportbackend/320716_1/:" + path).toLatin1()), true)
74 
75             // Scope of the transaction
76             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err)
77 
78             SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob")));
79             SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true)
80         }
81 
82         // Check
83         {
84             SKGAccountObject account;
85             SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("12345"), account), true)
86             SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true)
87             SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("100"))
88         }
89 
90         {
91             SKGTESTBOOL("PUTENV.320716_1", qputenv("PATH", (in + "/skgtestimportbackend/320716_2/:" + path).toLatin1()), true)
92 
93             // Scope of the transaction
94             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err)
95 
96             SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob")));
97             SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true)
98         }
99 
100         // Check
101         {
102             SKGAccountObject account;
103             SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("12345"), account), true)
104             SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true)
105             SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("0"))
106         }
107     }
108 
109     {
110         // Test error
111         SKGDocumentBank document1;
112         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
113         SKGError err;
114         {
115             SKGTESTBOOL("PUTENV.fake1", qputenv("PATH", (in + "/skgtestimportbackend/error1/:" + path).toLatin1()), true)
116 
117             // Scope of the transaction
118             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err)
119 
120             SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob")));
121             SKGTEST(QStringLiteral("WEBOOB.importFile"), imp1.importFile().getReturnCode(), ERR_FAIL)
122         }
123     }
124 
125     {
126         // Test error
127         SKGDocumentBank document1;
128         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
129         SKGError err;
130         {
131             SKGTESTBOOL("PUTENV.fake1", qputenv("PATH", (in + "/skgtestimportbackend/error2/:" + path).toLatin1()), true)
132 
133             // Scope of the transaction
134             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err)
135 
136             SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob")));
137             SKGTEST(QStringLiteral("WEBOOB.importFile"), imp1.importFile().getReturnCode(), ERR_FAIL)
138         }
139     }
140 
141     {
142         // Test error
143         SKGDocumentBank document1;
144         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
145         SKGError err;
146         {
147             SKGTESTBOOL("PUTENV.fake1", qputenv("PATH", (in + "/skgtestimportbackend/error3/:" + path).toLatin1()), true)
148 
149             // Scope of the transaction
150             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err)
151 
152             document1.sendMessage(QStringLiteral("Hello"));
153 
154             SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob")));
155             SKGTEST(QStringLiteral("WEBOOB.importFile"), imp1.importFile().getReturnCode(), ERR_FAIL)
156         }
157     }
158 
159     {
160         // Test error
161         SKGDocumentBank document1;
162         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
163         SKGError err;
164         {
165             SKGTESTBOOL("PUTENV.fake1", qputenv("PATH", (in + "/skgtestimportbackend/error4/:" + path).toLatin1()), true)
166 
167             // Scope of the transaction
168             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err)
169 
170             SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob")));
171             SKGTEST(QStringLiteral("WEBOOB.importFile"), imp1.importFile().getReturnCode(), ERR_FAIL)
172         }
173     }
174 
175     {
176         // Better account selection
177         SKGDocumentBank document1;
178         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
179         SKGError err;
180         {
181             // Scope of the transaction
182             SKGBEGINTRANSACTION(document1, QStringLiteral("CREATE ACCOUNT"), err)
183 
184             // Creation the bank
185             SKGBankObject bank(&document1);
186             SKGTESTERROR(QStringLiteral("BANK.setName"), bank.setName(QStringLiteral("caisse-epargne")), true)
187             SKGTESTERROR(QStringLiteral("BANK.setNumber"), bank.setNumber(QStringLiteral("13135")), true)
188             SKGTESTERROR(QStringLiteral("BANK.save"), bank.save(), true)
189 
190             // Creation the account
191             SKGAccountObject account;
192             SKGTESTERROR(QStringLiteral("BANK.addAccount"), bank.addAccount(account), true)
193             SKGTESTERROR(QStringLiteral("ACCOUNT.setName"), account.setName(QStringLiteral("test")), true)
194             SKGTESTERROR(QStringLiteral("ACCOUNT.setNumber"), account.setNumber(QStringLiteral("123456789")), true)
195             SKGTESTERROR(QStringLiteral("ACCOUNT.setAgencyNumber"), account.setAgencyNumber(QStringLiteral("00080")), true)
196             SKGTESTERROR(QStringLiteral("ACCOUNT.save"), account.save(), true)
197         }
198         {
199             // Scope of the transaction
200             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err)
201 
202             SKGTESTBOOL("PUTENV.weboob", qputenv("PATH", (in + "/skgtestimportbackend/betterselection/:" + path).toLatin1()), true)
203 
204             SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob")));
205             SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true)
206         }
207 
208         // Check
209         {
210             SKGAccountObject account;
211             SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("test"), account), true)
212             SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true)
213             SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-147994.82"))
214         }
215     }
216 
217     {
218         // Better account selection
219         SKGDocumentBank document1;
220         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
221         SKGError err;
222         {
223             // Scope of the transaction
224             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err)
225 
226             SKGTESTBOOL("PUTENV.weboob", qputenv("PATH", (in + "/skgtestimportbackend/joint_accounts/:" + path).toLatin1()), true)
227 
228             SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob")));
229             SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true)
230         }
231 
232         // Check
233         {
234             SKGAccountObject account;
235             SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("12345"), account), true)
236             SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true)
237             SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1000"))
238         }
239     }
240 
241     {
242         // BULK import
243         SKGDocumentBank document1;
244         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
245         SKGError err;
246         {
247             // Scope of the transaction
248             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_BULK"), err)
249 
250             SKGTESTBOOL("PUTENV.bulk", qputenv("PATH", (in + "/skgtestimportbackend/bulk/:" + path).toLatin1()), true)
251 
252             SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".bulk")));
253             SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true)
254         }
255 
256         // Check
257         {
258             SKGAccountObject account;
259             SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("12345"), account), true)
260             SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true)
261             SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("10"))
262         }
263 
264         // Check
265         {
266             SKGAccountObject account;
267             SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("78900"), account), true)
268             SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true)
269             SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("20"))
270         }
271     }
272 
273     {
274         // STAMM
275         SKGDocumentBank document1;
276         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
277         SKGError err;
278         {
279             // Scope of the transaction
280             SKGBEGINTRANSACTION(document1, QStringLiteral("CREATE ACCOUNT"), err)
281 
282             // Creation the bank
283             SKGBankObject bank(&document1);
284             SKGTESTERROR(QStringLiteral("BANK.setName"), bank.setName(QStringLiteral("ldlc")), true)
285             SKGTESTERROR(QStringLiteral("BANK.save"), bank.save(), true)
286 
287             // Creation the accounts
288             {
289                 SKGAccountObject account;
290                 SKGTESTERROR(QStringLiteral("BANK.addAccount"), bank.addAccount(account), true)
291                 SKGTESTERROR(QStringLiteral("ACCOUNT.setName"), account.setName(QStringLiteral("acc1")), true)
292                 SKGTESTERROR(QStringLiteral("ACCOUNT.setNumber"), account.setNumber(QStringLiteral("1234567A")), true)
293                 SKGTESTERROR(QStringLiteral("ACCOUNT.setAgencyNumber"), account.setAgencyNumber(QStringLiteral("00080")), true)
294                 SKGTESTERROR(QStringLiteral("ACCOUNT.save"), account.save(), true)
295             }
296             {
297                 SKGAccountObject account;
298                 SKGTESTERROR(QStringLiteral("BANK.addAccount"), bank.addAccount(account), true)
299                 SKGTESTERROR(QStringLiteral("ACCOUNT.setName"), account.setName(QStringLiteral("acc2")), true)
300                 SKGTESTERROR(QStringLiteral("ACCOUNT.setNumber"), account.setNumber(QStringLiteral("987654321")), true)
301                 SKGTESTERROR(QStringLiteral("ACCOUNT.setAgencyNumber"), account.setAgencyNumber(QStringLiteral("00080")), true)
302                 SKGTESTERROR(QStringLiteral("ACCOUNT.save"), account.save(), true)
303             }
304             {
305                 SKGAccountObject account;
306                 SKGTESTERROR(QStringLiteral("BANK.addAccount"), bank.addAccount(account), true)
307                 SKGTESTERROR(QStringLiteral("ACCOUNT.setName"), account.setName(QStringLiteral("acc3")), true)
308                 SKGTESTERROR(QStringLiteral("ACCOUNT.setNumber"), account.setNumber(QStringLiteral("1111111A")), true)
309                 SKGTESTERROR(QStringLiteral("ACCOUNT.setAgencyNumber"), account.setAgencyNumber(QStringLiteral("00080")), true)
310                 SKGTESTERROR(QStringLiteral("ACCOUNT.save"), account.save(), true)
311             }
312         }
313         {
314             // Scope of the transaction
315             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err)
316 
317             SKGTESTBOOL("PUTENV.weboob", qputenv("PATH", (in + "/skgtestimportbackend/stamm/:" + path).toLatin1()), true)
318 
319             SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob")));
320             SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true)
321         }
322 
323         // Checks
324         {
325             SKGAccountObject account;
326             SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("acc1"), account), true)
327             SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true)
328             SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-50"))
329         }
330         {
331             SKGAccountObject account;
332             SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("acc2"), account), true)
333             SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true)
334             SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-50"))
335         }
336         {
337             SKGAccountObject account;
338             SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("acc3"), account), true)
339             SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true)
340             SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-50"))
341         }
342 
343         {
344             SKGAccountObject account;
345             SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("1234567W089"), account), true)
346             SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true)
347             SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-50"))
348         }
349 
350         {
351             SKGAccountObject account;
352             SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("MYACCOUNTNAME"), account), true)
353             SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true)
354             SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-50"))
355         }
356     }
357 
358 
359     {
360         // Avoid merge of account due to same name
361         SKGDocumentBank document1;
362         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
363         SKGError err;
364         {
365             // Scope of the transaction
366             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err)
367 
368             SKGTESTBOOL("PUTENV.weboob", qputenv("PATH", (in + "/skgtestimportbackend/merge/:" + path).toLatin1()), true)
369 
370             SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob")));
371             SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true)
372         }
373 
374         // Checks
375         {
376             SKGAccountObject account;
377             SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("CPT"), account), true)
378             SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true)
379             SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-50"))
380         }
381         {
382             SKGAccountObject account;
383             SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("CPT2"), account), true)
384             SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true)
385             SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-50"))
386         }
387     }
388 
389     {
390         // Avoid merge of account due to same name
391         SKGDocumentBank document1;
392         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
393         SKGError err;
394         {
395             // Scope of the transaction
396             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err)
397 
398             SKGTESTBOOL("PUTENV.weboob", qputenv("PATH", (in + "/skgtestimportbackend/kevin/:" + path).toLatin1()), true)
399 
400             SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob")));
401             SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true)
402         }
403 
404         // Checks
405         QStringList accounts;
406         accounts << QStringLiteral("COMPTE 1") << QStringLiteral("COMPTE 2") << QStringLiteral("LIVRET 1") << QStringLiteral("LIVRET 2") << QStringLiteral("EPARGNE 1") << QStringLiteral("EPARGNE 2") << QStringLiteral("EPARGNE 3");
407         for (const auto& acc : qAsConst(accounts)) {
408             SKGAccountObject account;
409             SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), acc, account), true)
410             SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true)
411             SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-10"))
412         }
413     }
414 
415     {
416         // Avoid merge of account due to same name
417         SKGDocumentBank document1;
418         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
419         SKGError err;
420         {
421             // Scope of the transaction
422             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err)
423 
424             SKGTESTBOOL("PUTENV.weboob", qputenv("PATH", (in + "/skgtestimportbackend/double/:" + path).toLatin1()), true)
425 
426             SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob")));
427             SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true)
428         }
429 
430         // Checks
431         {
432             SKGAccountObject account;
433             SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("CPT"), account), true)
434             SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true)
435             SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-100"))
436         }
437     }
438 
439     {
440         // Avoid merge of account due to same name
441         SKGDocumentBank document1;
442         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
443         SKGError err;
444         {
445             // Scope of the transaction
446             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err)
447 
448             SKGTESTBOOL("PUTENV.weboob", qputenv("PATH", (in + "/skgtestimportbackend/397055/:" + path).toLatin1()), true)
449 
450             SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob")));
451             SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true)
452         }
453 
454         // Checks
455         {
456             SKGAccountObject account;
457             SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("LEO"), account), true)
458             SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true)
459             SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-20"))
460         }
461     }
462 
463     {
464         // rdate Not available
465         SKGDocumentBank document1;
466         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
467         SKGError err;
468         {
469             // Scope of the transaction
470             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err)
471 
472             SKGTESTBOOL("PUTENV.weboob", qputenv("PATH", (in + "/skgtestimportbackend/397611/:" + path).toLatin1()), true)
473 
474             SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob")));
475             SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true)
476         }
477 
478         // Checks
479         {
480             SKGAccountObject account;
481             SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("LEO"), account), true)
482             SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true)
483             SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("598.8"))
484 
485             SKGObjectBase::SKGListSKGObjectBase result;
486             SKGTESTERROR(QStringLiteral("DOC.getObjects"), document1.getObjects(QStringLiteral("v_operation"), QStringLiteral("d_date!='0000-00-00'"), result), true)
487             SKGTEST(QStringLiteral("DOC.getObjects.count"), result.count(), 3)
488         }
489     }
490 
491     {
492         // Double transferts
493         SKGDocumentBank document1;
494         SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true)
495         SKGError err;
496         {
497             // Scope of the transaction
498             SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err)
499 
500             SKGTESTBOOL("PUTENV.weboob", qputenv("PATH", (in + "/skgtestimportbackend/double_transferts/:" + path).toLatin1()), true)
501 
502             SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob")));
503             SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true)
504         }
505 
506         // Checks
507         {
508             SKGObjectBase::SKGListSKGObjectBase result;
509             SKGTESTERROR(QStringLiteral("DOC.getObjects"), document1.getObjects(QStringLiteral("v_operation"), QStringLiteral("d_date!='0000-00-00'"), result), true)
510             SKGTEST(QStringLiteral("DOC.getObjects.count"), result.count(), 4)
511         }
512     }
513     // End test
514     SKGENDTEST()
515 }
516