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
add some new documents - trade republic #3807
add some new documents - trade republic #3807
Conversation
add Steuerlicher Umtausch add Spin-Off
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @christen90
thank you very much for this pull request.
I have looked at it and suggested some minor changes and corrections.
All in all it looks good.
What do you think? Could you take a look and check if necessary?
I would also be happy if you could include this PDF debug.
Would you have time for this?
https://forum.portfolio-performance.info/t/pdf-import-von-trade-republic/5107/486
Greetings
Alex
.wrap(t -> { | ||
return new TransactionItem(t); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.wrap(t -> { | |
return new TransactionItem(t); | |
}); | |
.wrap(TransactionItem::new); |
{ | ||
DocumentType type = new DocumentType("(STEUERLICHER UMTAUSCH)", (context, lines) -> { | ||
Pattern pDate = Pattern.compile("^(.*) DATUM (?<date>[\\d]{2}\\.[\\d]{2}\\.[\\d]{4})$"); | ||
context.put("transactionPosition", "0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this variable reused? No? Remove it 👍🏻
context.put("transactionPosition", "0"); |
.section("position", "name", "shares", "nameContinued", "isin") | ||
.match("^(?<position>[\\d]) (Einbuchung|Ausbuchung) (?<name>.*) (?<shares>[\\.,\\d]+) Stk\\.$") | ||
.match("^(?<nameContinued>.*)$") | ||
.match("^(?<isin>[A-Z]{2}[A-Z0-9]{9}[0-9])$") | ||
.assign((t, v) -> { | ||
Map<String, String> context = type.getCurrentContext(); | ||
context.put("position", v.get("position")); | ||
t.setDateTime(asDate(context.get("date"))); | ||
t.setShares(asShares(v.get("shares"))); | ||
t.setSecurity(getOrCreateSecurity(v)); | ||
t.setCurrencyCode(asCurrencyCode(t.getSecurity().getCurrencyCode())); | ||
t.setAmount(0L); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this variable "position" reused?
With the change for reading the date, .documentContext("date")
is now used. access to the variable v.get("date")
is now possible. In addition, we now check whether this exists.
.section("position", "name", "shares", "nameContinued", "isin") | |
.match("^(?<position>[\\d]) (Einbuchung|Ausbuchung) (?<name>.*) (?<shares>[\\.,\\d]+) Stk\\.$") | |
.match("^(?<nameContinued>.*)$") | |
.match("^(?<isin>[A-Z]{2}[A-Z0-9]{9}[0-9])$") | |
.assign((t, v) -> { | |
Map<String, String> context = type.getCurrentContext(); | |
context.put("position", v.get("position")); | |
t.setDateTime(asDate(context.get("date"))); | |
t.setShares(asShares(v.get("shares"))); | |
t.setSecurity(getOrCreateSecurity(v)); | |
t.setCurrencyCode(asCurrencyCode(t.getSecurity().getCurrencyCode())); | |
t.setAmount(0L); | |
.section("name", "shares", "nameContinued", "isin") | |
.documentContext("date") // | |
.match("^[\\d] (Einbuchung|Ausbuchung) (?<name>.*) (?<shares>[\\.,\\d]+) Stk\\.$") | |
.match("^(?<nameContinued>.*)$") | |
.match("^(?<isin>[A-Z]{2}[A-Z0-9]{9}[0-9])$") | |
.assign((t, v) -> { | |
t.setDateTime(v.get("date")); | |
t.setShares(asShares(v.get("shares"))); | |
t.setSecurity(getOrCreateSecurity(v)); | |
t.setCurrencyCode(asCurrencyCode(t.getSecurity().getCurrencyCode())); | |
t.setAmount(0L); |
DocumentType type = new DocumentType("(STEUERLICHER UMTAUSCH)", (context, lines) -> { | ||
Pattern pDate = Pattern.compile("^(.*) DATUM (?<date>[\\d]{2}\\.[\\d]{2}\\.[\\d]{4})$"); | ||
context.put("transactionPosition", "0"); | ||
|
||
for (String line : lines) | ||
{ | ||
Matcher mDate = pDate.matcher(line); | ||
if (mDate.matches()) | ||
context.put("date", mDate.group("date")); | ||
|
||
} | ||
}); | ||
this.addDocumentTyp(type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could extract the date from the document in this way.
It should also be possible to transfer the security data in this way.
DocumentType type = new DocumentType("(STEUERLICHER UMTAUSCH)", (context, lines) -> { | |
Pattern pDate = Pattern.compile("^(.*) DATUM (?<date>[\\d]{2}\\.[\\d]{2}\\.[\\d]{4})$"); | |
context.put("transactionPosition", "0"); | |
for (String line : lines) | |
{ | |
Matcher mDate = pDate.matcher(line); | |
if (mDate.matches()) | |
context.put("date", mDate.group("date")); | |
} | |
}); | |
this.addDocumentTyp(type); | |
final DocumentType type = new DocumentType("STEUERLICHER UMTAUSCH", // | |
documentContext -> documentContext // | |
// @formatter:off | |
// Straße 1 DATUM 07.12.2023 | |
// @formatter:on | |
.section("date") // | |
.match("^(.*) DATUM (?<date>[\\d]{2}\\.[\\d]{2}\\.[\\d]{4})$") // | |
.assign((ctx, v) -> ctx.put("date", asDate(v.get("date"))))); | |
this.addDocumentTyp(type); |
.section("type") | ||
.match("(^|^[\\d] )(?<type>" | ||
+ "(Einbuchung|Ausbuchung)" | ||
+ ") .* ([\\.,\\d]+ Stk\\.)$") | ||
.assign((t, v) -> { | ||
if ("Einbuchung".equals(v.get("type"))) | ||
{ | ||
t.setType(PortfolioTransaction.Type.DELIVERY_INBOUND); | ||
t.setNote("Einstandskurs fehlt"); | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing translation "note" but i think... remove this line.
.section("type") | |
.match("(^|^[\\d] )(?<type>" | |
+ "(Einbuchung|Ausbuchung)" | |
+ ") .* ([\\.,\\d]+ Stk\\.)$") | |
.assign((t, v) -> { | |
if ("Einbuchung".equals(v.get("type"))) | |
{ | |
t.setType(PortfolioTransaction.Type.DELIVERY_INBOUND); | |
t.setNote("Einstandskurs fehlt"); | |
} | |
}) | |
.section("type") | |
.match("^[\\d] (?<type>(Einbuchung|Ausbuchung)) .* [\\.,\\d]+ Stk\\.$") | |
.assign((t, v) -> { | |
if ("Einbuchung".equals(v.get("type"))) | |
t.setType(PortfolioTransaction.Type.DELIVERY_INBOUND); | |
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wenn im Dokument in Deutsch Ein/Ausbuchung steht wird der Nutzer auch "Einstandskurs fehlt" verstehen. Finde den Hinweis wichtig, da sich daraus ja die zu zahlenden Steuern bei späterer Veräußerung berechnen. Der Import jeglicher Einlieferungen mit Wert 0 führt ja zur Verfälschung des Einstandskurs (zum Beispiel bei Berichte-> Performance-> Wertpapiere in den Spalten Einstandskurs und Nicht realisierte Kurserfolge).
Finde den Hinweis hilfreich. Wenn irgendwann anderssprachige Trade Republic Dokumente auftauchen stimme ich dir zu - dann brauchen wir eine Übersetzung.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wenn der "Einstandskurs fehlt" sollten wir dann nicht mit "cancellation" oder "not supported" den Import markieren?
Wäre das nicht sinnvoller?
BTW ich sehe auch, dass die reguläre expressions immer unterschliedlich sind:
L1059 --> (^|^[\\d] )(Einbuchung|Ausbuchung) .* ([\\.,\\d]+ Stk\\.)$
L1075 --> ^[\\d] (?<type>(Einbuchung|Ausbuchung)) .* [\\.,\\d]+ Stk\\.$
L1097 --> ^(?<position>[\\d]) (Einbuchung|Ausbuchung) (?<name>.*) (?<shares>[\\.,\\d]+) Stk\\.$
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naja um den aktuellen Bestand abzubilden, ist das als Platzhalter ja schonmal nicht schlecht.
Die steuerlichen Details sehe ich persönlich eher optional.
Das Problem zieht sich durch sehr viele Importer, dass der Kurs bei Einlieferung hart auf 0 gesetzt wird. Das müsste man dann alles rausnehmen und Funktionsumfang reduzieren. Ich denke mit dem Einfügen einer Notiz ist der Gewinn größer.
L1059 kann ich noch anpassen. Ansonsten sind die doch gleich?
.section("position", "amount", "currency", "date") // | ||
.match("^(?<position>[\\d]) Kapitalertragsteuer \\-[\\.,\\d]+ ([\\w]{3})$") // |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this variable "position" reused?
.section("position", "amount", "currency", "date") // | |
.match("^(?<position>[\\d]) Kapitalertragsteuer \\-[\\.,\\d]+ ([\\w]{3})$") // | |
.section("amount", "currency", "date") // | |
.match("^[\\d] Kapitalertragsteuer \\-[\\.,\\d]+ ([\\w]{3})$") // |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops. added the comparison from in/outbound delivery with tax booking
adopting some of Alex recommendations
updated PR |
* add US Quellensteuer * add Steuerlicher Umtausch * add Spin-Off * add Zwangsübernahme Issue: #3807
squashed, rebased, and merged |
add US Quellensteuer
add Steuerlicher Umtausch
add Spin-Off