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 May 12, 2024
1 parent 207b1d0 commit d934b99
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
PDFBox Version: 1.8.17
Portfolio Performance Version: 0.68.5.qualifier
-----------------------------------------
ZspRKw DKmaCBNod DATUM 01 Apr. 2024 - 30 Apr. 2024
wNBzSBmMeEwDAAeU 22, 1230 IBAN DE12345678984235226335
asdEasnA, RE BIC CITIDEFF
KONTOÜBERSICHT
PRODUKT ANFANGSSALDO ZAHLUNGSEINGANG ZAHLUNGSAUSGANG ENDSALDO
Depotkonto 50.000,00 € 172,23 € 172,23 € 50.000,00 €
UMSATZÜBERSICHT
DATUM TYP BESCHREIBUNG ZAHLUNGSEINGANG ZAHLUNGSAUSGANG SALDO
01 Apr. 2024 Zinszahlung Your interest payment 172,23 € 50.172,23 €
01 Apr. 2024 Überweisung PayOut to transit 172,23 € 50.000,00 €
Seite 1 von 2
Erstellt am 01 Mai 2024
Trade Republic Bank GmbH
HAFTUNGSAUSSCHLUSS
Sehr geehrte Kundin, sehr geehrter Kunde
Bitte überprüfe unbedingt deine Buchungen, Berechnungen und den Schlusssaldo auf dem Kontoauszug, der gleichzeitig deinen Rechnungsabschluss
darstellt. Der Rechnungsabschluss gilt als anerkannt, wenn du innerhalb von sechs Wochen nach Zugang keine Einwendungen erhebst. Einwendungen
gegen Kontoauszüge sind schriftlich an uns zu richten. Guthaben sind einlagefähig im Sinne des Einlagensicherungsgesetzes (EinSiG). Weitere
Informationen entnehme bitte dem Merkblatt für den Einleger, das zusammen mit unseren Allgemeinen Geschäftsbedingungen eingesehen werden kann.
Trade Republic Bank GmbH Kontakt Sitz der Gesellschaft: Berlin
Brunnenstraße 19-21 www.traderepublic.com AG Charlottenburg HRB 244347 B
10119 Berlin service@traderepublic.com Umsatzsteuer-ID DE307510626
Seite 2 von 2
Erstellt am 01 Mai 2024
Trade Republic Bank GmbH
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,31 @@ public void testKontoauszug09()
hasSource("Kontoauszug09.txt"), hasNote("TooGoodT"))));
}

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

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

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

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

// assert transaction
assertThat(results, hasItem(interest(hasDate("2024-04-01"), hasAmount("EUR", 172.23), //
hasSource("Kontoauszug10.txt"), hasNote(null))));

// assert transaction
assertThat(results, hasItem(removal(hasDate("2024-04-01"), hasAmount("EUR", 172.23), //
hasSource("Kontoauszug10.txt"), hasNote(null))));
}

@Test
public void testSteuerabrechnung01()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1414,33 +1414,48 @@ private void addAccountStatementTransaction_Format02()
});
this.addDocumentTyp(type);

// @formatter:off
// 02 Apr. Überweisung Einzahlung akzeptiert: DE7243872432 auf 2024 DE7243872432 1.200,00 € 51.352,41 €
// @formatter:on
Block depositBlock = new Block("^[\\d]{2} [\\w]{3,4}([\\.]{1})? .berweisung Einzahlung akzeptiert:.*$");
type.addBlock(depositBlock);
depositBlock.setMaxSize(1);
depositBlock.set(new Transaction<AccountTransaction>()
Block depositRemovalBlock_Format01 = new Block("^[\\d]{2} [\\w]{3,4}([\\.]{1})?( [\\d]{4})? .berweisung .*$");
type.addBlock(depositRemovalBlock_Format01);
depositRemovalBlock_Format01.setMaxSize(1);
depositRemovalBlock_Format01.set(new Transaction<AccountTransaction>()

.subject(() -> {
AccountTransaction accountTransaction = new AccountTransaction();
accountTransaction.setType(AccountTransaction.Type.DEPOSIT);
return accountTransaction;
})

.section("date", "year", "amount", "currency") //
.match("^(?<date>[\\d]{2} [\\w]{3,4}([\\.]{1})?) .berweisung Einzahlung akzeptiert:.* auf (?<year>[\\d]{4}) .* (?<amount>[\\.,\\d]+) (?<currency>\\p{Sc}) [\\.,\\d]+ \\p{Sc}$") //
.assign((t, v) -> {
t.setDateTime(asDate(v.get("date") + " " + v.get("year")));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
})
.oneOf( //
// @formatter:off
// 02 Apr. Überweisung Einzahlung akzeptiert: DE7243872432 auf 2024 DE7243872432 1.200,00 € 51.352,41 €
// @formatter:on
section -> section //
.attributes("date", "year", "amount", "currency") //
.match("^(?<date>[\\d]{2} [\\w]{3,4}([\\.]{1})?) .berweisung Einzahlung .* auf (?<year>[\\d]{4}) .* (?<amount>[\\.,\\d]+) (?<currency>\\p{Sc}) [\\.,\\d]+ \\p{Sc}$") //
.assign((t, v) -> {
t.setDateTime(asDate(v.get("date") + " " + v.get("year")));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
}),
// @formatter:off
// 01 Apr. 2024 Überweisung PayOut to transit 172,23 € 50.000,00 €
// @formatter:on
section -> section //
.attributes("date", "amount", "currency") //
.match("^(?<date>[\\d]{2} [\\w]{3,4}([\\.]{1})? [\\d]{4}) .berweisung PayOut .* (?<amount>[\\.,\\d]+) (?<currency>\\p{Sc}) [\\.,\\d]+ \\p{Sc}$") //
.assign((t, v) -> {
t.setType(AccountTransaction.Type.REMOVAL);

t.setDateTime(asDate(v.get("date")));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
}))

.wrap(TransactionItem::new));

Block removalDepositBlock = new Block("^[\\d]{2} [\\w]{3,4}([\\.]{1})?[\\s]$");
type.addBlock(removalDepositBlock);
removalDepositBlock.set(new Transaction<AccountTransaction>()
Block depositRemovalBlock_Format02 = new Block("^[\\d]{2} [\\w]{3,4}([\\.]{1})?[\\s]$");
type.addBlock(depositRemovalBlock_Format02);
depositRemovalBlock_Format02.set(new Transaction<AccountTransaction>()

.subject(() -> {
AccountTransaction accountTransaction = new AccountTransaction();
Expand Down Expand Up @@ -1553,14 +1568,38 @@ private void addAccountStatementTransaction_Format02()
return null;
}));

// @formatter:off
// 01 Apr. 2024 Zinszahlung Your interest payment 172,23 € 50.172,23 €
// @formatter:on
Block interestBlock_Format01 = new Block("^[\\d]{2} [\\w]{3,4}([\\.]{1})? [\\d]{4} Zinszahlung .*$");
type.addBlock(interestBlock_Format01);
interestBlock_Format01.setMaxSize(1);
interestBlock_Format01.set(new Transaction<AccountTransaction>()

.subject(() -> {
AccountTransaction accountTransaction = new AccountTransaction();
accountTransaction.setType(AccountTransaction.Type.INTEREST);
return accountTransaction;
})

.section("date", "amount", "currency") //
.match("^(?<date>[\\d]{2} [\\w]{3,4}([\\.]{1})? [\\d]{4}) Zinszahlung .* (?<amount>[\\.,\\d]+) (?<currency>\\p{Sc}) [\\.,\\d]+ \\p{Sc}$") //
.assign((t, v) -> {
t.setDateTime(asDate(v.get("date")));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
})

.wrap(TransactionItem::new));

// @formatter:off
// 01 Apr.
// 2024 Zinszahlung Your interest payment 147,34 € 50.152,41 €
// @formatter:on
Block interestBlock = new Block("^[\\d]{2} [\\w]{3,4}([\\.]{1})?[\\s]$");
type.addBlock(interestBlock);
interestBlock.setMaxSize(2);
interestBlock.set(new Transaction<AccountTransaction>()
Block interestBlock_Format02 = new Block("^[\\d]{2} [\\w]{3,4}([\\.]{1})?[\\s]$");
type.addBlock(interestBlock_Format02);
interestBlock_Format02.setMaxSize(2);
interestBlock_Format02.set(new Transaction<AccountTransaction>()

.subject(() -> {
AccountTransaction accountTransaction = new AccountTransaction();
Expand Down

0 comments on commit d934b99

Please sign in to comment.