use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType in project portfolio by buchen.
the class FinTechGroupBankPDFExtractor method addTaxReturnBlock.
@SuppressWarnings("nls")
private void addTaxReturnBlock(DocumentType type) {
// optional: Steuererstattung
Block block = new Block("Nr.(\\d*)/(\\d*) *Verkauf.*");
type.addBlock(block);
block.set(new Transaction<AccountTransaction>().subject(() -> {
AccountTransaction entry = new AccountTransaction();
entry.setType(AccountTransaction.Type.TAX_REFUND);
return entry;
}).section("taxreturn").optional().match(".* \\*\\*Einbeh. Steuer *: *(?<taxreturn>-[\\d.]+,\\d+) (?<currency>\\w{3}+)").assign((t, v) -> {
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(asAmount(v.get("taxreturn")));
}).section("wkn", "isin", "name").match("Nr.(\\d*)/(\\d*) *Verkauf *(?<name>.*) *\\((?<isin>[^/]*)/(?<wkn>[^)]*)\\)").assign((t, v) -> {
t.setSecurity(getOrCreateSecurity(v));
}).section("shares", "date").match("^davon ausgef\\. *: (?<shares>[.\\d]+,\\d*) St\\. *Schlusstag *: *(?<date>\\d+.\\d+.\\d{4}+), \\d+:\\d+ Uhr").assign((t, v) -> {
t.setShares(asShares(v.get("shares")));
t.setDateTime(asDate(v.get("date")));
}).wrap(t -> {
if (t.getCurrencyCode() != null && t.getAmount() != 0)
return new TransactionItem(t);
return null;
}));
}
use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType in project portfolio by buchen.
the class FinTechGroupBankPDFExtractor method addDividendTransaction.
@SuppressWarnings("nls")
private void addDividendTransaction() {
DocumentType type1 = new DocumentType("Dividendengutschrift für inländische Wertpapiere");
DocumentType type2 = new DocumentType("Ertragsmitteilung");
DocumentType type3 = new DocumentType("Zinsgutschrift");
this.addDocumentTyp(type1);
this.addDocumentTyp(type2);
this.addDocumentTyp(type3);
Block block = new Block("Ihre Depotnummer.*");
type1.addBlock(block);
type2.addBlock(block);
type3.addBlock(block);
block.set(new Transaction<AccountTransaction>().subject(() -> {
AccountTransaction t = new AccountTransaction();
t.setType(AccountTransaction.Type.DIVIDENDS);
return t;
}).section("wkn", "isin", "name").match("Nr\\.(\\d*) * (?<name>.*) *\\((?<isin>[^/]*)/(?<wkn>[^)]*)\\)").assign((t, v) -> {
t.setSecurity(getOrCreateSecurity(v));
}).section(//
"shares").match("^St\\.[^:]+: *(?<shares>[\\.\\d]+(,\\d*)?).*").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section("amount", //
"currency").match(//
".* Endbetrag *: *(?<amount>[\\d.-]+,\\d+) (?<currency>\\w{3}+)").assign((t, v) -> {
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(asAmount(v.get("amount")));
}).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")))))).section(//
"date").match("Valuta * : *(?<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 FinTechGroupBankPDFExtractor method addBuyTransaction.
@SuppressWarnings("nls")
private void addBuyTransaction() {
DocumentType type = new DocumentType("Wertpapierabrechnung Kauf Fonds/Zertifikate");
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.BUY);
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.[0-9A-Za-z]*/(\\d*) *Kauf *(?<name>.*) *\\((?<isin>[^/]*)/(?<wkn>[^)]*)\\)").assign((t, v) -> {
t.setSecurity(getOrCreateSecurity(v));
}).section(//
"shares").match(//
"^Ausgeführt *(?<shares>[\\.\\d]+(,\\d*)?) *St\\..*").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section("amount", //
"currency").match(//
" * Endbetrag *(?<currency>\\w{3}+) *(?<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 HelloBankPDFExtractor method addBuyTransaction.
@SuppressWarnings("nls")
private void addBuyTransaction() {
DocumentType type = new DocumentType("Geschäftsart: Kauf");
this.addDocumentTyp(type);
Block block = new Block("Geschäftsart: Kauf");
type.addBlock(block);
block.set(new Transaction<BuySellEntry>().subject(() -> {
BuySellEntry entry = new BuySellEntry();
entry.setType(PortfolioTransaction.Type.BUY);
return entry;
}).section("isin", "name", //
"currency").match(//
"Titel: (?<isin>\\S*) (?<name>.*)$").match("Kurs: [\\d+,.]* (?<currency>\\w{3}+) *").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section(//
"shares").match("^Zugang: (?<shares>[\\d+,.]*) Stk.*").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section("amount", //
"currency").match("Zu Lasten .* -(?<amount>[\\d+,.]*) (?<currency>\\w{3}+) *$").assign((t, v) -> {
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
}).section(//
"date").match("Handelszeit: (?<date>\\d+.\\d+.\\d{4}+).*").assign((t, v) -> t.setDate(asDate(v.get("date")))).section("fee", //
"currency").optional().match("Grundgebühr: -(?<fee>[\\d+,.]*) (?<currency>\\w{3}+) *").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: -(?<fee>[\\d+,.]*) (?<currency>\\w{3}+) *").assign((t, v) -> t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.FEE, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("fee")))))).section("gross", "currency", //
"exchangeRate").optional().match(//
"Kurswert: -(?<gross>[\\d+,.-]*) (?<currency>\\w{3}+) *").match("-[\\d+,.-]* \\w{3}+ *").match("Devisenkurs: (?<exchangeRate>[\\d+,.]*) \\(\\d+.\\d+.\\d{4}+\\) -[\\d+,.]* \\w{3}+ *").assign((t, v) -> {
long gross = asAmount(v.get("gross"));
String currency = asCurrencyCode(v.get("currency"));
BigDecimal exchangeRate = BigDecimal.ONE.divide(asExchangeRate(v.get("exchangeRate")), 10, BigDecimal.ROUND_HALF_UP);
PortfolioTransaction tx = t.getPortfolioTransaction();
if (currency.equals(tx.getSecurity().getCurrencyCode())) {
long convertedGross = BigDecimal.valueOf(gross).multiply(exchangeRate).setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
tx.addUnit(new Unit(Unit.Type.GROSS_VALUE, Money.of(tx.getCurrencyCode(), convertedGross), Money.of(currency, gross), exchangeRate));
}
}).wrap(BuySellEntryItem::new));
}
use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType in project portfolio by buchen.
the class HelloBankPDFExtractor method addSellTransaction.
@SuppressWarnings("nls")
private void addSellTransaction() {
DocumentType type = new DocumentType("Geschäftsart: Verkauf");
this.addDocumentTyp(type);
Block block = new Block("Geschäftsart: Verkauf");
type.addBlock(block);
block.set(new Transaction<BuySellEntry>().subject(() -> {
BuySellEntry entry = new BuySellEntry();
entry.setType(PortfolioTransaction.Type.SELL);
return entry;
}).section("isin", "name", //
"currency").match(//
"Titel: (?<isin>\\S*) (?<name>.*)$").match("Kurs: [\\d+,.]* (?<currency>\\w{3}+) *").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section(//
"shares").match("^Abgang: (?<shares>[\\d+,.]*) Stk.*").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section("amount", //
"currency").match("Zu Gunsten .* (?<amount>[\\d+,.]*) (?<currency>\\w{3}+) *$").assign((t, v) -> {
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
}).section(//
"date").match("Handelszeit: (?<date>\\d+.\\d+.\\d{4}+).*").assign((t, v) -> t.setDate(asDate(v.get("date")))).section("fee", //
"currency").optional().match("Grundgebühr: -(?<fee>[\\d+,.]*) (?<currency>\\w{3}+) *").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: -(?<fee>[\\d+,.]*) (?<currency>\\w{3}+) *").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: -(?<fee>[\\d+,.]*) (?<currency>\\w{3}+) *").assign((t, v) -> t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.FEE, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("fee")))))).section("gross", "tax", "currency", //
"exchangeRate").match(//
"Kurswert: (?<gross>[\\d+,.-]*) (?<currency>\\w{3}+) *").match(//
"Kapitalertragsteuer: -(?<tax>[\\d+,.-]*) \\w{3}+ *").match(//
"[\\d+,.-]* \\w{3}+ *").match("Devisenkurs: (?<exchangeRate>[\\d+,.]*) \\(\\d+.\\d+.\\d{4}+\\) [\\d+,.]* \\w{3}+ *").assign((t, v) -> {
long gross = asAmount(v.get("gross"));
long tax = asAmount(v.get("tax"));
String currency = asCurrencyCode(v.get("currency"));
BigDecimal exchangeRate = BigDecimal.ONE.divide(asExchangeRate(v.get("exchangeRate")), 10, BigDecimal.ROUND_HALF_UP);
PortfolioTransaction tx = t.getPortfolioTransaction();
if (currency.equals(tx.getSecurity().getCurrencyCode())) {
long convertedGross = BigDecimal.valueOf(gross).multiply(exchangeRate).setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
tx.addUnit(new Unit(Unit.Type.GROSS_VALUE, Money.of(tx.getCurrencyCode(), convertedGross), Money.of(currency, gross), exchangeRate));
long convertedTax = BigDecimal.valueOf(tax).multiply(exchangeRate).setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
tx.addUnit(new Unit(Unit.Type.TAX, Money.of(tx.getCurrencyCode(), convertedTax), Money.of(currency, tax), exchangeRate));
} else {
long convertedTax = BigDecimal.valueOf(tax).multiply(exchangeRate).setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
tx.addUnit(new Unit(Unit.Type.TAX, Money.of(tx.getCurrencyCode(), convertedTax)));
}
}).wrap(BuySellEntryItem::new));
}
Aggregations