use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType in project portfolio by buchen.
the class ConsorsbankPDFExtractor method addTaxAdjustmentTransaction.
@SuppressWarnings("nls")
private void addTaxAdjustmentTransaction() {
DocumentType type = new DocumentType("Nachträgliche Verlustverrechnung");
this.addDocumentTyp(type);
Block block = new Block(" Erstattung/Belastung \\(-\\) von Steuern");
type.addBlock(block);
block.set(new Transaction<AccountTransaction>().subject(() -> {
AccountTransaction t = new AccountTransaction();
t.setType(AccountTransaction.Type.TAX_REFUND);
// nirgends im Dokument ist die Währung aufgeführt.
t.setCurrencyCode(CurrencyUnit.EUR);
return t;
}).section("date").match(" *Den Steuerausgleich buchen wir mit Wertstellung (?<date>\\d+.\\d+.\\d{4}) .*").assign((t, v) -> t.setDateTime(asDate(v.get("date")))).section("amount").find(" *Erstattung/Belastung \\(-\\) von Steuern *").find(" *=* *").match(" *(?<amount>[\\d.]+,\\d{2}) *").assign((t, v) -> t.setAmount(asAmount(v.get("amount")))).wrap(t -> new TransactionItem(t)));
}
use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType in project portfolio by buchen.
the class DABPDFExtractor method addBuyTransaction.
@SuppressWarnings("nls")
private void addBuyTransaction() {
DocumentType type = new DocumentType("Kauf");
this.addDocumentTyp(type);
Block block = new Block("^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").find(//
"Gattungsbezeichnung ISIN").match("^(?<name>.*) (?<isin>[^ ]*)$").match("STK [\\d.]+(,\\d+)? (?<currency>\\w{3}+) ([\\d.]+,\\d+)$").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section(//
"shares").find(//
"Nominal Kurs").match("^STK (?<shares>[\\d.]+(,\\d+)?) (\\w{3}+) ([\\d.]+,\\d+)$").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section("amount", //
"currency").optional().find("Wert Konto-Nr. Betrag zu Ihren Lasten").match("^(\\d+.\\d+.\\d{4}+) ([0-9]*) (?<currency>\\w{3}+) (?<amount>[\\d.]+,\\d+)$").assign((t, v) -> {
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
}).section("amount", "currency", "exchangeRate", "forex", "forexCurrency").optional().find(".* Ausmachender Betrag (?<forexCurrency>\\w{3}+) (?<forex>[\\d.]+,\\d+)-").find("Wert Konto-Nr. Devisenkurs Betrag zu Ihren Lasten").match("^(\\d+.\\d+.\\d{4}+) ([0-9]*) .../... (?<exchangeRate>[\\d.]+,\\d+) (?<currency>\\w{3}+) (?<amount>[\\d.]+,\\d+)$").assign((t, v) -> {
Money amount = Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("amount")));
t.setMonetaryAmount(amount);
BigDecimal exchangeRate = //
BigDecimal.ONE.divide(asExchangeRate(v.get("exchangeRate")), 10, BigDecimal.ROUND_HALF_DOWN);
Money forex = Money.of(asCurrencyCode(v.get("forexCurrency")), asAmount(v.get("forex")));
Unit grossValue = new Unit(Unit.Type.GROSS_VALUE, amount, forex, exchangeRate);
t.getPortfolioTransaction().addUnit(grossValue);
}).section(//
"date").match("^Handelstag (?<date>\\d+.\\d+.\\d{4}+) .*$").assign((t, v) -> t.setDate(asDate(v.get("date")))).section("fees", //
"currency").optional().match("^.* Provision (?<currency>\\w{3}+) (?<fees>[\\d.]+,\\d+)-$").assign((t, v) -> {
String currency = asCurrencyCode(v.get("currency"));
// FIXME forex fees must update gross value
if (currency.equals(t.getAccountTransaction().getCurrencyCode())) {
t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.FEE, Money.of(currency, asAmount(v.get("fees")))));
}
}).wrap(t -> {
if (t.getPortfolioTransaction().getAmount() == 0L)
throw new IllegalArgumentException("No amount found");
return new BuySellEntryItem(t);
}));
}
use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType in project portfolio by buchen.
the class DABPDFExtractor method addProceedsTransaction.
@SuppressWarnings("nls")
private void addProceedsTransaction() {
DocumentType type = new DocumentType("Erträgnisgutschrift");
this.addDocumentTyp(type);
// Block zweimal vorhanden, finde direkt 2. Block
Block block = new Block("^Erträgnisgutschrift (?!aus).*$");
type.addBlock(block);
Transaction<AccountTransaction> pdfTransaction = new Transaction<>();
pdfTransaction.subject(() -> {
AccountTransaction entry = new AccountTransaction();
entry.setType(AccountTransaction.Type.DIVIDENDS);
return entry;
});
block.set(pdfTransaction);
//
pdfTransaction.section("name", "isin").find("Gattungsbezeichnung ISIN").match("^(?<name>.*) (?<isin>[^ ]*)$").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section("shares").find("Nominal Ex-Tag Zahltag .*").match("^STK (?<shares>[\\d.]+(,\\d+)?) .*$").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section("date", "amount", "currency").optional().find("Wert\\s*Konto-Nr.\\s*Betrag\\s*zu\\s*Ihren\\s*Gunsten").match("^(?<date>\\d+.\\d+.\\d{4}+)\\s*([0-9]*) (?<currency>\\w{3}+)\\s*(?<amount>[\\d.]+,\\d+)$").assign((t, v) -> {
t.setDateTime(asDate(v.get("date")));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
}).section("date", "amount", //
"currency").optional().find("Wert\\s*Konto-Nr.\\s*Devisenkurs\\s*Betrag\\s*zu\\s*Ihren\\s*Gunsten").match("^(?<date>\\d+.\\d+.\\d{4}+)\\s*([0-9]*)\\s*(\\w{3}+)\\/(?<forign>\\w{3}+)\\s*(?<rate>[\\d.]+(,\\d+)?)\\s*(?<currency>\\w{3}+)\\s*(?<amount>[\\d.]+,\\d+)$").assign((t, v) -> {
t.setDateTime(asDate(v.get("date")));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
}).wrap(t -> {
if (t.getAmount() == 0)
throw new IllegalArgumentException("No dividend amount found.");
return new TransactionItem(t);
});
addTaxesSectionsTransaction(type, pdfTransaction);
}
use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType in project portfolio by buchen.
the class DABPDFExtractor method addDividendTransaction.
@SuppressWarnings("nls")
private void addDividendTransaction() {
DocumentType type = new DocumentType("Dividende");
this.addDocumentTyp(type);
Block block = new Block("^Dividendengutschrift .*$");
type.addBlock(block);
Transaction<AccountTransaction> pdfTransaction = new Transaction<>();
pdfTransaction.subject(() -> {
AccountTransaction entry = new AccountTransaction();
entry.setType(AccountTransaction.Type.DIVIDENDS);
return entry;
});
block.set(pdfTransaction);
//
pdfTransaction.section("isin", "name", "currency").find(//
"Gattungsbezeichnung ISIN").match(//
"^(?<name>.*) (?<isin>[^ ]*)$").match("STK ([\\d.]+(,\\d+)?) (\\d+.\\d+.\\d{4}+) (\\d+.\\d+.\\d{4}+) (?<currency>\\w{3}+) (\\d+,\\d+)").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section(//
"shares").find(//
"Nominal Ex-Tag Zahltag .*").match("^STK (?<shares>[\\d.]+(,\\d+)?) .*$").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section("date", "amount", //
"currency").optional().find("Wert *Konto-Nr. *Betrag *zu *Ihren *Gunsten").match("^(?<date>\\d+.\\d+.\\d{4}+) ([0-9]*) (?<currency>\\w{3}+) (?<amount>[\\d.]+,\\d+)$").assign((t, v) -> {
t.setDateTime(asDate(v.get("date")));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
}).section("date", "amount", "currency", "forexCurrency", //
"exchangeRate").optional().find("Wert Konto-Nr. Devisenkurs Betrag zu Ihren Gunsten").match("^(?<date>\\d+.\\d+.\\d{4}+) ([0-9]*) \\w{3}+/(?<forexCurrency>\\w{3}+) (?<exchangeRate>[\\d.]+,\\d+) (?<currency>\\w{3}+) (?<amount>[\\d.]+,\\d+)$").assign((t, v) -> {
t.setDateTime(asDate(v.get("date")));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
BigDecimal exchangeRate = asExchangeRate(v.get("exchangeRate")).setScale(10, BigDecimal.ROUND_HALF_DOWN);
Money forex = Money.of(asCurrencyCode(v.get("forexCurrency")), Math.round(t.getAmount() / exchangeRate.doubleValue()));
Unit unit = new Unit(Unit.Type.GROSS_VALUE, t.getMonetaryAmount(), forex, exchangeRate);
if (unit.getForex().getCurrencyCode().equals(t.getSecurity().getCurrencyCode()))
t.addUnit(unit);
}).section("forex", "localCurrency", "forexCurrency", //
"exchangeRate").optional().find("Wert Konto-Nr. Betrag zu Ihren Gunsten").match("^(\\d+.\\d+.\\d{4}+) ([0-9]*) (\\w{3}+) (?<forex>[\\d.]+,\\d+)$").match("Devisenkurs: (?<localCurrency>\\w{3}+)/(?<forexCurrency>\\w{3}+) (?<exchangeRate>[\\d.]+,\\d+)").assign((t, v) -> {
BigDecimal exchangeRate = asExchangeRate(v.get("exchangeRate")).setScale(10, BigDecimal.ROUND_HALF_DOWN);
Money forex = Money.of(asCurrencyCode(v.get("forexCurrency")), asAmount(v.get("forex")));
Money localAmount = Money.of(v.get("localCurrency"), Math.round(forex.getAmount() / Double.parseDouble(v.get("exchangeRate").replace(',', '.'))));
t.setAmount(forex.getAmount());
t.setCurrencyCode(forex.getCurrencyCode());
Unit unit = new Unit(Unit.Type.GROSS_VALUE, forex, localAmount, exchangeRate);
if (unit.getForex().getCurrencyCode().equals(t.getSecurity().getCurrencyCode()))
t.addUnit(unit);
}).wrap(t -> {
if (t.getAmount() == 0)
throw new IllegalArgumentException("No dividend amount found.");
return new TransactionItem(t);
});
addTaxesSectionsTransaction(type, pdfTransaction);
}
use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType in project portfolio by buchen.
the class DeutscheBankPDFExtractor method addBuyTransaction.
@SuppressWarnings("nls")
private void addBuyTransaction() {
DocumentType type = new DocumentType("Kauf von Wertpapieren");
this.addDocumentTyp(type);
Block block = new Block("Abrechnung: Kauf von Wertpapieren");
type.addBlock(block);
block.set(new Transaction<BuySellEntry>().subject(() -> {
BuySellEntry entry = new BuySellEntry();
entry.setType(PortfolioTransaction.Type.BUY);
return entry;
}).section("wkn", "isin", "name", "currency").find(//
"Filialnummer Depotnummer Wertpapierbezeichnung Seite").match(//
"^.{15}(?<name>.*)$").match(//
"^WKN (?<wkn>[^ ]*) (.*)$").match(//
"^ISIN (?<isin>[^ ]*) Kurs (?<currency>\\w{3}+) (.*)$").assign((t, v) -> {
t.setSecurity(getOrCreateSecurity(v));
}).section(//
"shares").match(//
"^WKN [^ ]* Nominal ST (?<shares>\\d+(,\\d+)?)").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section("date", "amount", "currency").match("Buchung auf Kontonummer [\\d ]* mit Wertstellung (?<date>\\d+.\\d+.\\d{4}+) (?<currency>\\w{3}+) (?<amount>[\\d.]+,\\d+)").assign((t, v) -> {
t.setDate(asDate(v.get("date")));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(v.get("currency"));
}).section("provision", //
"currency").optional().match("Provision( \\([0-9,]* %\\))? (?<currency>\\w{3}+) (?<provision>[\\d.]+,\\d+)").assign((t, v) -> t.getPortfolioTransaction().addUnit(new //
Unit(//
Unit.Type.FEE, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("provision")))))).section("additional", //
"currency").optional().match("Weitere Provision der Bank bei der börslichen Orderausführung (?<currency>\\w{3}+) (?<additional>[\\d.]+,\\d+)").assign((t, v) -> t.getPortfolioTransaction().addUnit(new //
Unit(//
Unit.Type.FEE, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("additional")))))).section("xetra", //
"currency").optional().match("XETRA-Kosten (?<currency>\\w{3}+) (?<xetra>[\\d.]+,\\d+)").assign((t, v) -> t.getPortfolioTransaction().addUnit(new //
Unit(//
Unit.Type.FEE, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("xetra")))))).wrap(t -> new BuySellEntryItem(t)));
}
Aggregations