use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction in project portfolio by buchen.
the class OnvistaPDFExtractor method addDividendTransaction.
private void addDividendTransaction() {
DocumentType type = new DocumentType("Erträgnisgutschrift");
this.addDocumentTyp(type);
// Erträgnisgutschrift allein ist nicht gut hier, da es schon in der
// Kopfzeile steht..
Block block = new Block("Dividendengutschrift.*|Kupongutschrift.*|Erträgnisgutschrift.*(\\d+.\\d+.\\d{4})");
type.addBlock(block);
Transaction<AccountTransaction> pdfTransaction = new Transaction<>();
pdfTransaction.subject(() -> {
AccountTransaction transaction = new AccountTransaction();
transaction.setType(AccountTransaction.Type.DIVIDENDS);
return transaction;
});
block.set(pdfTransaction);
pdfTransaction.section("name", //
"isin").find("Gattungsbezeichnung(.*) ISIN").match(//
"(?<name>.*?) (\\d+.\\d+.\\d{4} ){0,2}(?<isin>[^ ]\\S*)$").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section("notation", "shares", "date", "amount", "currency").match("(?<notation>^\\w{3}+) (?<shares>[\\d.]+(,\\d{3,})?) (\\d+.\\d+.\\d{4}+) (?<date>\\d+.\\d+.\\d{4}+)?(.*)").match("(?<date>\\d+.\\d+.\\d{4}+)?(\\d{6,12})?(.{7,58} )?(?<currency>\\w{3}+) (?<amount>\\d{1,3}(\\.\\d{3})*(,\\d{2})?)").assign((t, v) -> {
String notation = v.get("notation");
if (notation != null && !"STK".equalsIgnoreCase(notation)) {
// Prozent-Notierung, Workaround..
t.setShares(asShares(v.get("shares")) / 100);
} else {
t.setShares(asShares(v.get("shares")));
}
t.setDateTime(asDate(v.get("date")));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
}).wrap(TransactionItem::new);
addTaxesSectionsTransaction(pdfTransaction);
// optional: Reinvestierung in:
block = new Block("Reinvestierung.*");
type.addBlock(block);
block.set(new Transaction<BuySellEntry>().subject(() -> {
BuySellEntry entry = new BuySellEntry();
entry.setType(PortfolioTransaction.Type.BUY);
return entry;
}).section("date").match("(^\\w{3}+) (\\d{1,3}(\\.\\d{3})*(,\\d{3})?) (\\d+.\\d+.\\d{4}+) (?<date>\\d+.\\d+.\\d{4}+)?(.*)").assign((t, v) -> t.setDate(asDate(v.get("date")))).section("name", //
"isin").find("Die Dividende wurde wie folgt in neue Aktien reinvestiert:").find(//
"Gattungsbezeichnung ISIN").match(//
"(?<name>.*) (?<isin>[^ ]\\S*)$").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section("notation", "shares", "amount", //
"currency").find("Nominal Reinvestierungspreis").match("(?<notation>^\\w{3}+) (?<shares>\\d{1,3}(\\.\\d{3})*(,\\d{3,})?) (?<currency>\\w{3}+) (?<amount>\\d{1,3}(\\.\\d{3})*(,\\d{2})?)(.*)").assign((t, v) -> {
String notation = v.get("notation");
if (notation != null && !notation.equalsIgnoreCase("STK")) {
// Prozent-Notierung, Workaround..
t.setShares((asShares(v.get("shares")) / 100));
} else {
t.setShares(asShares(v.get("shares")));
}
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount((asAmount(v.get("amount")) * asAmount(v.get("shares")) / 100));
}).wrap(BuySellEntryItem::new));
}
use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction in project portfolio by buchen.
the class OnvistaPDFExtractor method addTaxReturnTransaction.
private void addTaxReturnTransaction() {
DocumentType type = new DocumentType("Steuerausgleich nach § 43a");
this.addDocumentTyp(type);
Block block1 = new Block("Wir haben für Sie (ge|ver)kauft(.*)");
type.addBlock(block1);
Block block2 = new Block("(Aus|Ein)buchung:(.*)");
type.addBlock(block2);
Transaction<AccountTransaction> taxRefundTransaction = new Transaction<AccountTransaction>().subject(() -> {
AccountTransaction entry = new AccountTransaction();
entry.setType(AccountTransaction.Type.TAX_REFUND);
return entry;
}).section("name", //
"isin").find(//
"Gattungsbezeichnung ISIN").match(//
"(?<name>.*) (?<isin>[^ ]\\S*)$").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section("tax").optional().match("^Kapitalertragsteuer (?<currency>\\w{3}+) (?<tax>\\d{1,3}(\\.\\d{3})*(,\\d{2})?)").assign((t, v) -> {
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(asAmount(v.get("tax")));
}).section("soli").optional().match("^Solidaritätszuschlag (?<currency>\\w{3}+) (?<soli>\\d{1,3}(\\.\\d{3})*(,\\d{2})?)").assign((t, v) -> {
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(t.getAmount() + asAmount(v.get("soli")));
}).section("kirchenst").optional().match("^Kirchensteuer (?<currency>\\w{3}+) (?<kirchenst>\\d{1,3}(\\.\\d{3})*(,\\d{2})?)").assign((t, v) -> {
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(t.getAmount() + asAmount(v.get("kirchenst")));
}).section("date", "currency").optional().find("Wert(\\s+)Konto-Nr.(\\s+)Abrechnungs-Nr.(\\s+)Betrag zu Ihren Gunsten(\\s*)$").match("(^|\\s+)(?<date>\\d+\\.\\d+\\.\\d{4}+)(\\s)(\\d+)?(\\s)?(\\d+)?(\\s)(?<currency>\\w{3}+) (\\d{1,3}(\\.\\d{3})*(,\\d{2})?)").assign((t, v) -> {
t.setDateTime(asDate(v.get("date")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
}).wrap(t -> t.getAmount() != 0 ? new TransactionItem(t) : null);
block1.set(taxRefundTransaction);
block2.set(taxRefundTransaction);
}
use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction in project portfolio by buchen.
the class OnvistaPDFExtractor method addTransferInTransaction.
private void addTransferInTransaction() {
DocumentType type = new DocumentType("Wir erhielten zu Gunsten Ihres Depots");
this.addDocumentTyp(type);
Block block = new Block("Wir erhielten zu Gunsten Ihres Depots(.*)");
type.addBlock(block);
Transaction<BuySellEntry> pdfTransaction = new Transaction<>();
pdfTransaction.subject(() -> {
BuySellEntry entry = new BuySellEntry();
entry.setType(PortfolioTransaction.Type.TRANSFER_IN);
return entry;
});
block.set(pdfTransaction);
//
pdfTransaction.section("name", "isin").find(//
"Gattungsbezeichnung ISIN").match(//
"(?<name>.*) (?<isin>[^ ]\\S*)$").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section("notation", "shares", //
"date").find("Nominal Schlusstag Wert").match("(?<notation>^\\w{3}+) (?<shares>\\d{1,3}(\\.\\d{3})*(,\\d{3,})?) (\\d+.\\d+.\\d{4}+) (?<date>\\d+.\\d+.\\d{4}+)(.*)").assign((t, v) -> {
String notation = v.get("notation");
if (notation != null && !notation.equalsIgnoreCase("STK")) {
// Prozent-Notierung, Workaround..
t.setShares((asShares(v.get("shares")) / 100));
} else {
t.setShares(asShares(v.get("shares")));
}
t.setDate(asDate(v.get("date")));
t.setCurrencyCode(asCurrencyCode(t.getPortfolioTransaction().getSecurity().getCurrencyCode()));
}).wrap(BuySellEntryItem::new);
addFeesSectionsTransaction(pdfTransaction);
}
use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction in project portfolio by buchen.
the class OnvistaPDFExtractor method addChangeTransaction.
private void addChangeTransaction() {
DocumentType type = new DocumentType("Bestätigung");
this.addDocumentTyp(type);
Block block = new Block("Bestätigung(.*)");
type.addBlock(block);
Transaction<BuySellEntry> pdfTransaction = new Transaction<>();
pdfTransaction.subject(() -> {
BuySellEntry entry = new BuySellEntry();
entry.setType(PortfolioTransaction.Type.BUY);
return entry;
});
block.set(pdfTransaction);
//
pdfTransaction.section("name", "isin").find(//
"Gattungsbezeichnung ISIN").match(//
"(?<name>.*) (?<isin>[^ ]\\S*)$").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section("notation", //
"shares").find("Nominal Kurs").match(//
"(?<notation>^\\w{3}+) (?<shares>\\d{1,3}(\\.\\d{3})*(,\\d{3,})?)(.*)").assign((t, v) -> {
String notation = v.get("notation");
if (notation != null && !notation.equalsIgnoreCase("STK")) {
// Prozent-Notierung, Workaround..
t.setShares((asShares(v.get("shares")) / 100));
} else {
t.setShares(asShares(v.get("shares")));
}
}).section("date", "amount", //
"currency").find("Wert(\\s+)Konto-Nr. Betrag zu Ihren Lasten(\\s*)$").match("(?<date>\\d+.\\d+.\\d{4}+) (\\d{6,12}) (?<currency>\\w{3}+) (?<amount>\\d{1,3}(\\.\\d{3})*(,\\d{2})?)$").assign((t, v) -> {
t.setDate(asDate(v.get("date")));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
}).wrap(BuySellEntryItem::new);
addFeesSectionsTransaction(pdfTransaction);
}
use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction in project portfolio by buchen.
the class OnvistaPDFExtractor method addCompensationTransaction.
private void addCompensationTransaction() {
DocumentType type = new DocumentType("Abfindung");
this.addDocumentTyp(type);
Block block = new Block("Ausbuchung(.*)");
type.addBlock(block);
Transaction<BuySellEntry> pdfTransaction = new Transaction<>();
pdfTransaction.subject(() -> {
BuySellEntry entry = new BuySellEntry();
entry.setType(PortfolioTransaction.Type.SELL);
return entry;
});
block.set(pdfTransaction);
//
pdfTransaction.section("name", "isin").find(//
"Gattungsbezeichnung ISIN").match(//
"(?<name>.*) (?<isin>[^ ]\\S*)$").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section(//
"transactiontype").match(//
"^(?<transactiontype>.*buchung:)(.*)").assign((t, v) -> {
String transactiontype = v.get("transactiontype");
if ("Einbuchung:".equalsIgnoreCase(transactiontype)) {
t.getAccountTransaction().setType(AccountTransaction.Type.BUY);
t.getPortfolioTransaction().setType(PortfolioTransaction.Type.DELIVERY_INBOUND);
} else if ("Ausbuchung:".equalsIgnoreCase(transactiontype)) {
t.getAccountTransaction().setType(AccountTransaction.Type.SELL);
t.getPortfolioTransaction().setType(PortfolioTransaction.Type.DELIVERY_OUTBOUND);
} else {
// TODO: evtl. Warnung/Hinweis ausgeben?
}
}).section("notation", "shares", //
"date").find("Nominal Ex-Tag").match("(?<notation>^\\w{3}+) (?<shares>\\d{1,3}(\\.\\d{3})*(,\\d{3,})?) (?<date>\\d+.\\d+.\\d{4}+)(.*)").assign((t, v) -> {
String notation = v.get("notation");
if (notation != null && !notation.equalsIgnoreCase("STK")) {
// Prozent-Notierung, Workaround..
t.setShares((asShares(v.get("shares")) / 100));
} else {
t.setShares(asShares(v.get("shares")));
}
t.setDate(asDate(v.get("date")));
t.setCurrencyCode(asCurrencyCode(t.getPortfolioTransaction().getSecurity().getCurrencyCode()));
}).section("date", "amount", "currency").find("Wert(\\s+)Konto-Nr. Betrag zu Ihren Gunsten(\\s*)$").match("(?<date>\\d+.\\d+.\\d{4}+) (\\d{6,12}) (?<currency>\\w{3}+) (?<amount>\\d{1,3}(\\.\\d{3})*(,\\d{2})?)").assign((t, v) -> {
t.setDate(asDate(v.get("date")));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
}).wrap(BuySellEntryItem::new);
addFeesSectionsTransaction(pdfTransaction);
}
Aggregations