Search in sources :

Example 6 with Type

use of name.abuchen.portfolio.model.Transaction.Unit.Type in project portfolio by buchen.

the class ConsorsbankPDFExtractor method addPreemptiveBuyTransaction.

@SuppressWarnings("nls")
private void addPreemptiveBuyTransaction() {
    DocumentType type = new DocumentType("BEZUG");
    this.addDocumentTyp(type);
    Block block = new Block("^BEZUG 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", "amount", "currency").match(// 
    "Wert (?<date>\\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")));
        t.setDate(asDate(v.get("date")));
    }).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)

Aggregations

IOException (java.io.IOException)6 BigDecimal (java.math.BigDecimal)6 RoundingMode (java.math.RoundingMode)6 Optional (java.util.Optional)6 Block (name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block)6 DocumentType (name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType)6 Transaction (name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction)6 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)6 BuySellEntry (name.abuchen.portfolio.model.BuySellEntry)6 Client (name.abuchen.portfolio.model.Client)6 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)6 Unit (name.abuchen.portfolio.model.Transaction.Unit)6 Type (name.abuchen.portfolio.model.Transaction.Unit.Type)6 CurrencyUnit (name.abuchen.portfolio.money.CurrencyUnit)6 Money (name.abuchen.portfolio.money.Money)6