use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType in project portfolio by buchen.
the class BaaderBankPDFExtractor method addFeesAssetManagerTransaction.
@SuppressWarnings("nls")
private void addFeesAssetManagerTransaction() {
DocumentType type = new DocumentType("Vergütung des Vermögensverwalters");
this.addDocumentTyp(type);
Block block = new Block("Rechnung für .*");
type.addBlock(block);
block.set(new Transaction<AccountTransaction>().subject(() -> {
AccountTransaction t = new AccountTransaction();
t.setType(AccountTransaction.Type.FEES);
return t;
}).section("currency", "amount").match("Leistungen Beträge \\((?<currency>\\w{3})\\).*").match("Rechnungsbetrag *(?<amount>[\\d.]+,\\d{2}).*").assign((t, v) -> {
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(asAmount(v.get("amount")));
}).section("date").match("Abbuchungsdatum: (?<date>\\d+.\\d+.\\d{4})").assign((t, v) -> t.setDateTime(asDate(v.get("date")))).wrap(t -> new TransactionItem(t)));
}
use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType in project portfolio by buchen.
the class BankSLMPDFExtractor method addBuyTransaction.
@SuppressWarnings("nls")
private void addBuyTransaction() {
DocumentType type = new DocumentType("abrechnung - Kauf");
this.addDocumentTyp(type);
Block block = new Block("B.rsenabrechnung - Kauf");
type.addBlock(block);
Transaction<BuySellEntry> extractor = new Transaction<BuySellEntry>().subject(() -> {
BuySellEntry entry = new BuySellEntry();
entry.setType(PortfolioTransaction.Type.BUY);
return entry;
}).section("date", "shares", "name", "wkn", "currency").match(//
"Wir haben f.r Sie am (?<date>\\d+.\\d+.\\d{4}+) gekauft.").match(//
"^(?<shares>[\\d.']+) .*$").match(//
"^(?<name>.*)$").match(//
"^Valor: (?<wkn>[^ ]*)$").match(//
"Total Kurswert (?<currency>\\w{3}+) .*").assign((t, v) -> {
t.setDate(asDate(v.get("date")));
t.setShares(asShares(v.get("shares")));
t.setSecurity(getOrCreateSecurity(v));
}).section("amount", //
"currency").match(//
"Netto (?<currency>\\w{3}+) -(?<amount>[\\d.']+)").assign((t, v) -> {
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(v.get("currency"));
}).wrap(t -> new BuySellEntryItem(t));
addForexGrossValue(extractor);
addFeesSection(extractor);
block.set(extractor);
}
use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType in project portfolio by buchen.
the class ComdirectPDFExtractor method addBuyTransaction.
@SuppressWarnings("nls")
private void addBuyTransaction() {
DocumentType type = new DocumentType("Wertpapierkauf");
this.addDocumentTyp(type);
Block block = new Block("^(\\* )?Wertpapierkauf *.*");
type.addBlock(block);
Transaction<BuySellEntry> pdfTransaction = new Transaction<BuySellEntry>().subject(() -> {
BuySellEntry entry = new BuySellEntry();
entry.setType(PortfolioTransaction.Type.BUY);
return entry;
}).section(//
"date").match(//
"Geschäftstag *: (?<date>\\d+.\\d+.\\d{4}+) .*").assign((t, v) -> t.setDate(asDate(v.get("date")))).section("isin", "name", //
"wkn").find(//
"Wertpapier-Bezeichnung *WPKNR/ISIN *").match(//
"^(?<name>(\\S{1,} )*) *(?<wkn>\\S*) *$").match(//
"(\\S{1,} )* *(?<isin>\\S*) *$").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section("shares").optional().match(//
"^St\\. *(?<shares>[\\d.]+(,\\d+)?) .*").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section("shares").optional().match(//
"^ Summe *St\\. *(?<shares>[\\d.]+(,\\d+)?) .*").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section("amount", //
"currency").find(//
".*Zu Ihren Lasten( vor Steuern)? *").match(//
".* \\d+.\\d+.\\d{4}+ *(?<currency>\\w{3}+) *(?<amount>[\\d.]+,\\d+).*").assign((t, v) -> {
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(asAmount(v.get("amount")));
}).section("tax").optional().match(//
"^a *b *g *e *f *ü *h *r *t *e *S *t *e *u *e *r *n *(?<tax>.*)$").assign((t, v) -> {
Unit unit = createTaxUnit(v.get("tax"));
if (unit == null || unit.getAmount().isZero())
return;
t.getPortfolioTransaction().addUnit(unit);
MutableMoney total = MutableMoney.of(t.getPortfolioTransaction().getCurrencyCode());
total.add(t.getPortfolioTransaction().getMonetaryAmount());
total.add(unit.getAmount());
t.setMonetaryAmount(total.toMoney());
}).wrap(t -> {
if (t.getPortfolioTransaction().getShares() == 0)
throw new IllegalArgumentException(Messages.PDFMsgMissingShares);
return new BuySellEntryItem(t);
});
addFeesSection(pdfTransaction);
block.set(pdfTransaction);
addTaxRefunds(type, "^(\\* )?Wertpapierkauf *.*");
}
use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType in project portfolio by buchen.
the class ComdirectPDFExtractor method addDividendTransaction.
@SuppressWarnings("nls")
private void addDividendTransaction() {
DocumentType dividende = new DocumentType("Abrechnung Dividendengutschrift");
this.addDocumentTyp(dividende);
DocumentType ertrag = new DocumentType("Abrechnung Ertragsgutschrift");
this.addDocumentTyp(ertrag);
Block block = new Block(".*G *u *t *s *c *h *r *i *f *t *f *ä *l *l *i *g *e *r *W *e *r *t *p *a *p *i *e *r *- *E *r *t *r *ä *g *e *");
dividende.addBlock(block);
ertrag.addBlock(block);
block.set(new Transaction<AccountTransaction>().subject(() -> {
AccountTransaction t = new AccountTransaction();
t.setType(AccountTransaction.Type.DIVIDENDS);
return t;
}).section("wkn", "name", "isin", "shares").optional().match(//
"^\\s*(p\\s*e\\s*r) *\\+?[\\d .]+ (?<name>.*) (?<wkn>.*)").match(//
"^\\s*(S\\s*T\\s*K) *(?<shares>\\+?[\\d .]+,\\+?[\\d ]+).* .* {4}(?<isin>.*)$").assign((t, v) -> {
v.put("isin", stripBlanks(v.get("isin")));
v.put("wkn", stripBlanks(v.get("wkn")));
t.setSecurity(getOrCreateSecurity(v));
t.setShares(asShares(stripBlanks(v.get("shares"))));
}).section("currency", "amount", //
"date").find(//
".*Zu Ihren Gunsten vor Steuern *").match(//
"^.*(?<date>\\d{2}.\\d{2}.\\d{4}) *(?<currency>\\w{3}+) *(?<amount>[\\d.]+,\\d+) *$").assign((t, v) -> {
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(asAmount(v.get("amount")));
t.setDateTime(asDate(v.get("date")));
}).section("currency", //
"gross").optional().find("^Bruttobetrag: *(?<currency>\\w{3}+) *(?<gross>[\\d.]+,\\d+)").assign((t, v) -> {
long gross = asAmount(v.get("gross"));
long tax = gross - t.getAmount();
Unit unit = new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency")), tax));
if (unit.getAmount().getCurrencyCode().equals(t.getCurrencyCode()))
t.addUnit(unit);
}).wrap(TransactionItem::new));
}
use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType in project portfolio by buchen.
the class ComdirectPDFExtractor method addTaxTransaction.
@SuppressWarnings("nls")
private void addTaxTransaction() {
// TODO 1: combine with dividend-transaction of other file
// TODO 2: not matched by buy/sell with taxes...
// just char sequence
DocumentType type = new DocumentType("Steuerliche Behandlung: Ausländische Dividende");
// type.setMustExclude("Wertpapierkauf");
this.addDocumentTyp(type);
Block block = new Block("^\\s*Steuerliche Behandlung:.*");
type.addBlock(block);
block.set(new Transaction<AccountTransaction>().subject(() -> {
AccountTransaction t = new AccountTransaction();
t.setType(AccountTransaction.Type.TAXES);
return t;
}).section("wkn", "name", "isin", "shares").optional().match(//
"^(Stk.)\\W*(?<shares>\\d[\\d .,]*)(?<name>.*),\\W*(WKN / ISIN:)(?<wkn>.*)/(?<isin>.*)$").assign((t, v) -> {
v.put("isin", stripBlanks(v.get("isin")));
v.put("wkn", stripBlanks(v.get("wkn")));
t.setSecurity(getOrCreateSecurity(v));
t.setShares(asShares(stripBlanks(v.get("shares"))));
}).section(//
"date").match(//
"^.*Die Gutschrift erfolgt mit Valuta\\s+(?<date>\\d{2}.\\d{2}.\\d{4}).*$").assign((t, v) -> {
t.setDateTime(asDate(v.get("date")));
}).section("tax", "currency").optional().match(//
"^\\s*(K\\s*a\\s*p\\s*i\\s*t\\s*a\\s*l\\s*e\\s*r\\s*t\\s*r\\s*a\\s*g\\s*s\\s*t\\s*e\\s*u\\s*e\\s*r)" + //
"(?<currency>[A-Z\\s]+)(?<tax>[\\d\\s,-]+)$").assign((t, v) -> {
v.put("currency", stripBlanksAndUnderscores(v.get("currency")));
v.put("tax", stripBlanksAndUnderscores(v.get("tax")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("tax")))));
}).section("tax", "currency").optional().match("^\\s*(K\\s*i\\s*r\\s*c\\s*h\\s*e\\s*n\\s*s\\s*t\\s*e\\s*u\\s*e\\s*r)" + "(?<currency>[A-Z\\s_]+)(?<tax>[\\d\\s,-_]+)$").assign((t, v) -> {
v.put("currency", stripBlanksAndUnderscores(v.get("currency")));
v.put("tax", stripBlanksAndUnderscores(v.get("tax")));
t.addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("tax")))));
}).section("tax", "currency").optional().match("^\\s*(S\\s*o\\s*l\\s*i\\s*d\\s*a\\s*r\\s*i\\s*t\\s*ä\\s*t\\s*s\\s*z\\s*u\\s*s\\s*c\\s*h\\s*l\\s*a\\s*g)" + "(?<currency>[A-Z\\s_]+)(?<tax>[\\d\\s,-_]+)$").assign((t, v) -> {
v.put("currency", stripBlanksAndUnderscores(v.get("currency")));
v.put("tax", stripBlanksAndUnderscores(v.get("tax")));
t.addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("tax")))));
}).section("tax", // abgeführte Steuern
"currency").match("^\\s*(a\\s*b\\s*g\\s*e\\s*f\\s*ü\\s*h\\s*r\\s*t\\s*e\\s*S\\s*t\\s*e\\s*u\\s*er\\s*n)" + "(?<currency>[A-Z\\s_]+)(?<tax>[\\d\\s,-_]+)$").assign((t, v) -> {
v.put("currency", stripBlanksAndUnderscores(v.get("currency")));
v.put("tax", stripBlanksAndUnderscores(v.get("tax")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(asAmount(v.get("tax")));
}).wrap(TransactionItem::new));
}
Aggregations