Search in sources :

Example 6 with Block

use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block in project portfolio by buchen.

the class ConsorsbankPDFExtractor method addSellTransaction.

@SuppressWarnings("nls")
private void addSellTransaction() {
    DocumentType type = new DocumentType("VERKAUF");
    this.addDocumentTyp(type);
    Block block = new Block("^VERKAUF AM .*$");
    type.addBlock(block);
    Transaction<BuySellEntry> pdfTransaction = new Transaction<>();
    block.set(pdfTransaction);
    pdfTransaction.subject(() -> {
        BuySellEntry entry = new BuySellEntry();
        entry.setType(PortfolioTransaction.Type.SELL);
        return entry;
    });
    // 
    pdfTransaction.section("wkn", "isin", "name", "currency").find(// 
    "(Wertpapier|Bezeichnung) WKN ISIN").match(// 
    "^(?<name>.*) (?<wkn>[^ ]*) (?<isin>[^ ]*)$").match("(Kurs|Preis pro Anteil) (\\d+,\\d+) (?<currency>\\w{3}+) .*").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section(// 
    "shares").find(// 
    "Einheit Umsatz( F\\Dlligkeit)?").match(// 
    "^ST (?<shares>[\\d.]+(,\\d+)?).*$").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section("date", "time").match("VERKAUF AM (?<date>\\d+\\.\\d+\\.\\d{4}+)\\s+UM (?<time>\\d+:\\d+:\\d+).*.*").assign((t, v) -> t.setDate(asDate(v.get("date"), v.get("time")))).section("amount", "currency").match(// 
    "Wert \\d+.\\d+.\\d{4}+ (?<currency>\\w{3}+) (?<amount>[\\d.]+,\\d+)").assign((t, v) -> {
        t.setAmount(asAmount(v.get("amount")));
        t.setCurrencyCode(asCurrencyCode(v.get("currency")));
    }).wrap(BuySellEntryItem::new);
    addFeesSectionsTransaction(pdfTransaction);
    addTaxesSectionsTransaction(pdfTransaction);
}
Also used : PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Money(name.abuchen.portfolio.money.Money) Client(name.abuchen.portfolio.model.Client) Block(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) DocumentType(name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType) Type(name.abuchen.portfolio.model.Transaction.Unit.Type) IOException(java.io.IOException) BigDecimal(java.math.BigDecimal) Transaction(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction) Unit(name.abuchen.portfolio.model.Transaction.Unit) Optional(java.util.Optional) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) RoundingMode(java.math.RoundingMode) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Transaction(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction) DocumentType(name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType) Block(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block)

Example 7 with Block

use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block in project portfolio by buchen.

the class ConsorsbankPDFExtractor method addBuyTransaction.

@SuppressWarnings("nls")
private void addBuyTransaction() {
    DocumentType type = new DocumentType("KAUF");
    this.addDocumentTyp(type);
    Block block = new Block("^KAUF AM .*$");
    type.addBlock(block);
    Transaction<BuySellEntry> pdfTransaction = new Transaction<>();
    block.set(pdfTransaction);
    pdfTransaction.subject(() -> {
        BuySellEntry entry = new BuySellEntry();
        entry.setType(PortfolioTransaction.Type.BUY);
        return entry;
    });
    // 
    pdfTransaction.section("wkn", "isin", "name", "currency").find(// 
    "(Wertpapier|Bezeichnung) WKN ISIN").match(// 
    "^(?<name>.*) (?<wkn>[^ ]*) (?<isin>[^ ]*)$").match("(Kurs|Preis pro Anteil) (\\d+,\\d+) (?<currency>\\w{3}+) .*").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section(// 
    "shares").find(// 
    "Einheit Umsatz( F\\Dlligkeit)?").match(// 
    "^ST (?<shares>[\\d.]+(,\\d+)?).*$").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section("date", "time").match("KAUF AM (?<date>\\d+\\.\\d+\\.\\d{4}+)\\s+UM (?<time>\\d+:\\d+:\\d+).*").assign((t, v) -> t.setDate(asDate(v.get("date"), v.get("time")))).section("amount", "currency").match(// 
    "Wert \\d+.\\d+.\\d{4}+ (?<currency>\\w{3}+) (?<amount>[\\d.]+,\\d+)").assign((t, v) -> {
        t.setAmount(asAmount(v.get("amount")));
        t.setCurrencyCode(asCurrencyCode(v.get("currency")));
    }).wrap(BuySellEntryItem::new);
    addFeesSectionsTransaction(pdfTransaction);
}
Also used : PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Money(name.abuchen.portfolio.money.Money) Client(name.abuchen.portfolio.model.Client) Block(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) DocumentType(name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType) Type(name.abuchen.portfolio.model.Transaction.Unit.Type) IOException(java.io.IOException) BigDecimal(java.math.BigDecimal) Transaction(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction) Unit(name.abuchen.portfolio.model.Transaction.Unit) Optional(java.util.Optional) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) RoundingMode(java.math.RoundingMode) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Transaction(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction) DocumentType(name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType) Block(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block)

Example 8 with Block

use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block in project portfolio by buchen.

the class ConsorsbankPDFExtractor method addIncomeTransaction.

@SuppressWarnings("nls")
private void addIncomeTransaction() {
    DocumentType type = new DocumentType("ERTRAGSGUTSCHRIFT");
    this.addDocumentTyp(type);
    Block block = new Block("ERTRAGSGUTSCHRIFT.*");
    type.addBlock(block);
    block.set(newDividendTransaction(type));
}
Also used : DocumentType(name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType) Block(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block)

Example 9 with Block

use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block in project portfolio by buchen.

the class ConsorsbankPDFExtractor method addDividendTransaction.

@SuppressWarnings("nls")
private void addDividendTransaction() {
    DocumentType type = new DocumentType("DIVIDENDENGUTSCHRIFT");
    this.addDocumentTyp(type);
    Block block = new Block("DIVIDENDENGUTSCHRIFT.*");
    type.addBlock(block);
    block.set(newDividendTransaction(type));
}
Also used : DocumentType(name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType) Block(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block)

Example 10 with Block

use of name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block 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)));
}
Also used : PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Money(name.abuchen.portfolio.money.Money) Client(name.abuchen.portfolio.model.Client) Block(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) DocumentType(name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType) Type(name.abuchen.portfolio.model.Transaction.Unit.Type) IOException(java.io.IOException) BigDecimal(java.math.BigDecimal) Transaction(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction) Unit(name.abuchen.portfolio.model.Transaction.Unit) Optional(java.util.Optional) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) RoundingMode(java.math.RoundingMode) DocumentType(name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType) Block(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction)

Aggregations

Block (name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block)83 DocumentType (name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType)83 Transaction (name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction)81 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)81 IOException (java.io.IOException)80 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)80 BuySellEntry (name.abuchen.portfolio.model.BuySellEntry)80 Client (name.abuchen.portfolio.model.Client)80 Unit (name.abuchen.portfolio.model.Transaction.Unit)79 Money (name.abuchen.portfolio.money.Money)78 Map (java.util.Map)58 Matcher (java.util.regex.Matcher)58 Pattern (java.util.regex.Pattern)58 BigDecimal (java.math.BigDecimal)42 Values (name.abuchen.portfolio.money.Values)16 BiConsumer (java.util.function.BiConsumer)9 MutableMoney (name.abuchen.portfolio.money.MutableMoney)7 RoundingMode (java.math.RoundingMode)6 Optional (java.util.Optional)5 Type (name.abuchen.portfolio.model.Transaction.Unit.Type)5