Search in sources :

Example 71 with DocumentType

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

the class INGDiBaExtractor method addBuyTransaction.

@SuppressWarnings("nls")
private void addBuyTransaction() {
    DocumentType type = new DocumentType("Wertpapierabrechnung Kauf");
    this.addDocumentTyp(type);
    Block block = new Block("Wertpapierabrechnung Kauf.*");
    type.addBlock(block);
    block.set(new Transaction<BuySellEntry>().subject(() -> {
        BuySellEntry entry = new BuySellEntry();
        entry.setType(PortfolioTransaction.Type.BUY);
        return entry;
    }).section("wkn", "isin", "name").match("^ISIN \\(WKN\\) (?<isin>[^ ]*) \\((?<wkn>.*)\\)$").match("Wertpapierbezeichnung (?<name>.*)").assign((t, v) -> {
        t.setSecurity(getOrCreateSecurity(v));
    }).section("shares").match("^Nominale( St.ck)? (?<shares>[\\d.]+(,\\d+)?).*").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section(// 
    "date").match(// 
    "(Ausf.hrungstag . -zeit|Ausf.hrungstag|Schlusstag . -zeit|Schlusstag) (?<date>\\d+.\\d+.\\d{4}+).*").assign((t, v) -> t.setDate(asDate(v.get("date")))).section("amount", // 
    "currency").match(// 
    "Endbetrag zu Ihren Lasten (?<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(// 
    "Handelsplatzgeb.hr (?<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(// 
    "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(// 
    "Handelsentgelt (?<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 -> {
        if (t.getPortfolioTransaction().getDateTime() == null)
            throw new IllegalArgumentException("Missing date");
        return new BuySellEntryItem(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) DocumentType(name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType) IOException(java.io.IOException) Matcher(java.util.regex.Matcher) Transaction(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction) Unit(name.abuchen.portfolio.model.Transaction.Unit) Map(java.util.Map) BiConsumer(java.util.function.BiConsumer) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) Pattern(java.util.regex.Pattern) 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) Unit(name.abuchen.portfolio.model.Transaction.Unit)

Example 72 with DocumentType

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

the class INGDiBaExtractor method addTaxSectionToAccountTransaction.

@SuppressWarnings("nls")
private void addTaxSectionToAccountTransaction(DocumentType type, Transaction<AccountTransaction> transaction) {
    // Kapitalerstragsteuer (Einzelkonto)
    // 
    transaction.section("tax", "currency").optional().match("Kapitalertragsteuer \\d+,\\d+ ?% (?<currency>\\w{3}+) (?<tax>[\\d.]+,\\d+)").assign((t, v) -> t.addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("tax")))))).section("tax1", "currency1", "tax2", "currency2").optional().match("KapSt anteilig 50,00 ?% \\d+,\\d+ ?% (?<currency1>\\w{3}+) (?<tax1>[\\d.]+,\\d+)").match("KapSt anteilig 50,00 ?% \\d+,\\d+ ?% (?<currency2>\\w{3}+) (?<tax2>[\\d.]+,\\d+)").assign((t, v) -> {
        t.addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency1")), asAmount(v.get("tax1")))));
        t.addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency2")), asAmount(v.get("tax2")))));
    }).section("tax", "currency").optional().match("Solidarit.tszuschlag \\d+,\\d+ ?% (?<currency>\\w{3}+) (?<tax>[\\d.]+,\\d+)").assign((t, v) -> {
        if (!Boolean.parseBoolean(type.getCurrentContext().get(IS_JOINT_ACCOUNT)))
            t.addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("tax")))));
    }).section("tax1", "currency1", "tax2", "currency2").optional().match("Solidarit.tszuschlag \\d+,\\d+ ?% (?<currency1>\\w{3}+) (?<tax1>[\\d.]+,\\d+)").match("Solidarit.tszuschlag \\d+,\\d+ ?% (?<currency2>\\w{3}+) (?<tax2>[\\d.]+,\\d+)").assign((t, v) -> {
        t.addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency1")), asAmount(v.get("tax1")))));
        t.addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency2")), asAmount(v.get("tax2")))));
    }).section("tax", "currency").optional().match("Kirchensteuer \\d+,\\d+ ?% (?<currency>\\w{3}+) (?<tax>[\\d.]+,\\d+)").assign((t, v) -> {
        if (!Boolean.parseBoolean(type.getCurrentContext().get(IS_JOINT_ACCOUNT)))
            t.addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("tax")))));
    }).section("tax1", "currency1", "tax2", "currency2").optional().match("Kirchensteuer \\d+,\\d+ ?% (?<currency1>\\w{3}+) (?<tax1>[\\d.]+,\\d+)").match("Kirchensteuer \\d+,\\d+ ?% (?<currency2>\\w{3}+) (?<tax2>[\\d.]+,\\d+)").assign((t, v) -> {
        t.addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency1")), asAmount(v.get("tax1")))));
        t.addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency2")), asAmount(v.get("tax2")))));
    }).section("tax", "currency", "taxTx", // 
    "currencyTx").optional().match("QuSt \\d+,\\d+ % \\((?<currencyTx>\\w{3}+) (?<taxTx>[\\d.,]*)\\) (?<currency>\\w{3}+) (?<tax>[\\d.,]*)").assign((t, v) -> {
        String currency = asCurrencyCode(v.get("currency"));
        String currencyTx = asCurrencyCode(v.get("currencyTx"));
        if (currency.equals(t.getCurrencyCode()))
            t.addUnit(new Unit(Unit.Type.TAX, Money.of(currency, asAmount(v.get("tax")))));
        else
            t.addUnit(new Unit(Unit.Type.TAX, Money.of(currencyTx, asAmount(v.get("taxTx")))));
    });
}
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) DocumentType(name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType) IOException(java.io.IOException) Matcher(java.util.regex.Matcher) Transaction(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction) Unit(name.abuchen.portfolio.model.Transaction.Unit) Map(java.util.Map) BiConsumer(java.util.function.BiConsumer) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) Pattern(java.util.regex.Pattern) Unit(name.abuchen.portfolio.model.Transaction.Unit)

Example 73 with DocumentType

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

the class INGDiBaExtractor method addErtragsgutschrift.

@SuppressWarnings("nls")
private void addErtragsgutschrift() {
    DocumentType type = new DocumentType("Ertragsgutschrift", isJointAccount);
    this.addDocumentTyp(type);
    Block block = new Block("Ertragsgutschrift");
    type.addBlock(block);
    Transaction<AccountTransaction> transaction = new Transaction<AccountTransaction>().subject(() -> {
        AccountTransaction entry = new AccountTransaction();
        entry.setType(AccountTransaction.Type.DIVIDENDS);
        return entry;
    }).section("wkn", "isin", "name").match("^ISIN \\(WKN\\) (?<isin>[^ ]*) \\((?<wkn>.*)\\)$").match("Wertpapierbezeichnung (?<name>.*)").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section("shares").match("^Nominale (?<shares>[\\d.]+(,\\d+)?) .*").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section(// 
    "date").match(// 
    "Zahltag (?<date>\\d+.\\d+.\\d{4}+)").assign((t, v) -> t.setDateTime(asDate(v.get("date")))).section("amount", // 
    "currency").match(// 
    "Gesamtbetrag zu Ihren Gunsten (?<currency>\\w{3}+) (?<amount>[\\d.]+,\\d+)").assign((t, v) -> {
        t.setCurrencyCode(asCurrencyCode(v.get("currency")));
        t.setAmount(asAmount(v.get("amount")));
    }).wrap(TransactionItem::new);
    addTaxSectionToAccountTransaction(type, transaction);
    block.set(transaction);
}
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) DocumentType(name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType) IOException(java.io.IOException) Matcher(java.util.regex.Matcher) Transaction(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction) Unit(name.abuchen.portfolio.model.Transaction.Unit) Map(java.util.Map) BiConsumer(java.util.function.BiConsumer) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) Pattern(java.util.regex.Pattern) DocumentType(name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType) Block(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction)

Example 74 with DocumentType

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

the class INGDiBaExtractor method addZinsgutschrift.

@SuppressWarnings("nls")
private void addZinsgutschrift() {
    DocumentType type = new DocumentType("Zinsgutschrift", isJointAccount);
    this.addDocumentTyp(type);
    Block block = new Block("Zinsgutschrift");
    type.addBlock(block);
    Transaction<AccountTransaction> transaction = new Transaction<AccountTransaction>().subject(() -> {
        AccountTransaction entry = new AccountTransaction();
        entry.setType(AccountTransaction.Type.DIVIDENDS);
        return entry;
    }).section("wkn", "isin", "name").match("^ISIN \\(WKN\\) (?<isin>[^ ]*) \\((?<wkn>.*)\\)$").match("Wertpapierbezeichnung (?<name>.*)").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section(// 
    "date").match(// 
    "Zahltag (?<date>\\d+.\\d+.\\d{4}+)").assign((t, v) -> t.setDateTime(asDate(v.get("date")))).section("amount", // 
    "currency").match(// 
    "Gesamtbetrag zu Ihren Gunsten (?<currency>\\w{3}+) (?<amount>[\\d.]+,\\d+)").assign((t, v) -> {
        t.setCurrencyCode(asCurrencyCode(v.get("currency")));
        t.setAmount(asAmount(v.get("amount")));
    }).wrap(TransactionItem::new);
    addTaxSectionToAccountTransaction(type, transaction);
    block.set(transaction);
}
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) DocumentType(name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType) IOException(java.io.IOException) Matcher(java.util.regex.Matcher) Transaction(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction) Unit(name.abuchen.portfolio.model.Transaction.Unit) Map(java.util.Map) BiConsumer(java.util.function.BiConsumer) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) Pattern(java.util.regex.Pattern) 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) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction)

Example 75 with DocumentType

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

the class INGDiBaExtractor method addSellTransaction.

@SuppressWarnings("nls")
private void addSellTransaction() {
    DocumentType type = new DocumentType("Wertpapierabrechnung Verkauf", isJointAccount);
    this.addDocumentTyp(type);
    Block block = new Block("Wertpapierabrechnung Verkauf.*");
    type.addBlock(block);
    Transaction<BuySellEntry> transaction = new Transaction<BuySellEntry>().subject(() -> {
        BuySellEntry entry = new BuySellEntry();
        entry.setType(PortfolioTransaction.Type.SELL);
        return entry;
    }).section("wkn", "isin", "name").match("^ISIN \\(WKN\\) (?<isin>[^ ]*) \\((?<wkn>.*)\\)$").match("Wertpapierbezeichnung (?<name>.*)").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section("shares").match("^Nominale St.ck (?<shares>[\\d.]+(,\\d+)?)").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section(// 
    "date").match(// 
    "(Ausf.hrungstag . -zeit|Ausf.hrungstag|Schlusstag . -zeit|Schlusstag) (?<date>\\d+.\\d+.\\d{4}+).*").assign((t, v) -> t.setDate(asDate(v.get("date")))).section("amount", // 
    "currency").match(// 
    "Endbetrag zu Ihren Gunsten (?<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(// 
    "Handelsplatzgeb.hr (?<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(// 
    "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(// 
    "Handelsentgelt (?<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(BuySellEntryItem::new);
    addTaxSectionToBuySellEntry(type, transaction);
    block.set(transaction);
}
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) DocumentType(name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType) IOException(java.io.IOException) Matcher(java.util.regex.Matcher) Transaction(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction) Unit(name.abuchen.portfolio.model.Transaction.Unit) Map(java.util.Map) BiConsumer(java.util.function.BiConsumer) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) Pattern(java.util.regex.Pattern) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) DocumentType(name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType) Block(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block) Unit(name.abuchen.portfolio.model.Transaction.Unit)

Aggregations

Block (name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block)86 DocumentType (name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType)86 Transaction (name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction)84 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)84 IOException (java.io.IOException)83 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)83 BuySellEntry (name.abuchen.portfolio.model.BuySellEntry)83 Client (name.abuchen.portfolio.model.Client)83 Unit (name.abuchen.portfolio.model.Transaction.Unit)82 Money (name.abuchen.portfolio.money.Money)81 Map (java.util.Map)60 Matcher (java.util.regex.Matcher)60 Pattern (java.util.regex.Pattern)60 BigDecimal (java.math.BigDecimal)43 Values (name.abuchen.portfolio.money.Values)16 BiConsumer (java.util.function.BiConsumer)11 RoundingMode (java.math.RoundingMode)7 MutableMoney (name.abuchen.portfolio.money.MutableMoney)7 Optional (java.util.Optional)6 Type (name.abuchen.portfolio.model.Transaction.Unit.Type)6