Esempio n. 1
0
  private void addBuyTransaction() {
    DocumentType type = new DocumentType("Wir haben für Sie gekauft");
    this.addDocumentTyp(type);

    Block block = new Block("Wir haben für Sie gekauft(.*)");
    type.addBlock(block);

    Transaction<BuySellEntry> pdfTransaction = new Transaction<BuySellEntry>();
    pdfTransaction.subject(
        () -> {
          BuySellEntry entry = new BuySellEntry();
          entry.setType(PortfolioTransaction.Type.BUY);
          return entry;
        });

    block.set(pdfTransaction);
    pdfTransaction
        .section("name", "isin") //
        .find("Gattungsbezeichnung ISIN") //
        .match("(?<name>.*) (?<isin>[^ ]\\S*)$") //
        .assign(
            (t, v) -> {
              t.setSecurity(getOrCreateSecurity(v));
            })
        .section("notation", "shares") //
        .find("Nominal Kurs") //
        .match("(?<notation>^\\w{3}+) (?<shares>\\d{1,3}(\\.\\d{3})*(,\\d{3})?)(.*)") //
        .assign(
            (t, v) -> {
              String notation = v.get("notation");
              if (notation != null && !notation.equalsIgnoreCase("STK")) {
                // Prozent-Notierung, Workaround..
                t.setShares((asShares(v.get("shares")) / 100));
              } else {
                t.setShares(asShares(v.get("shares")));
              }
            })
        .section("date", "amount", "currency") //
        .find("Wert(\\s+)Konto-Nr. Betrag zu Ihren Lasten(\\s*)$")
        // 14.01.2015 172305047 EUR 59,55
        // Wert Konto-Nr. Betrag zu Ihren Lasten
        // 01.06.2011 172305047 EUR 6,40
        .match(
            "(?<date>\\d+.\\d+.\\d{4}+) (\\d{6,12}) (?<currency>\\w{3}+) (?<amount>\\d{1,3}(\\.\\d{3})*(,\\d{2})?)$")
        .assign(
            (t, v) -> {
              t.setDate(asDate(v.get("date")));
              t.setAmount(asAmount(v.get("amount")));
              t.setCurrencyCode(asCurrencyCode(v.get("currency")));
            })
        .wrap(t -> new BuySellEntryItem(t));
    addFeesSections(pdfTransaction);
  }
Esempio n. 2
0
  @Test
  public void testThatCorrectBuySellEntriesAreNotReported() {
    BuySellEntry entry = new BuySellEntry(portfolio, account);
    entry.setType(PortfolioTransaction.Type.BUY);
    entry.setDate(Dates.today());
    entry.setSecurity(security);
    entry.setShares(1);
    entry.setAmount(100);
    entry.insert();

    assertThat(new CrossEntryCheck().execute(client).size(), is(0));
  }
    @Override
    public void execute() {
      BuySellEntry entry = new BuySellEntry(portfolio, account);
      entry.setDate(transaction.getDate());
      entry.setType(PortfolioTransaction.Type.valueOf(transaction.getType().name()));
      entry.setSecurity(transaction.getSecurity());
      entry.setShares(Values.Share.factor());
      entry.setAmount(transaction.getAmount());
      entry.setCurrencyCode(transaction.getCurrencyCode());
      entry.insert();

      account.getTransactions().remove(transaction);
    }
Esempio n. 4
0
  private void addPayingTransaction() {
    DocumentType type = new DocumentType("Gutschriftsanzeige");
    this.addDocumentTyp(type);

    Block block = new Block("Gutschriftsanzeige(.*)");
    type.addBlock(block);

    Transaction<BuySellEntry> pdfTransaction = new Transaction<BuySellEntry>();
    pdfTransaction.subject(
        () -> {
          BuySellEntry entry = new BuySellEntry();
          entry.setType(PortfolioTransaction.Type.SELL);
          return entry;
        });

    block.set(pdfTransaction);
    pdfTransaction
        .section("name", "isin") //
        .find("Gattungsbezeichnung (.*) ISIN") //
        .match("(?<name>.*) (.*) (?<isin>[^ ]\\S*)$") //
        .assign(
            (t, v) -> {
              t.setSecurity(getOrCreateSecurity(v));
            })
        .section("notation", "shares") //
        .find("Nominal Einlösung(.*)$") //
        .match("(?<notation>^\\w{3}+) (?<shares>\\d{1,3}(\\.\\d{3})*(,\\d{3})?)(.*)$")
        .assign(
            (t, v) -> {
              String notation = v.get("notation");
              if (notation != null && !notation.equalsIgnoreCase("STK")) {
                // Prozent-Notierung, Workaround..
                t.setShares((asShares(v.get("shares")) / 100));
              } else {
                t.setShares(asShares(v.get("shares")));
              }
            })
        .section("date", "amount", "currency") //
        .find("Wert(\\s+)Konto-Nr. Betrag zu Ihren Gunsten$")
        // 17.11.2014 172305047 EUR 51,85
        .match(
            "(?<date>\\d+.\\d+.\\d{4}+) (\\d{6,12}) (?<currency>\\w{3}+) (?<amount>\\d{1,3}(\\.\\d{3})*(,\\d{2})?)")
        .assign(
            (t, v) -> {
              t.setDate(asDate(v.get("date")));
              t.setAmount(asAmount(v.get("amount")));
              t.setCurrencyCode(asCurrencyCode(v.get("currency")));
            })
        .wrap(t -> new BuySellEntryItem(t));
    addTaxesSectionsBuySell(pdfTransaction);
  }
Esempio n. 5
0
  private void addTransferInTransaction() {
    DocumentType type = new DocumentType("Wir erhielten zu Gunsten Ihres Depots");
    this.addDocumentTyp(type);

    Block block = new Block("Wir erhielten zu Gunsten Ihres Depots(.*)");
    type.addBlock(block);

    Transaction<BuySellEntry> pdfTransaction = new Transaction<BuySellEntry>();
    pdfTransaction.subject(
        () -> {
          BuySellEntry entry = new BuySellEntry();
          entry.setType(PortfolioTransaction.Type.TRANSFER_IN);
          return entry;
        });

    block.set(pdfTransaction);
    pdfTransaction
        .section("name", "isin") //
        .find("Gattungsbezeichnung ISIN") //
        .match("(?<name>.*) (?<isin>[^ ]\\S*)$") //
        .assign(
            (t, v) -> {
              t.setSecurity(getOrCreateSecurity(v));
            })
        .section("notation", "shares", "date") //
        .find("Nominal Schlusstag Wert")
        // STK 28,000 02.12.2011 02.12.2011
        .match(
            "(?<notation>^\\w{3}+) (?<shares>\\d{1,3}(\\.\\d{3})*(,\\d{3})?) (\\d+.\\d+.\\d{4}+) (?<date>\\d+.\\d+.\\d{4}+)(.*)")
        .assign(
            (t, v) -> {
              String notation = v.get("notation");
              if (notation != null && !notation.equalsIgnoreCase("STK")) {
                // Prozent-Notierung, Workaround..
                t.setShares((asShares(v.get("shares")) / 100));
              } else {
                t.setShares(asShares(v.get("shares")));
              }
              t.setDate(asDate(v.get("date")));
              t.setCurrencyCode(
                  asCurrencyCode(t.getPortfolioTransaction().getSecurity().getCurrencyCode()));
            })
        .wrap(t -> new BuySellEntryItem(t));
    addFeesSections(pdfTransaction);
  }
Esempio n. 6
0
  private void addDividendTransaction() {
    DocumentType type = new DocumentType("Erträgnisgutschrift");
    this.addDocumentTyp(type);

    // Erträgnisgutschrift allein ist nicht gut hier, da es schon in der
    // Kopfzeile steht..
    Block block =
        new Block(
            "Dividendengutschrift.*|Kupongutschrift.*|Erträgnisgutschrift.*(\\d+.\\d+.\\d{4})");
    type.addBlock(block);

    Transaction<AccountTransaction> pdfTransaction = new Transaction<AccountTransaction>();
    pdfTransaction.subject(
        () -> {
          AccountTransaction transaction = new AccountTransaction();
          transaction.setType(AccountTransaction.Type.DIVIDENDS);
          return transaction;
        });

    block.set(pdfTransaction);
    pdfTransaction
        .section("name", "isin") //
        .find("Gattungsbezeichnung(.*) ISIN")
        // Commerzbank AG Inhaber-Aktien o.N. DE000CBK1001
        // 5,5% TUI AG Wandelanl.v.2009(2014) 17.11.2014
        // 17.11.2010 DE000TUAG117
        .match("(?<name>.*?) (\\d+.\\d+.\\d{4} ){0,2}(?<isin>[^ ]\\S*)$") //
        .assign(
            (t, v) -> {
              t.setSecurity(getOrCreateSecurity(v));
            })
        .section("notation", "shares", "date", "amount", "currency")
        // .find("Nominal (Ex-Tag )?Zahltag (.*etrag pro
        // .*)?(Zinssatz.*)?")
        // STK 25,000 17.05.2013 17.05.2013 EUR 0,700000
        // Leistungen aus dem steuerlichen Einlagenkonto (§27
        // KStG) EUR 17,50
        .match(
            "(?<notation>^\\w{3}+) (?<shares>\\d{1,3}(\\.\\d{3})*(,\\d{3})?) (\\d+.\\d+.\\d{4}+) (?<date>\\d+.\\d+.\\d{4}+)?(.*)")
        .match(
            "(?<date>\\d+.\\d+.\\d{4}+)?(\\d{6,12})?(.{7,58} )?(?<currency>\\w{3}+) (?<amount>\\d{1,3}(\\.\\d{3})*(,\\d{2})?)")
        .assign(
            (t, v) -> {
              String notation = v.get("notation");
              if (notation != null && !notation.equalsIgnoreCase("STK")) {
                // Prozent-Notierung, Workaround..
                t.setShares((asShares(v.get("shares")) / 100));
              } else {
                t.setShares(asShares(v.get("shares")));
              }
              t.setDate(asDate(v.get("date")));
              t.setAmount(asAmount(v.get("amount")));
              t.setCurrencyCode(asCurrencyCode(v.get("currency")));
            })
        .wrap(t -> new TransactionItem(t));

    addTaxesSectionsAccount(pdfTransaction);

    // optional: Reinvestierung in:
    block = new Block("Reinvestierung.*");
    type.addBlock(block);
    block.set(
        new Transaction<BuySellEntry>()
            .subject(
                () -> {
                  BuySellEntry entry = new BuySellEntry();
                  entry.setType(PortfolioTransaction.Type.BUY);
                  return entry;
                })
            .section("date")
            .match(
                "(^\\w{3}+) (\\d{1,3}(\\.\\d{3})*(,\\d{3})?) (\\d+.\\d+.\\d{4}+) (?<date>\\d+.\\d+.\\d{4}+)?(.*)")
            .assign((t, v) -> t.setDate(asDate(v.get("date"))))
            .section("name", "isin") //
            .find("Die Dividende wurde wie folgt in neue Aktien reinvestiert:")
            .find("Gattungsbezeichnung ISIN") //
            .match("(?<name>.*) (?<isin>[^ ]\\S*)$") //
            .assign(
                (t, v) -> {
                  t.setSecurity(getOrCreateSecurity(v));
                })
            .section("notation", "shares", "amount", "currency") //
            .find("Nominal Reinvestierungspreis")
            // STK 25,000 EUR 0,700000
            .match(
                "(?<notation>^\\w{3}+) (?<shares>\\d{1,3}(\\.\\d{3})*(,\\d{3})?) (?<currency>\\w{3}+) (?<amount>\\d{1,3}(\\.\\d{3})*(,\\d{2})?)(.*)")
            .assign(
                (t, v) -> {
                  String notation = v.get("notation");
                  if (notation != null && !notation.equalsIgnoreCase("STK")) {
                    // Prozent-Notierung, Workaround..
                    t.setShares((asShares(v.get("shares")) / 100));
                  } else {
                    t.setShares(asShares(v.get("shares")));
                  }
                  t.setCurrencyCode(asCurrencyCode(v.get("currency")));
                })
            .wrap(t -> new BuySellEntryItem(t)));
  }