Search in sources :

Example 26 with Unit

use of name.abuchen.portfolio.model.Transaction.Unit 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)));
}
Also used : PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) 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) BigDecimal(java.math.BigDecimal) Matcher(java.util.regex.Matcher) Transaction(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction) Unit(name.abuchen.portfolio.model.Transaction.Unit) Map(java.util.Map) 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)

Example 27 with Unit

use of name.abuchen.portfolio.model.Transaction.Unit 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));
}
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) BigDecimal(java.math.BigDecimal) 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) 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) BigDecimal(java.math.BigDecimal)

Example 28 with Unit

use of name.abuchen.portfolio.model.Transaction.Unit 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));
}
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) BigDecimal(java.math.BigDecimal) 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) 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) BigDecimal(java.math.BigDecimal)

Example 29 with Unit

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

the class HelloBankPDFExtractor method addDividendTransaction.

@SuppressWarnings("nls")
private void addDividendTransaction() {
    DocumentType type = new DocumentType("Geschäftsart: Ertrag", (context, lines) -> {
        Pattern exchangeRatePattern = Pattern.compile("Devisenkurs: (?<exchangeRate>[\\d+,.]*) \\(\\d+.\\d+.\\d{4}+\\) [\\d+,.]* \\w{3}+ *");
        for (String line : lines) {
            Matcher matcher = exchangeRatePattern.matcher(line);
            if (matcher.matches())
                context.put("exchangeRate", matcher.group(1));
        }
    });
    this.addDocumentTyp(type);
    Block block = new Block("Geschäftsart: Ertrag");
    type.addBlock(block);
    BiConsumer<AccountTransaction, Map<String, String>> taxProcessor = (t, v) -> {
        long tax = asAmount(v.get("tax"));
        String currency = asCurrencyCode(v.get("currency"));
        if (currency.equals(t.getCurrencyCode())) {
            t.addUnit(new Unit(Unit.Type.TAX, Money.of(t.getCurrencyCode(), tax)));
        } else {
            String exchangeRateString = type.getCurrentContext().get("exchangeRate");
            if (exchangeRateString != null) {
                BigDecimal exchangeRate = BigDecimal.ONE.divide(asExchangeRate(exchangeRateString), 10, BigDecimal.ROUND_HALF_UP);
                if (currency.equals(t.getSecurity().getCurrencyCode())) {
                    long convertedTax = BigDecimal.valueOf(tax).multiply(exchangeRate).setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
                    t.addUnit(new Unit(Unit.Type.TAX, Money.of(t.getCurrencyCode(), convertedTax), Money.of(currency, tax), exchangeRate));
                } else {
                    long convertedTax = BigDecimal.valueOf(tax).multiply(exchangeRate).setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
                    t.addUnit(new Unit(Unit.Type.TAX, Money.of(t.getCurrencyCode(), convertedTax)));
                }
            }
        }
    };
    block.set(new Transaction<AccountTransaction>().subject(() -> {
        AccountTransaction transaction = new AccountTransaction();
        transaction.setType(AccountTransaction.Type.DIVIDENDS);
        return transaction;
    }).section("isin", "name", // 
    "currency").match(// 
    "Titel: (?<isin>\\S*) (?<name>.*)$").match("Dividende: [\\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(// 
    "Valuta (?<date>\\d+.\\d+.\\d{4}+)").assign((t, v) -> t.setDateTime(asDate(v.get("date")))).section("tax", // 
    "currency").optional().match("Inkassoprovision: -(?<tax>[\\d+,.]*) (?<currency>\\w{3}+) *").assign(taxProcessor).section("tax", // 
    "currency").optional().match("Umsatzsteuer: -(?<tax>[\\d+,.]*) (?<currency>\\w{3}+) *").assign(taxProcessor).section("tax", // 
    "currency").optional().match(// 
    "Fremde Spesen: -(?<tax>[\\d+,.-]*) (?<currency>\\w{3}+) *").assign(taxProcessor).section("tax", // 
    "currency").optional().match(// 
    "KESt Ausländische Dividende: -(?<tax>[\\d+,.]*) (?<currency>\\w{3}+) *").assign(taxProcessor).section("tax", // 
    "currency").optional().match(// 
    "Quellensteuer[^.]*: -(?<tax>[\\d+,.]*) (?<currency>\\w{3}+) *").assign(taxProcessor).section("gross", // 
    "currency").optional().match("Bruttoertrag: (?<gross>[\\d+,.-]*) (?<currency>\\w{3}+) *").assign((t, v) -> {
        long gross = asAmount(v.get("gross"));
        String currency = asCurrencyCode(v.get("currency"));
        if (currency.equals(t.getSecurity().getCurrencyCode())) {
            String exchangeRateString = type.getCurrentContext().get("exchangeRate");
            if (exchangeRateString != null) {
                BigDecimal exchangeRate = BigDecimal.ONE.divide(asExchangeRate(exchangeRateString), 10, BigDecimal.ROUND_HALF_UP);
                long convertedGross = BigDecimal.valueOf(gross).multiply(exchangeRate).setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
                t.addUnit(new Unit(Unit.Type.GROSS_VALUE, Money.of(t.getCurrencyCode(), convertedGross), Money.of(currency, gross), exchangeRate));
            }
        }
    }).wrap(TransactionItem::new));
}
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) BigDecimal(java.math.BigDecimal) 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) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) DocumentType(name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Unit(name.abuchen.portfolio.model.Transaction.Unit) BigDecimal(java.math.BigDecimal) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Transaction(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction) Block(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block) Map(java.util.Map)

Example 30 with Unit

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

the class INGDiBaExtractor method addTaxSectionToBuySellEntry.

@SuppressWarnings("nls")
private void addTaxSectionToBuySellEntry(DocumentType type, Transaction<BuySellEntry> transaction) {
    // Kapitalerstragsteuer (Einzelkonto)
    // 
    transaction.section("tax", "currency").optional().match("Kapitalertragsteuer \\d+,\\d+ ?% (?<currency>\\w{3}+) (?<tax>[\\d.]+,\\d+)").assign((t, v) -> t.getPortfolioTransaction().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.getPortfolioTransaction().addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency1")), asAmount(v.get("tax1")))));
        t.getPortfolioTransaction().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.getPortfolioTransaction().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.getPortfolioTransaction().addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency1")), asAmount(v.get("tax1")))));
        t.getPortfolioTransaction().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.getPortfolioTransaction().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.getPortfolioTransaction().addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency1")), asAmount(v.get("tax1")))));
        t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency2")), asAmount(v.get("tax2")))));
    });
}
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)

Aggregations

Unit (name.abuchen.portfolio.model.Transaction.Unit)75 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)58 BuySellEntry (name.abuchen.portfolio.model.BuySellEntry)51 Money (name.abuchen.portfolio.money.Money)51 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)50 Client (name.abuchen.portfolio.model.Client)50 IOException (java.io.IOException)44 Block (name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block)37 DocumentType (name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType)37 Transaction (name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction)37 BigDecimal (java.math.BigDecimal)32 Security (name.abuchen.portfolio.model.Security)26 Matcher (java.util.regex.Matcher)24 Pattern (java.util.regex.Pattern)24 CurrencyUnit (name.abuchen.portfolio.money.CurrencyUnit)24 Test (org.junit.Test)24 Map (java.util.Map)23 Values (name.abuchen.portfolio.money.Values)18 ArrayList (java.util.ArrayList)13 LocalDateTime (java.time.LocalDateTime)12