Skip to content

Commit 833da8c

Browse files
committed
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.
1 parent 24ecfad commit 833da8c

4 files changed

Lines changed: 156 additions & 1 deletion

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
```
2+
PDFBox Version: 3.0.3 != 1.8.17
3+
Portfolio Performance Version: 0.76.3
4+
System: win32 | x86_64 | 21.0.5+11-LTS | Azul Systems, Inc.
5+
-----------------------------------------
6+
OPERATION DE BOURSE
7+
le 11/06/2024
8+
000000
9+
P12345
10+
MR XXX XXX
11+
XXX XXX XXX XXX
12+
12345 XXX SSS LLL
13+
Références de votre compte titres
14+
12345 12345 00012345678 Résident Français
15+
ACHAT COMPTANT ETR
16+
ACTION
17+
Date et heure
18+
locale d'exécution Quantité Informations sur la valeur Informations sur l'exécution
19+
10/06/2024 18 NVIDIA Référence : 09R240610U2204
20+
Type d'ordre : non spécifié
21+
18:05:46
22+
Code ISIN : US67066G1040 Cours exécuté : 121,97 USD
23+
Lieu d'exécution : NASDAQ
24+
Montant transaction
25+
Montant transaction brut Intérêts total brut Courtages Montant transaction net
26+
2 195,46 USD 0,00 USD 2 195,46 USD 0,00 USD 2 195,46 USD
27+
000 jours
28+
ACHAT DEVISES A TERME Cours de change Montant transaction net contrevalorisé
29+
Contrevalorisation en EURO 1,07340300 2 045,33 EUR
30+
Commission Frais divers Montant total des frais
31+
6,95 EUR 0,00 EUR 6,95 EUR
32+
Montant net au débit de votre compte
33+
2 052,28 EUR
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 P63374 1/1
42+
43+
```

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

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,43 @@ public void testCompteAChat06WithSecurityInEUR()
268268
assertThat(s, is(Status.OK_STATUS));
269269
}))));
270270
}
271+
272+
273+
@Test
274+
public void testCompteAchat07()
275+
{
276+
var security = new Security("NVIDIA", CurrencyUnit.EUR);
277+
security.setIsin("US67066G1040");
278+
279+
var client = new Client();
280+
client.addSecurity(security);
281+
282+
var extractor = new BoursoBankPDFExtractor(client);
283+
284+
List<Exception> errors = new ArrayList<>();
285+
286+
var results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "AChat07.txt"), errors);
287+
288+
assertThat(errors, empty());
289+
assertThat(countSecurities(results), is(0L));
290+
assertThat(countBuySell(results), is(1L));
291+
assertThat(countAccountTransactions(results), is(0L));
292+
assertThat(results.size(), is(1));
293+
new AssertImportActions().check(results, CurrencyUnit.EUR);
294+
295+
// check buy sell transaction
296+
assertThat(results, hasItem(purchase( //
297+
hasDate("2024-06-10T18:05:46"), hasShares(18.00), //
298+
hasSource("AChat07.txt"), //
299+
hasNote("non spécifié | Référence : 09R240610U2204"), //
300+
hasAmount("EUR", 2052.28), hasGrossValue("EUR", 2045.33), //
301+
hasTaxes("EUR", 0.00), hasFees("EUR", 6.95), //
302+
check(tx -> {
303+
var c = new CheckCurrenciesAction();
304+
var s = c.process((PortfolioTransaction) tx, new Portfolio());
305+
assertThat(s, is(Status.OK_STATUS));
306+
}))));
307+
}
271308

272309
@Test
273310
public void testCompteVente01()
@@ -362,6 +399,37 @@ public void testCompteVente03()
362399
hasTaxes("EUR", 0.00), hasFees("EUR", 0.00))));
363400
}
364401

402+
@Test
403+
public void testCompteVente04()
404+
{
405+
var extractor = new BoursoBankPDFExtractor(new Client());
406+
407+
List<Exception> errors = new ArrayList<>();
408+
409+
var results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "Vente04.txt"), errors);
410+
411+
assertThat(errors, empty());
412+
assertThat(countSecurities(results), is(1L));
413+
assertThat(countBuySell(results), is(1L));
414+
assertThat(countAccountTransactions(results), is(0L));
415+
assertThat(results.size(), is(2));
416+
new AssertImportActions().check(results, "EUR");
417+
418+
// check security
419+
assertThat(results, hasItem(security( //
420+
hasIsin("US46625H1005"), hasWkn(null), hasTicker(null), //
421+
hasName("JPMORGAN CHASE"), //
422+
hasCurrencyCode("USD"))));
423+
424+
// check buy sell transaction
425+
assertThat(results, hasItem(sale( //
426+
hasDate("2024-11-07T16:22:40"), hasShares(10.00), //
427+
hasSource("Vente04.txt"), //
428+
hasNote("à cours limite | Référence : 09R241107U2540"), //
429+
hasAmount("EUR", 2215.40), hasGrossValue("EUR", 2222.35), //
430+
hasTaxes("EUR", 0.00), hasFees("EUR", 6.95))));
431+
}
432+
365433
@Test
366434
public void testDividende01()
367435
{
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
```
2+
PDFBox Version: 3.0.3 != 1.8.17
3+
Portfolio Performance Version: 0.76.3
4+
System: win32 | x86_64 | 21.0.5+11-LTS | Azul Systems, Inc.
5+
-----------------------------------------
6+
OPERATION DE BOURSE
7+
le 08/11/2024
8+
000000
9+
P46553
10+
MR XXX YYY
11+
123 XXX SSS FFF
12+
12345 DDD FFF DDD
13+
Références de votre compte titres
14+
12345 12345 00012345678 Résident Français
15+
VENTE COMPTANT ETR
16+
ACTION
17+
Date et heure
18+
locale d'exécution Quantité Informations sur la valeur Informations sur l'exécution
19+
07/11/2024 10 JPMORGAN CHASE Référence : 09R241107U2540
20+
Type d'ordre : à cours limite
21+
16:22:40
22+
Code ISIN : US46625H1005 Cours exécuté : 240 USD
23+
Lieu d'exécution : NEW YORK STOCK EXCHANGE I
24+
Montant transaction
25+
Montant transaction brut Intérêts total brut Courtages Montant transaction net
26+
2 400,00 USD 0,00 USD 2 400,00 USD 0,00 USD 2 400,00 USD
27+
000 jours
28+
VENTE DEVISES A TERME Cours de change Montant transaction net contrevalorisé
29+
Contrevalorisation en EURO 1,07994000 2 222,35 EUR
30+
Commission Frais divers Montant total des frais
31+
6,95 EUR 0,00 EUR 6,95 EUR
32+
Montant net au crédit de votre compte
33+
2 215,40 EUR
34+
Opération prise en compte au titre de l'année fiscale 2024
35+
Sous réserve de bonne fin.
36+
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.
37+
38+
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
39+
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
40+
AA1
41+
Adresse du médiateur : Médiateur de l'AMF - 17, place de la Bourse - 75082 PARIS CEDEX 02
42+
000000 F1 P46553 1/1
43+
44+
```

name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/BoursoBankPDFExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ private void addBuySellTransaction()
180180
.attributes("fxGross", "termCurrency", "exchangeRate", "baseCurrency") //
181181
.find("Montant transaction brut.*") //
182182
.match("^(?<fxGross>[\\d\\s]+,[\\d]{2}) (?<termCurrency>[\\w]{3}) .*$") //
183-
.match("^Contrevalorisation en .* (?<exchangeRate>[\\.,\\d]+) [\\d\\s]+,[\\d]{2} (?<baseCurrency>[\\w]{3})$") //
183+
.match("^Contrevalorisation en [\\w]+ (?<exchangeRate>[\\.,\\d]+) [\\d\\s]+,[\\d]{2} (?<baseCurrency>[\\w]{3})$") //
184184
.assign((t, v) -> {
185185
var rate = asExchangeRate(v);
186186
type.getCurrentContext().putType(rate);

0 commit comments

Comments
 (0)