Skip to content

Commit

Permalink
Modify Trade Republic PDF-Importer to support new transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Nirus2000 committed Mar 27, 2024
1 parent 447ca01 commit f2f5e9f
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
@@ -0,0 +1,32 @@
PDFBox Version: 1.8.17
Portfolio Performance Version: 0.68.3
-----------------------------------------
TRADE REPUBLIC BANK GMBH BRUNNENSTRASSE 19-21 10119 BERLIN
CRwazW CVGYx oATxGhG SEITE 1 von 1
AtehMW-fYEnfbmPd-ApeaZD 33 DATUM 26.03.2024
23949 VEjt ORDER 20f0-0026
AUSFÜHRUNG 761d-19e4
DEPOT 0706195861
WERTPAPIERABRECHNUNG
ÜBERSICHT
Market-Order Kauf am 26.03.2024, um 15:53 Uhr (Europe/Berlin).
Der Kontrahent der Transaktion ist Lang & Schwarz TradeCenter AG & Co. KG.
POSITION NOMINALE PREIS BETRAG
Bundesrep.Deutschland 1.019 EUR 98,05 % 999,13 EUR
Bundesobl.Ser.180 v.2019(24)
ISIN: DE0001141802
GESAMT 999,13 EUR
ABRECHNUNG
POSITION BETRAG
Fremdkostenzuschlag -1,00 EUR
GESAMT -1.000,13 EUR
BUCHUNG
VERRECHNUNGSKONTO WERTSTELLUNG BETRAG
DE58120700700122500000 28.03.2024 -1.000,13 EUR
Bundesrep.Deutschland Bundesobl.Ser.180 v.2019(24) in Girosammelverwahrung in Deutschland.
Diese Abrechnung wird maschinell erstellt und daher nicht unterschrieben.
Sofern keine Umsatzsteuer ausgewiesen ist, handelt es sich gem. § 4 Nr. 8 UStG um eine umsatzsteuerfreie Leistung.
Trade Republic Bank GmbH www.traderepublic.com Sitz der Gesellschaft: Berlin Geschäftsführer
Brunnenstraße 19-21 service@traderepublic.com AG Charlottenburg HRB 244347 B Andreas Torner
10119 Berlin USt-ID DE307510626 Gernot Mittendorfer
ABRE / 26.03.2024 / 63960219 / 46a8-f932
Expand Up @@ -600,6 +600,37 @@ public void testWertpapierKauf13()
hasTaxes("EUR", 0.00), hasFees("EUR", 0.00))));
}

@Test
public void testWertpapierKauf14()
{
TradeRepublicPDFExtractor extractor = new TradeRepublicPDFExtractor(new Client());

List<Exception> errors = new ArrayList<>();

List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "Kauf14.txt"), errors);

assertThat(errors, empty());
assertThat(countSecurities(results), is(1L));
assertThat(countBuySell(results), is(1L));
assertThat(countAccountTransactions(results), is(0L));
assertThat(results.size(), is(2));
new AssertImportActions().check(results, CurrencyUnit.EUR);

// check security
assertThat(results, hasItem(security( //
hasIsin("DE0001141802"), hasWkn(null), hasTicker(null), //
hasName("Bundesrep.Deutschland Bundesobl.Ser.180 v.2019(24)"), //
hasCurrencyCode("EUR"))));

// check buy sell transaction
assertThat(results, hasItem(purchase( //
hasDate("2024-03-26T15:53"), hasShares(10.19), //
hasSource("Kauf14.txt"), //
hasNote("Order: 20f0-0026 | Ausführung: 761d-19e4"), //
hasAmount("EUR", 1000.13), hasGrossValue("EUR", 999.13), //
hasTaxes("EUR", 0.00), hasFees("EUR", 1.00))));
}

@Test
public void testBuy01()
{
Expand Down
Expand Up @@ -129,6 +129,17 @@ private void addBuySellTransaction()
.match("^[\\d] (Barausgleich|Kurswert) [\\.,\\d]+ (?<currency>[\\w]{3})$") //
.assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))),
// @formatter:off
// Bundesrep.Deutschland 1.019 EUR 98,05 % 999,13 EUR
// Bundesobl.Ser.180 v.2019(24)
// ISIN: DE0001141802
// @formatter:on
section -> section //
.attributes("name", "currency", "nameContinued", "isin") //
.match("^(?<name>.*) [\\.,\\d]+ (?<currency>[\\w]{3}) [\\.,\\d]+ % [\\.,\\d]+ [\\w]{3}$")
.match("^(?<nameContinued>.*)$")
.match("^ISIN: (?<isin>[A-Z]{2}[A-Z0-9]{9}[0-9])$")
.assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))),
// @formatter:off
// This is for the reinvestment of dividends
// We pick the second
//
Expand Down Expand Up @@ -174,6 +185,19 @@ private void addBuySellTransaction()
.match("^[\\d] (Ausbuchung|Tilgung) .* (?<shares>[\\.,\\d]+) Stk\\.$") //
.assign((t, v) -> t.setShares(asShares(v.get("shares")))),
// @formatter:off
// Bundesrep.Deutschland 1.019 EUR 98,05 % 999,13 EUR
// @formatter:on
section -> section //
.attributes("shares") //
.match("^.* (?<shares>[\\.,\\d]+) [\\w]{3} [\\.,\\d]+ % [\\.,\\d]+ [\\w]{3}$")
.assign((t, v) -> {
// @formatter:off
// Percentage quotation, workaround for bonds
// @formatter:on
BigDecimal shares = asBigDecimal(v.get("shares"));
t.setShares(Values.Share.factorize(shares.doubleValue() / 100));
}),
// @formatter:off
// 1 Reinvestierung Vodafone Group PLC 699 Stk.
// 2 Reinvestierung Vodafone Group PLC 22 Stk.
// @formatter:on
Expand Down Expand Up @@ -1656,6 +1680,17 @@ private void addBuySellTaxReturnBlock(DocumentType type)
.match("^[\\d] (Barausgleich|Kurswert) [\\.,\\d]+ (?<currency>[\\w]{3})$") //
.assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))),
// @formatter:off
// Bundesrep.Deutschland 1.019 EUR 98,05 % 999,13 EUR
// Bundesobl.Ser.180 v.2019(24)
// ISIN: DE0001141802
// @formatter:on
section -> section //
.attributes("name", "currency", "nameContinued", "isin") //
.match("^(?<name>.*) [\\.,\\d]+ (?<currency>[\\w]{3}) [\\.,\\d]+ % [\\.,\\d]+ [\\w]{3}$")
.match("^(?<nameContinued>.*)$")
.match("^ISIN: (?<isin>[A-Z]{2}[A-Z0-9]{9}[0-9])$")
.assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))),
// @formatter:off
// This is for the reinvestment of dividends
// We pick the second
//
Expand Down Expand Up @@ -1701,6 +1736,19 @@ private void addBuySellTaxReturnBlock(DocumentType type)
.match("^[\\d] (Ausbuchung|Tilgung) .* (?<shares>[\\.,\\d]+) Stk\\.$") //
.assign((t, v) -> t.setShares(asShares(v.get("shares")))),
// @formatter:off
// Bundesrep.Deutschland 1.019 EUR 98,05 % 999,13 EUR
// @formatter:on
section -> section //
.attributes("shares") //
.match("^.* (?<shares>[\\.,\\d]+) [\\w]{3} [\\.,\\d]+ % [\\.,\\d]+ [\\w]{3}$")
.assign((t, v) -> {
// @formatter:off
// Percentage quotation, workaround for bonds
// @formatter:on
BigDecimal shares = asBigDecimal(v.get("shares"));
t.setShares(Values.Share.factorize(shares.doubleValue() / 100));
}),
// @formatter:off
// 1 Reinvestierung Vodafone Group PLC 699 Stk.
// 2 Reinvestierung Vodafone Group PLC 22 Stk.
// @formatter:on
Expand Down

0 comments on commit f2f5e9f

Please sign in to comment.