Skip to content

Commit 244eb13

Browse files
PDF Parser for Boursobank - Fix Foreign ccy parsing (#4767)
* PDF Parser for Boursobank - Fix Foreign ccy parsing This change fixes the PDF parser regular expressions so that Boursobank transactions executed in a foreign currency load properly. * Add some improvments and tests --------- Co-authored-by: Alexander Ott <webmaster@nirus-online.de>
1 parent 9d7d129 commit 244eb13

4 files changed

Lines changed: 235 additions & 19 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
PDFBox Version: 3.0.3 != 1.8.17
2+
Portfolio Performance Version: 0.76.3
3+
System: win32 | x86_64 | 21.0.5+11-LTS | Azul Systems, Inc.
4+
-----------------------------------------
5+
OPERATION DE BOURSE
6+
le 11/06/2024
7+
000000
8+
P12345
9+
MR XXX XXX
10+
XXX XXX XXX XXX
11+
12345 XXX SSS LLL
12+
Références de votre compte titres
13+
12345 12345 00012345678 Résident Français
14+
ACHAT COMPTANT ETR
15+
ACTION
16+
Date et heure
17+
locale d'exécution Quantité Informations sur la valeur Informations sur l'exécution
18+
10/06/2024 18 NVIDIA Référence : 09R240610U2204
19+
Type d'ordre : non spécifié
20+
18:05:46
21+
Code ISIN : US67066G1040 Cours exécuté : 121,97 USD
22+
Lieu d'exécution : NASDAQ
23+
Montant transaction
24+
Montant transaction brut Intérêts total brut Courtages Montant transaction net
25+
2 195,46 USD 0,00 USD 2 195,46 USD 0,00 USD 2 195,46 USD
26+
000 jours
27+
ACHAT DEVISES A TERME Cours de change Montant transaction net contrevalorisé
28+
Contrevalorisation en EURO 1,07340300 2 045,33 EUR
29+
Commission Frais divers Montant total des frais
30+
6,95 EUR 0,00 EUR 6,95 EUR
31+
Montant net au débit de votre compte
32+
2 052,28 EUR
33+
Sous réserve de bonne fin.
34+
Cet avis ne tient pas compte des frais inhérents aux Taxes sur les Transactions Financières européennes (hors France), s'ils doivent s'appliquer.
35+
36+
Service Clientèle : 01 46 09 49 49 ou +33 146 09 49 49 depuis l'étranger, du lundi au vendredi de 8h à 20h et le samedi de 8h45 à 16h30 – www.boursobank.com
37+
Boursorama S.A. au capital de 51 171 597,60 € - RCS Nanterre 351 058 151 - TVA 69 351 058 151 - 44 rue Traversière - CS 80134 - 92772 Boulogne Billancourt Cedex
38+
AA1
39+
Adresse du médiateur : Médiateur de l'AMF - 17, place de la Bourse - 75082 PARIS CEDEX 02
40+
000000 F1 P63374 1/1

name.abuchen.portfolio.tests/src/name/abuchen/portfolio/datatransfer/pdf/boursobank/BoursoBankPDFExtractorTest.java

Lines changed: 139 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import name.abuchen.portfolio.model.Portfolio;
4242
import name.abuchen.portfolio.model.PortfolioTransaction;
4343
import name.abuchen.portfolio.model.Security;
44-
import name.abuchen.portfolio.money.CurrencyUnit;
4544

4645
@SuppressWarnings("nls")
4746
public class BoursoBankPDFExtractorTest
@@ -236,7 +235,7 @@ public void testCompteAChat06()
236235
@Test
237236
public void testCompteAChat06WithSecurityInEUR()
238237
{
239-
var security = new Security("LOWE S", CurrencyUnit.EUR);
238+
var security = new Security("LOWE S", "EUR");
240239
security.setIsin("US5486611073");
241240

242241
var client = new Client();
@@ -253,7 +252,7 @@ public void testCompteAChat06WithSecurityInEUR()
253252
assertThat(countBuySell(results), is(1L));
254253
assertThat(countAccountTransactions(results), is(0L));
255254
assertThat(results.size(), is(1));
256-
new AssertImportActions().check(results, CurrencyUnit.EUR);
255+
new AssertImportActions().check(results, "EUR");
257256

258257
// check buy sell transaction
259258
assertThat(results, hasItem(purchase( //
@@ -269,6 +268,74 @@ public void testCompteAChat06WithSecurityInEUR()
269268
}))));
270269
}
271270

271+
@Test
272+
public void testCompteAChat07()
273+
{
274+
var extractor = new BoursoBankPDFExtractor(new Client());
275+
276+
List<Exception> errors = new ArrayList<>();
277+
278+
var results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "AChat07.txt"), errors);
279+
280+
assertThat(errors, empty());
281+
assertThat(countSecurities(results), is(1L));
282+
assertThat(countBuySell(results), is(1L));
283+
assertThat(countAccountTransactions(results), is(0L));
284+
assertThat(results.size(), is(2));
285+
new AssertImportActions().check(results, "EUR");
286+
287+
// check security
288+
assertThat(results, hasItem(security( //
289+
hasIsin("US67066G1040"), hasWkn(null), hasTicker(null), //
290+
hasName("NVIDIA"), //
291+
hasCurrencyCode("USD"))));
292+
293+
// check buy sell transaction
294+
assertThat(results, hasItem(purchase( //
295+
hasDate("2024-06-10T18:05:46"), hasShares(18.00), //
296+
hasSource("AChat07.txt"), //
297+
hasNote("non spécifié | Référence : 09R240610U2204"), //
298+
hasAmount("EUR", 2052.28), hasGrossValue("EUR", 2045.33), //
299+
hasForexGrossValue("USD", 2195.46), //
300+
hasTaxes("EUR", 0.00), hasFees("EUR", 6.95))));
301+
}
302+
303+
@Test
304+
public void testCompteAchat07WithSecurityInEUR()
305+
{
306+
var security = new Security("NVIDIA", "EUR");
307+
security.setIsin("US67066G1040");
308+
309+
var client = new Client();
310+
client.addSecurity(security);
311+
312+
var extractor = new BoursoBankPDFExtractor(client);
313+
314+
List<Exception> errors = new ArrayList<>();
315+
316+
var results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "AChat07.txt"), errors);
317+
318+
assertThat(errors, empty());
319+
assertThat(countSecurities(results), is(0L));
320+
assertThat(countBuySell(results), is(1L));
321+
assertThat(countAccountTransactions(results), is(0L));
322+
assertThat(results.size(), is(1));
323+
new AssertImportActions().check(results, "EUR");
324+
325+
// check buy sell transaction
326+
assertThat(results, hasItem(purchase( //
327+
hasDate("2024-06-10T18:05:46"), hasShares(18.00), //
328+
hasSource("AChat07.txt"), //
329+
hasNote("non spécifié | Référence : 09R240610U2204"), //
330+
hasAmount("EUR", 2052.28), hasGrossValue("EUR", 2045.33), //
331+
hasTaxes("EUR", 0.00), hasFees("EUR", 6.95), //
332+
check(tx -> {
333+
var c = new CheckCurrenciesAction();
334+
var s = c.process((PortfolioTransaction) tx, new Portfolio());
335+
assertThat(s, is(Status.OK_STATUS));
336+
}))));
337+
}
338+
272339
@Test
273340
public void testCompteVente01()
274341
{
@@ -362,6 +429,74 @@ public void testCompteVente03()
362429
hasTaxes("EUR", 0.00), hasFees("EUR", 0.00))));
363430
}
364431

432+
@Test
433+
public void testCompteVente04()
434+
{
435+
var extractor = new BoursoBankPDFExtractor(new Client());
436+
437+
List<Exception> errors = new ArrayList<>();
438+
439+
var results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "Vente04.txt"), errors);
440+
441+
assertThat(errors, empty());
442+
assertThat(countSecurities(results), is(1L));
443+
assertThat(countBuySell(results), is(1L));
444+
assertThat(countAccountTransactions(results), is(0L));
445+
assertThat(results.size(), is(2));
446+
new AssertImportActions().check(results, "EUR");
447+
448+
// check security
449+
assertThat(results, hasItem(security( //
450+
hasIsin("US46625H1005"), hasWkn(null), hasTicker(null), //
451+
hasName("JPMORGAN CHASE"), //
452+
hasCurrencyCode("USD"))));
453+
454+
// check buy sell transaction
455+
assertThat(results, hasItem(sale( //
456+
hasDate("2024-11-07T16:22:40"), hasShares(10.00), //
457+
hasSource("Vente04.txt"), //
458+
hasNote("à cours limite | Référence : 09R241107U2540"), //
459+
hasAmount("EUR", 2215.40), hasGrossValue("EUR", 2222.35), //
460+
hasForexGrossValue("USD", 2400.00), //
461+
hasTaxes("EUR", 0.00), hasFees("EUR", 6.95))));
462+
}
463+
464+
@Test
465+
public void testCompteVenteWithSecurityInEUR()
466+
{
467+
var security = new Security("JPMORGAN CHASE", "EUR");
468+
security.setIsin("US46625H1005");
469+
470+
var client = new Client();
471+
client.addSecurity(security);
472+
473+
var extractor = new BoursoBankPDFExtractor(client);
474+
475+
List<Exception> errors = new ArrayList<>();
476+
477+
var results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "Vente04.txt"), errors);
478+
479+
assertThat(errors, empty());
480+
assertThat(countSecurities(results), is(0L));
481+
assertThat(countBuySell(results), is(1L));
482+
assertThat(countAccountTransactions(results), is(0L));
483+
assertThat(results.size(), is(1));
484+
new AssertImportActions().check(results, "EUR");
485+
486+
// check buy sell transaction
487+
assertThat(results, hasItem(sale( //
488+
hasDate("2024-11-07T16:22:40"), hasShares(10.00), //
489+
hasSource("Vente04.txt"), //
490+
hasNote("à cours limite | Référence : 09R241107U2540"), //
491+
hasAmount("EUR", 2215.40), hasGrossValue("EUR", 2222.35), //
492+
hasTaxes("EUR", 0.00), hasFees("EUR", 6.95), //
493+
check(tx -> {
494+
var c = new CheckCurrenciesAction();
495+
var s = c.process((PortfolioTransaction) tx, new Portfolio());
496+
assertThat(s, is(Status.OK_STATUS));
497+
}))));
498+
}
499+
365500
@Test
366501
public void testDividende01()
367502
{
@@ -392,4 +527,4 @@ public void testDividende01()
392527
hasAmount("EUR", 28.24), hasGrossValue("EUR", 40.33), //
393528
hasTaxes("EUR", 12.09), hasFees("EUR", 0.00))));
394529
}
395-
}
530+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
PDFBox Version: 3.0.3 != 1.8.17
2+
Portfolio Performance Version: 0.76.3
3+
System: win32 | x86_64 | 21.0.5+11-LTS | Azul Systems, Inc.
4+
-----------------------------------------
5+
OPERATION DE BOURSE
6+
le 08/11/2024
7+
000000
8+
P46553
9+
MR XXX YYY
10+
123 XXX SSS FFF
11+
12345 DDD FFF DDD
12+
Références de votre compte titres
13+
12345 12345 00012345678 Résident Français
14+
VENTE COMPTANT ETR
15+
ACTION
16+
Date et heure
17+
locale d'exécution Quantité Informations sur la valeur Informations sur l'exécution
18+
07/11/2024 10 JPMORGAN CHASE Référence : 09R241107U2540
19+
Type d'ordre : à cours limite
20+
16:22:40
21+
Code ISIN : US46625H1005 Cours exécuté : 240 USD
22+
Lieu d'exécution : NEW YORK STOCK EXCHANGE I
23+
Montant transaction
24+
Montant transaction brut Intérêts total brut Courtages Montant transaction net
25+
2 400,00 USD 0,00 USD 2 400,00 USD 0,00 USD 2 400,00 USD
26+
000 jours
27+
VENTE DEVISES A TERME Cours de change Montant transaction net contrevalorisé
28+
Contrevalorisation en EURO 1,07994000 2 222,35 EUR
29+
Commission Frais divers Montant total des frais
30+
6,95 EUR 0,00 EUR 6,95 EUR
31+
Montant net au crédit de votre compte
32+
2 215,40 EUR
33+
Opération prise en compte au titre de l'année fiscale 2024
34+
Sous réserve de bonne fin.
35+
Cet avis ne tient pas compte des frais inhérents aux Taxes sur les Transactions Financières européennes (hors France), s'ils doivent s'appliquer.
36+
37+
Service Clientèle : 01 46 09 49 49 ou +33 146 09 49 49 depuis l'étranger, du lundi au vendredi de 8h à 20h et le samedi de 8h45 à 16h30 – www.boursobank.com
38+
Boursorama S.A. au capital de 51 171 597,60 € - RCS Nanterre 351 058 151 - TVA 69 351 058 151 - 44 rue Traversière - CS 80134 - 92772 Boulogne Billancourt Cedex
39+
AA1
40+
Adresse du médiateur : Médiateur de l'AMF - 17, place de la Bourse - 75082 PARIS CEDEX 02
41+
000000 F1 P46553 1/1

0 commit comments

Comments
 (0)