Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Trade Republic PDF import to support new date format #1867

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,33 @@
{
"version": 1,
"transactions": [
{
"type": "DIVIDEND",
"date": "2020-12-11",
"currency": "EUR",
"amount": 1.09,
"shares": 3.3272,
"security": {
"name": "Walgreens Boots Alliance Inc.",
"isin": "US9314271084",
"currency": "USD"
},
"units": [
{
"type": "GROSS_VALUE",
"amount": 1.28,
"fxAmount": 1.56,
"fxCurrency": "USD",
"fxRateToBase": 1.2153
},
{
"type": "TAX",
"amount": 0.19,
"fxAmount": 0.23,
"fxCurrency": "USD",
"fxRateToBase": 1.2153
}
]
}
]
}
@@ -0,0 +1,32 @@
PDF Autor: ''
PDFBox Version: 1.8.16
-----------------------------------------
TRADE REPUBLIC BANK GMBH KASTANIENALLEE 32 10435 BERLIN
SEITE 1 von 1
DATUM 15.12.2020
DEPOT
DIVIDENDE
ÜBERSICHT
Dividende mit dem Ex-Tag 18.11.2020.
POSITION ANZAHL ERTRÄGNIS BETRAG
Walgreens Boots Alliance Inc. 3,3272 Stk. 0,468 USD 1,56 USD
Reg. Shares DL -,01
ISIN: US9314271084
GESAMT 1,56 USD
ABRECHNUNG
POSITION BETRAG
Quellensteuer DE für US-Emittent -0,23 USD
Zwischensumme 1,33 USD
Zwischensumme 1,2153 EUR/USD 1,09 EUR
GESAMT 1,09 EUR
BUCHUNG
VERRECHNUNGSKONTO VALUTA BETRAG
DE 2020-12-11 1,09 EUR
Walgreens Boots Alliance Inc. Reg. Shares DL -,01 in Girosammelverwahrung.
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: Düsseldorf Geschäftsführer
Kastanienallee 32 service@traderepublic.com AG Düsseldorf HRB 85864 Andreas Willius
10435 Berlin USt-ID DE307510626 Karsten Müller
ABRE / 073e-7cd0
Expand Up @@ -28,6 +28,7 @@
public abstract class AbstractPDFExtractor implements Extractor
{
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("d.M.yyyy", Locale.GERMANY); //$NON-NLS-1$
private static final DateTimeFormatter DATE_FORMAT_DASHES = DateTimeFormatter.ofPattern("yyyy-M-d", Locale.GERMANY); //$NON-NLS-1$
private static final DateTimeFormatter DATE_TIME_SECONDS_FORMAT = DateTimeFormatter.ofPattern("d.M.yyyy HH:mm", //$NON-NLS-1$
Locale.GERMANY);
private static final DateTimeFormatter DATE_TIME_FORMAT = DateTimeFormatter.ofPattern("d.M.yyyy HH:mm:ss", //$NON-NLS-1$
Expand Down Expand Up @@ -242,7 +243,17 @@ protected String asCurrencyCode(String currency)

/* protected */LocalDateTime asDate(String value)
{
return value == null ? null : LocalDate.parse(value, DATE_FORMAT).atStartOfDay();
LocalDateTime date = null;

try
{
date = LocalDate.parse(value, DATE_FORMAT).atStartOfDay();
}
catch (DateTimeParseException e)
{
date = LocalDate.parse(value, DATE_FORMAT_DASHES).atStartOfDay();
}
return date;
}

/* protected */LocalTime asTime(String value)
Expand Down
Expand Up @@ -60,7 +60,7 @@ private void addBuyTransaction()
})

.section("date", "time") //
.match(".*Order Kauf am (?<date>\\d+.\\d+.\\d{4}+), um (?<time>\\d+:\\d+) Uhr.*")
.match(".*Order Kauf am (?<date>\\d+\\.\\d+\\.\\d{4}|\\d{4}-\\d+-\\d+), um (?<time>\\d+:\\d+) Uhr.*")
.assign((t, v) -> t.setDate(asDate(v.get("date"), v.get("time"))))

.section("fee", "currency") //
Expand Down Expand Up @@ -124,7 +124,7 @@ private void addSellTransaction()
})

.section("date", "time") //
.match(".*Order Verkauf am (?<date>\\d+.\\d+.\\d{4}+), um (?<time>\\d+:\\d+) Uhr.*")
.match(".*Order Verkauf am (?<date>\\d+\\.\\d+\\.\\d{4}|\\d{4}-\\d+-\\d+), um (?<time>\\d+:\\d+) Uhr.*")
.assign((t, v) -> t.setDate(asDate(v.get("date"), v.get("time"))))

.section("fee", "currency") //
Expand Down Expand Up @@ -192,7 +192,7 @@ private void addSellTransaction()
.section("tax", "currency", "date").optional() //
.match("Kapitalertragssteuer Optimierung (?<tax>[\\d+,.]*) (?<currency>\\w{3}+)")
.match("VERRECHNUNGSKONTO VALUTA BETRAG")
.match(".* (?<date>\\d+.\\d+.\\d{4}+) (?<amount>[\\d+,.]*) (\\w{3}+)")
.match(".* (?<date>\\d+\\.\\d+\\.\\d{4}|\\d{4}-\\d+-\\d+) (?<amount>[\\d+,.]*) (\\w{3}+)")
.assign((t, v) -> {
t.setAmount(asAmount(v.get("tax")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
Expand All @@ -202,7 +202,7 @@ private void addSellTransaction()
.section("tax", "currency", "date").optional() //
.match("Solidaritätszuschlag Optimierung (?<tax>[\\d+,.]*) (?<currency>\\w{3}+)")
.match("VERRECHNUNGSKONTO VALUTA BETRAG")
.match(".* (?<date>\\d+.\\d+.\\d{4}+) (?<amount>[\\d+,.]*) (\\w{3}+)")
.match(".* (?<date>\\d+\\.\\d+\\.\\d{4}|\\d{4}-\\d+-\\d+) (?<amount>[\\d+,.]*) (\\w{3}+)")
.assign((t, v) -> {
t.setAmount(t.getAmount() + asAmount(v.get("tax")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
Expand All @@ -212,7 +212,7 @@ private void addSellTransaction()
.section("tax", "currency", "date").optional() //
.match("Kirchensteuer Optimierung (?<tax>[\\d+,.]*) (?<currency>\\w{3}+)")
.match("VERRECHNUNGSKONTO VALUTA BETRAG")
.match(".* (?<date>\\d+.\\d+.\\d{4}+) (?<amount>[\\d+,.]*) (\\w{3}+)")
.match(".* (?<date>\\d+\\.\\d+\\.\\d{4}|\\d{4}-\\d+-\\d+) (?<amount>[\\d+,.]*) (\\w{3}+)")
.assign((t, v) -> {
t.setAmount(t.getAmount() + asAmount(v.get("tax")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
Expand Down Expand Up @@ -257,7 +257,7 @@ private void addLiquidationTransaction()

.section("date") //
.match("VERRECHNUNGSKONTO VALUTA BETRAG")
.match("\\w* (?<date>\\d+.\\d+.\\d{4}+) .*")
.match("\\w* (?<date>\\d+\\.\\d+\\.\\d{4}|\\d{4}-\\d+-\\d+) .*")
.assign((t, v) -> t.setDate(asDate(v.get("date"))))

.wrap(BuySellEntryItem::new));
Expand All @@ -274,7 +274,7 @@ private void addLiquidationTransaction()
.section("tax", "currency", "date").optional() //
.match(".*Kapitalertragssteuer Optimierung (?<tax>[\\d+,.]*) (?<currency>\\w{3}+)")
.match("VERRECHNUNGSKONTO VALUTA BETRAG")
.match(".* (?<date>\\d+.\\d+.\\d{4}+) ([\\d+,.]*) (\\w{3}+)")
.match(".* (?<date>\\d+\\.\\d+\\.\\d{4}|\\d{4}-\\d+-\\d+) ([\\d+,.]*) (\\w{3}+)")
.assign((t, v) -> {
t.setAmount(asAmount(v.get("tax")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
Expand All @@ -284,7 +284,7 @@ private void addLiquidationTransaction()
.section("tax", "currency", "date").optional() //
.match("Solidaritätszuschlag Optimierung (?<tax>[\\d+,.]*) (?<currency>\\w{3}+)")
.match("VERRECHNUNGSKONTO VALUTA BETRAG")
.match(".* (?<date>\\d+.\\d+.\\d{4}+) ([\\d+,.]*) (\\w{3}+)")
.match(".* (?<date>\\d+\\.\\d+\\.\\d{4}|\\d{4}-\\d+-\\d+) ([\\d+,.]*) (\\w{3}+)")
.assign((t, v) -> {
t.setAmount(t.getAmount() + asAmount(v.get("tax")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
Expand All @@ -294,7 +294,7 @@ private void addLiquidationTransaction()
.section("tax", "currency", "date").optional() //
.match("Kirchensteuer Optimierung (?<tax>[\\d+,.]*) (?<currency>\\w{3}+)")
.match("VERRECHNUNGSKONTO VALUTA BETRAG")
.match(".* (?<date>\\d+.\\d+.\\d{4}+) ([\\d+,.]*) (\\w{3}+)")
.match(".* (?<date>\\d+\\.\\d+\\.\\d{4}|\\d{4}-\\d+-\\d+) ([\\d+,.]*) (\\w{3}+)")
.assign((t, v) -> {
t.setAmount(t.getAmount() + asAmount(v.get("tax")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
Expand Down Expand Up @@ -332,7 +332,7 @@ private void addAccountStatementTransaction()
})

.section("date", "amount")
.match("(?<date>\\d+.\\d+.\\d{4}+) Accepted PayIn:.* to .* (?<amount>[\\d+,.]*)")
.match("(?<date>\\d+\\.\\d+\\.\\d{4}|\\d{4}-\\d+-\\d+) Accepted PayIn:.* to .* (?<amount>[\\d+,.]*)")
.assign((t, v) -> {
t.setDateTime(asDate(v.get("date")));
t.setAmount(asAmount(v.get("amount")));
Expand Down
Expand Up @@ -22,7 +22,7 @@
{
"pattern": [
"VERRECHNUNGSKONTO VALUTA BETRAG",
".* (?<date>\\d+.\\d+.\\d{4}+) (?<amount>[\\d+,.]*) (?<currency>\\w{3})"
".* (?<date>\\d+\\.\\d+\\.\\d{4}|\\d{4}-\\d+-\\d+) (?<amount>[\\d+,.]*) (?<currency>\\w{3})"
]
},
{
Expand Down
Expand Up @@ -27,7 +27,7 @@
},
{
"pattern": [
"Sparplanausführung am (?<date>\\d+.\\d+.\\d{4}+) .*"
"Sparplanausführung am (?<date>\\d+\\.\\d+\\.\\d{4}|\\d{4}-\\d+-\\d+) .*"
]
},
{
Expand Down