Search in sources :

Example 61 with BuySellEntry

use of name.abuchen.portfolio.model.BuySellEntry in project portfolio by buchen.

the class BankSLMPDFExtractor method addSellTransaction.

@SuppressWarnings("nls")
private void addSellTransaction() {
    DocumentType type = new DocumentType("abrechnung - Verkauf");
    this.addDocumentTyp(type);
    Block block = new Block("B.rsenabrechnung - Verkauf");
    type.addBlock(block);
    Transaction<BuySellEntry> extractor = new Transaction<BuySellEntry>().subject(() -> {
        BuySellEntry entry = new BuySellEntry();
        entry.setType(PortfolioTransaction.Type.SELL);
        return entry;
    }).section("date", "shares", "name", "wkn", "currency").match(// 
    "Wir haben f.r Sie am (?<date>\\d+.\\d+.\\d{4}+) verkauft.").match(// 
    "^(?<shares>[\\d.']+) .*$").match(// 
    "^(?<name>.*)$").match(// 
    "^Valor: (?<wkn>[^ ]*)$").match(// 
    "Total Kurswert (?<currency>\\w{3}+) .*").assign((t, v) -> {
        t.setDate(asDate(v.get("date")));
        t.setShares(asShares(v.get("shares")));
        t.setSecurity(getOrCreateSecurity(v));
    }).section("amount", // 
    "currency").match(// 
    "Netto (?<currency>\\w{3}+) (?<amount>[\\d.']+)").assign((t, v) -> {
        t.setAmount(asAmount(v.get("amount")));
        t.setCurrencyCode(v.get("currency"));
    }).wrap(t -> new BuySellEntryItem(t));
    addForexGrossValue(extractor);
    addFeesSection(extractor);
    block.set(extractor);
}
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) Collectors(java.util.stream.Collectors) NumberFormat(java.text.NumberFormat) BigDecimal(java.math.BigDecimal) List(java.util.List) Transaction(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction) Unit(name.abuchen.portfolio.model.Transaction.Unit) Locale(java.util.Locale) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) ParseException(java.text.ParseException) 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 62 with BuySellEntry

use of name.abuchen.portfolio.model.BuySellEntry in project portfolio by buchen.

the class ComdirectPDFExtractor method addSellTransaction.

@SuppressWarnings("nls")
private void addSellTransaction() {
    DocumentType type = new DocumentType("Wertpapierverkauf");
    this.addDocumentTyp(type);
    Block block = new Block("^(\\* )?Wertpapierverkauf *.*");
    type.addBlock(block);
    Transaction<BuySellEntry> pdfTransaction = new Transaction<BuySellEntry>().subject(() -> {
        BuySellEntry entry = new BuySellEntry();
        entry.setType(PortfolioTransaction.Type.SELL);
        return entry;
    }).section(// 
    "date").match(// 
    "Geschäftstag *: (?<date>\\d+.\\d+.\\d{4}+) .*").assign((t, v) -> t.setDate(asDate(v.get("date")))).section("isin", "name", // 
    "wkn").find(// 
    "Wertpapier-Bezeichnung *WPKNR/ISIN *").match(// 
    "^(?<name>(\\S{1,} )*) *(?<wkn>\\S*) *$").match(// 
    "(\\S{1,} )* *(?<isin>\\S*) *$").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section("shares").optional().match(// 
    "^St\\. *(?<shares>[\\d.]+(,\\d+)?) .*").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section("shares").optional().match(// 
    "^ Summe *St\\. *(?<shares>[\\d.]+(,\\d+)?) .*").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section("amount", // 
    "currency").find(// 
    ".*Zu Ihren Gunsten vor Steuern *").match(// 
    ".* \\d+.\\d+.\\d{4}+ *(?<currency>\\w{3}+) *(?<amount>[\\d.]+,\\d+).*").assign((t, v) -> {
        t.setCurrencyCode(asCurrencyCode(v.get("currency")));
        t.setAmount(asAmount(v.get("amount")));
    }).section("tax").optional().match(// 
    "^a *b *g *e *f *ü *h *r *t *e *S *t *e *u *e *r *n *(?<tax>.*)$").assign((t, v) -> {
        Unit unit = createTaxUnit(v.get("tax"));
        if (unit == null || unit.getAmount().isZero())
            return;
        t.getPortfolioTransaction().addUnit(unit);
        MutableMoney total = MutableMoney.of(t.getPortfolioTransaction().getCurrencyCode());
        total.add(t.getPortfolioTransaction().getMonetaryAmount());
        total.subtract(unit.getAmount());
        t.setMonetaryAmount(total.toMoney());
    }).wrap(BuySellEntryItem::new);
    addFeesSection(pdfTransaction);
    block.set(pdfTransaction);
    addTaxRefunds(type, "^(\\* )?Wertpapierverkauf *.*");
}
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) Messages(name.abuchen.portfolio.Messages) MutableMoney(name.abuchen.portfolio.money.MutableMoney) Matcher(java.util.regex.Matcher) Transaction(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction) Unit(name.abuchen.portfolio.model.Transaction.Unit) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) Pattern(java.util.regex.Pattern) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) MutableMoney(name.abuchen.portfolio.money.MutableMoney) 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 63 with BuySellEntry

use of name.abuchen.portfolio.model.BuySellEntry in project portfolio by buchen.

the class CommerzbankPDFExtractor method addBuyTransaction.

private void addBuyTransaction() {
    DocumentType type = new DocumentType("W e r t p a p i e r k a u f");
    this.addDocumentTyp(type);
    Block block = new Block("W e r t p a p i e r k a u f");
    type.addBlock(block);
    block.set(new Transaction<BuySellEntry>().subject(() -> {
        BuySellEntry entry = new BuySellEntry();
        entry.setType(PortfolioTransaction.Type.BUY);
        return entry;
    }).section("amount", // 
    "currency").match(".*Zu I h r e n L a s t e n.*").match("^.* (\\d \\d . \\d \\d . \\d \\d \\d \\d) (?<currency>\\w{3}+)(?<amount>( \\d)*( \\.)?( \\d)* ,( \\d)*)$").assign((t, v) -> {
        t.setCurrencyCode(asCurrencyCode(v.get("currency")));
        t.setAmount(asAmount(stripBlanks(v.get("amount"))));
    }).section(// 
    "date").match("G e s c h ä f t s t a g : (?<date>\\d \\d . \\d \\d . \\d \\d \\d \\d) .*").assign((t, v) -> t.setDate(asDate(stripBlanks(v.get("date"))))).section(// 
    "shares").match("S t . (?<shares>[\\d ,.]*) .*").assign((t, v) -> t.setShares(asShares(stripBlanks(v.get("shares"))))).section("wkn", "name", "isin", "currency").match(".*W e r t p a p i e r - B e z e i c h n u n g.*").match("(?<name>.*) (?<wkn>\\S*)").match(// 
    "^IBAN.*$").match("^(?<isin>.*) (?<currency>\\w{3}+) (\\d \\d . \\d \\d . \\d \\d \\d \\d) (\\w{3}+)(( \\d)*( \\.)?( \\d)* ,( \\d)*)$").assign((t, v) -> {
        v.put("isin", stripBlanks(v.get("isin")));
        t.setSecurity(getOrCreateSecurity(v));
    }).wrap(BuySellEntryItem::new));
}
Also used : PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Client(name.abuchen.portfolio.model.Client) Block(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block) Transaction(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) DocumentType(name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType) IOException(java.io.IOException) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) DocumentType(name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType) Block(name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block)

Example 64 with BuySellEntry

use of name.abuchen.portfolio.model.BuySellEntry 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 65 with BuySellEntry

use of name.abuchen.portfolio.model.BuySellEntry 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)

Aggregations

BuySellEntry (name.abuchen.portfolio.model.BuySellEntry)169 Client (name.abuchen.portfolio.model.Client)150 IOException (java.io.IOException)141 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)125 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)125 Unit (name.abuchen.portfolio.model.Transaction.Unit)122 Money (name.abuchen.portfolio.money.Money)119 Security (name.abuchen.portfolio.model.Security)111 Test (org.junit.Test)108 ArrayList (java.util.ArrayList)107 Item (name.abuchen.portfolio.datatransfer.Extractor.Item)105 SecurityItem (name.abuchen.portfolio.datatransfer.Extractor.SecurityItem)105 BuySellEntryItem (name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem)104 TransactionItem (name.abuchen.portfolio.datatransfer.Extractor.TransactionItem)104 Values (name.abuchen.portfolio.money.Values)83 CurrencyUnit (name.abuchen.portfolio.money.CurrencyUnit)79 LocalDateTime (java.time.LocalDateTime)78 List (java.util.List)78 Optional (java.util.Optional)78 PDFInputFile (name.abuchen.portfolio.datatransfer.pdf.PDFInputFile)75