use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType in project portfolio by buchen.
the class DkbPDFExtractor method addInvestmentEarningTransaction.
private void addInvestmentEarningTransaction() {
DocumentType type = new DocumentType("Investmenterträge", (context, lines) -> {
Pattern pattern = Pattern.compile("Devisenkurs (?<term>\\w{3}+) / (?<base>\\w{3}+) (?<exchangeRate>[\\d,.]*)");
for (String line : lines) {
Matcher m = pattern.matcher(line);
if (m.matches())
context.put(EXCHANGE_RATE, m.group("exchangeRate"));
}
});
this.addDocumentTyp(type);
Block block = new Block("Gutschrift von Investmenterträgen");
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("shares", "name", "isin", "wkn", "currency").find("Nominale Wertpapierbezeichnung ISIN \\(WKN\\)").match("(^St\\Dck) (?<shares>[\\d,.]*) (?<name>.*)$").match(//
".*").match(//
"(?<isin>[^ ]*) \\((?<wkn>.*)\\)$").match("^Ertrag pro St. [\\d,.]* (?<currency>\\w{3}+)").assign((t, v) -> {
t.setShares(asShares(v.get("shares")));
t.setSecurity(getOrCreateSecurity(v));
}).section("date", "amount").match("(^Ausmachender Betrag) (?<amount>[\\d,.]*)(.*) (?<currency>\\w{3}+)").match("(^Lagerstelle) (.*)").match("(^Den Betrag buchen wir mit Wertstellung) (?<date>\\d+.\\d+.\\d{4}+) zu Gunsten des Kontos (.*)").assign((t, v) -> {
t.setDateTime(asDate(v.get("date")));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
}).wrap(TransactionItem::new);
addTaxesSectionsTransaction(type, pdfTransaction);
addFeesSectionsTransaction(pdfTransaction);
}
use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType in project portfolio by buchen.
the class DkbPDFExtractor method addTaxReturnBlock.
private void addTaxReturnBlock(DocumentType type) {
// optional: Steuererstattung
Block block = new Block("^Kapitalertragsteuer (.*) (\\w{3}+) ([\\d.-]+,\\d+)(\\+) (\\w{3}+)(.*)");
type.addBlock(block);
block.set(new Transaction<AccountTransaction>().subject(() -> {
AccountTransaction entry = new AccountTransaction();
entry.setType(AccountTransaction.Type.TAX_REFUND);
return entry;
}).section("tax", "currency").optional().match("^Kapitalertragsteuer (.*) (\\w{3}+) (?<tax>[\\d.-]+,\\d+)(\\+) (?<currency>\\w{3}+)").assign((t, v) -> {
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(asAmount(v.get("tax")));
}).section("soli", "currency").optional().match("^Solidarit(.*) (\\w{3}+) (?<soli>[\\d.-]+,\\d+)(\\+) (?<currency>\\w{3}+)").assign((t, v) -> {
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(t.getAmount() + asAmount(v.get("soli")));
}).section("kirchenst", "currency").optional().match("^Kirchensteuer (.*) (\\w{3}+) (?<kirchenst>[\\d.-]+,\\d+)(\\+) (?<currency>\\w{3}+)").assign((t, v) -> {
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(t.getAmount() + asAmount(v.get("kirchenst")));
}).section("date").match("(^Den Betrag buchen wir mit Valuta) (?<date>\\d+.\\d+.\\d{4}+) zu Lasten des Kontos (.*)").assign((t, v) -> {
t.setDateTime(asDate(v.get("date")));
v.put("isin", type.getCurrentContext().get("isin"));
t.setSecurity(getOrCreateSecurity(v));
}).wrap(TransactionItem::new));
}
use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType in project portfolio by buchen.
the class FinTechGroupBankPDFExtractor method addSellTransaction.
@SuppressWarnings("nls")
private void addSellTransaction() {
DocumentType type = new DocumentType("Wertpapierabrechnung Verkauf");
this.addDocumentTyp(type);
Block block = new Block(" *FinTech Group Bank AG*| *biw AG*");
type.addBlock(block);
block.set(new Transaction<BuySellEntry>().subject(() -> {
BuySellEntry entry = new BuySellEntry();
entry.setType(PortfolioTransaction.Type.SELL);
return entry;
}).section("date").match(//
".*Schlusstag *(?<date>\\d+.\\d+.\\d{4}).*").assign((t, v) -> t.setDate(asDate(v.get("date")))).section("wkn", "isin", "name").match(//
"Nr.(\\d*)/(\\d*) *Verkauf *(?<name>.*) *\\((?<isin>[^/]*)/(?<wkn>[^)]*)\\)").assign((t, v) -> {
t.setSecurity(getOrCreateSecurity(v));
}).section("shares", "notation").match(//
"^Ausgeführt *(?<shares>[\\.\\d]+(,\\d*)?) *(?<notation>St\\.|\\w{3}+).*").assign((t, v) -> {
String notation = v.get("notation");
if (notation != null && !notation.equalsIgnoreCase("St.")) {
// Prozent-Notierung, Workaround..
t.setShares((asShares(v.get("shares")) / 100));
} else {
t.setShares(asShares(v.get("shares")));
}
}).section("amount", "currency").match(".* Endbetrag(\\s+)(?<currency>\\w{3}+)(\\s+)(?<amount>[\\d.]+,\\d+)").assign((t, v) -> {
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(asAmount(v.get("amount")));
}).section("fee", "currency").optional().match(".* Provision *(?<currency>\\w{3}+) *(?<fee>[\\d.-]+,\\d+)").assign((t, v) -> t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.FEE, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("fee")))))).section("fee", "currency").optional().match(".* Eigene Spesen *(?<currency>\\w{3}+) *(?<fee>[\\d.-]+,\\d+)").assign((t, v) -> t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.FEE, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("fee")))))).section("fee", "currency").optional().match(".* \\*Fremde Spesen *(?<currency>\\w{3}+) *(?<fee>[\\d.-]+,\\d+)").assign((t, v) -> t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.FEE, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("fee")))))).wrap(t -> new BuySellEntryItem(t)));
}
use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType in project portfolio by buchen.
the class FinTechGroupBankPDFExtractor method addDepositAndWithdrawalTransaction.
@SuppressWarnings("nls")
private void addDepositAndWithdrawalTransaction() {
final DocumentType type = new DocumentType("Kontoauszug Nr:", (context, lines) -> {
Pattern pYear = Pattern.compile("Kontoauszug Nr:[ ]*\\d+/(\\d+).*");
Pattern pCurrency = Pattern.compile("Kontow.hrung:[ ]+(\\w{3}+)");
// read the current context here
for (String line : lines) {
Matcher m = pYear.matcher(line);
if (m.matches()) {
context.put("year", m.group(1));
}
m = pCurrency.matcher(line);
if (m.matches()) {
context.put("currency", m.group(1));
}
}
});
this.addDocumentTyp(type);
// deposit, add value to account
// 01.01. 01.01. xyz 123,45+
Block block = new Block("\\d+\\.\\d+\\.[ ]+\\d+\\.\\d+\\.[ ]+.berweisung[ ]+[\\d.-]+,\\d+[+-]");
type.addBlock(block);
block.set(new Transaction<AccountTransaction>().subject(() -> {
AccountTransaction t = new AccountTransaction();
t.setType(AccountTransaction.Type.DEPOSIT);
return t;
}).section("valuta", "amount", "sign").match("\\d+.\\d+.[ ]+(?<valuta>\\d+.\\d+.)[ ]+.berweisung[ ]+(?<amount>[\\d.-]+,\\d+)(?<sign>[+-])").assign((t, v) -> {
Map<String, String> context = type.getCurrentContext();
String date = v.get("valuta");
if (date != null) {
// create a long date from the year in the
// context
t.setDateTime(asDate(date + context.get("year")));
}
t.setNote(v.get("text"));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(asCurrencyCode(context.get("currency")));
// check for withdrawals
String sign = v.get("sign");
if ("-".equals(sign)) {
// change type for withdrawals
t.setType(AccountTransaction.Type.REMOVAL);
}
}).wrap(t -> new TransactionItem(t)));
// fees for foreign dividends, subtract value from account
block = new Block("\\d+\\.\\d+\\.[ ]+\\d+\\.\\d+\\.[ ]+Geb.hr Kapitaltransaktion Ausland[ ]+[\\d.-]+,\\d+[-]");
type.addBlock(block);
block.set(new Transaction<AccountTransaction>().subject(() -> {
AccountTransaction t = new AccountTransaction();
t.setType(AccountTransaction.Type.FEES);
return t;
}).section("valuta", "amount").match("\\d+.\\d+.[ ]+(?<valuta>\\d+.\\d+.)[ ]+Geb.hr Kapitaltransaktion Ausland[ ]+(?<amount>[\\d.-]+,\\d+)[-]").assign((t, v) -> {
Map<String, String> context = type.getCurrentContext();
String date = v.get("valuta");
if (date != null) {
// create a long date from the year in the
// context
t.setDateTime(asDate(date + context.get("year")));
}
t.setNote(v.get("text"));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(asCurrencyCode(context.get("currency")));
}).wrap(t -> new TransactionItem(t)));
}
use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType in project portfolio by buchen.
the class FinTechGroupBankPDFExtractor method addTransferInOutTransaction.
// example is from 2016-12-01
@SuppressWarnings("nls")
private void addTransferInOutTransaction() {
DocumentType type = new DocumentType("Gutschrifts-/Belastungsanzeige");
this.addDocumentTyp(type);
Block block = new Block("Depoteingang .*");
type.addBlock(block);
block.set(new Transaction<PortfolioTransaction>().subject(() -> {
PortfolioTransaction entry = new PortfolioTransaction();
entry.setType(PortfolioTransaction.Type.DELIVERY_INBOUND);
return entry;
}).section("date").match(//
"Datum(\\s*):(\\s+)(?<date>\\d+.\\d+.\\d{4})").assign((t, v) -> t.setDateTime(asDate(v.get("date")))).section("isin", "name").match(//
"Depoteingang *(?<name>.*) *\\((?<isin>[^/]*)\\)").assign((t, v) -> {
t.setSecurity(getOrCreateSecurity(v));
}).section("shares", "notation").match(//
"^Stk\\.\\/Nominale(\\s*):(\\s+)(?<shares>[\\.\\d]+(,\\d*)?) *(?<notation>St\\.|\\w{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("rate", "currency").match("^Kurs(\\s*):(\\s+)(?<rate>[\\d.]+,\\d+)(\\s+)(?<currency>\\w{3}+)(\\s+)(.*)").assign((t, v) -> {
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(asAmount(v.get("rate")) * t.getShares() / Values.Share.factor());
}).section("tax", "currency").optional().match(//
"(.*)Einbeh. Steuer(.*):(\\s*)(?<tax>[\\d.]+,\\d+) (?<currency>\\w{3}+)").assign((t, v) -> t.addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("tax")))))).wrap(t -> new TransactionItem(t)));
}
Aggregations