Search in sources :

Example 1 with CommerzbankPDFExtractor

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

the class CommerzbankPDFExtractorTest method testWertpapierkauf.

@Test
public void testWertpapierkauf() throws IOException {
    CommerzbankPDFExtractor extractor = new CommerzbankPDFExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "CommerzbankWertpapierkauf.txt"), errors);
    assertThat(errors, empty());
    assertThat(results.size(), is(2));
    new AssertImportActions().check(results, CurrencyUnit.EUR);
    // check security
    Security security = results.stream().filter(i -> i instanceof SecurityItem).findAny().get().getSecurity();
    assertThat(security.getName(), is("i S h s I I I - C o r e MSCI W o r l d U . E T F"));
    assertThat(security.getWkn(), is("A0RPWH"));
    assertThat(security.getCurrencyCode(), is(CurrencyUnit.EUR));
    // check transaction
    Optional<Item> item = results.stream().filter(i -> i instanceof BuySellEntryItem).findFirst();
    assertThat(item.isPresent(), is(true));
    assertThat(item.get().getSubject(), instanceOf(BuySellEntry.class));
    BuySellEntry entry = (BuySellEntry) item.get().getSubject();
    assertThat(entry.getPortfolioTransaction().getType(), is(PortfolioTransaction.Type.BUY));
    assertThat(entry.getAccountTransaction().getType(), is(AccountTransaction.Type.BUY));
    assertThat(entry.getPortfolioTransaction().getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(24.96))));
    assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2017-04-18T00:00")));
    assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(0.572)));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) Client(name.abuchen.portfolio.model.Client) Item(name.abuchen.portfolio.datatransfer.Extractor.Item) CommerzbankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.CommerzbankPDFExtractor) CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) LocalDateTime(java.time.LocalDateTime) IsEmptyCollection.empty(org.hamcrest.collection.IsEmptyCollection.empty) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) ArrayList(java.util.ArrayList) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) Assert.assertThat(org.junit.Assert.assertThat) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) PDFInputFile(name.abuchen.portfolio.datatransfer.pdf.PDFInputFile) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) IOException(java.io.IOException) Test(org.junit.Test) Security(name.abuchen.portfolio.model.Security) List(java.util.List) AssertImportActions(name.abuchen.portfolio.datatransfer.actions.AssertImportActions) Optional(java.util.Optional) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) ArrayList(java.util.ArrayList) CommerzbankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.CommerzbankPDFExtractor) Security(name.abuchen.portfolio.model.Security) IOException(java.io.IOException) AssertImportActions(name.abuchen.portfolio.datatransfer.actions.AssertImportActions) Item(name.abuchen.portfolio.datatransfer.Extractor.Item) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) Client(name.abuchen.portfolio.model.Client) Test(org.junit.Test)

Example 2 with CommerzbankPDFExtractor

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

the class CommerzbankPDFExtractorTest method testErtragsgutschrift.

@Test
public void testErtragsgutschrift() throws IOException {
    CommerzbankPDFExtractor extractor = new CommerzbankPDFExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "CommerzbankErtragsgutschrift.txt"), errors);
    assertThat(errors, empty());
    assertThat(results.size(), is(2));
    new AssertImportActions().check(results, CurrencyUnit.EUR);
    // check security
    Security security = results.stream().filter(i -> i instanceof SecurityItem).findAny().get().getSecurity();
    assertThat(security.getName(), is("iShs-MSCI N . America UCITS ETF"));
    assertThat(security.getIsin(), is("DE000A0J2060"));
    assertThat(security.getWkn(), is("A0J206"));
    assertThat(security.getCurrencyCode(), is(CurrencyUnit.EUR));
    // check transaction
    Optional<Item> item = results.stream().filter(i -> i instanceof TransactionItem).findFirst();
    assertThat(item.isPresent(), is(true));
    assertThat(item.get().getSubject(), instanceOf(AccountTransaction.class));
    AccountTransaction transaction = (AccountTransaction) item.get().getSubject();
    assertThat(transaction.getType(), is(AccountTransaction.Type.DIVIDENDS));
    assertThat(transaction.getSecurity(), is(security));
    assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2015-06-22T00:00")));
    assertThat(transaction.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 223_45L)));
    assertThat(transaction.getShares(), is(Values.Share.factorize(123)));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) Client(name.abuchen.portfolio.model.Client) Item(name.abuchen.portfolio.datatransfer.Extractor.Item) CommerzbankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.CommerzbankPDFExtractor) CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) LocalDateTime(java.time.LocalDateTime) IsEmptyCollection.empty(org.hamcrest.collection.IsEmptyCollection.empty) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) ArrayList(java.util.ArrayList) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) Assert.assertThat(org.junit.Assert.assertThat) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) PDFInputFile(name.abuchen.portfolio.datatransfer.pdf.PDFInputFile) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) IOException(java.io.IOException) Test(org.junit.Test) Security(name.abuchen.portfolio.model.Security) List(java.util.List) AssertImportActions(name.abuchen.portfolio.datatransfer.actions.AssertImportActions) Optional(java.util.Optional) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) ArrayList(java.util.ArrayList) CommerzbankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.CommerzbankPDFExtractor) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Security(name.abuchen.portfolio.model.Security) IOException(java.io.IOException) AssertImportActions(name.abuchen.portfolio.datatransfer.actions.AssertImportActions) Item(name.abuchen.portfolio.datatransfer.Extractor.Item) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) Client(name.abuchen.portfolio.model.Client) Test(org.junit.Test)

Example 3 with CommerzbankPDFExtractor

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

the class CommerzbankPDFExtractorTest method testErtragsgutschrift2.

@Test
public void testErtragsgutschrift2() throws IOException {
    CommerzbankPDFExtractor extractor = new CommerzbankPDFExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "CommerzbankErtragsgutschrift2.txt"), errors);
    assertThat(errors, empty());
    assertThat(results.size(), is(2));
    new AssertImportActions().check(results, CurrencyUnit.EUR);
    // check security
    Security security = results.stream().filter(i -> i instanceof SecurityItem).findAny().get().getSecurity();
    assertThat(security.getName(), is("iShares-MSCI Japan UETF DIS"));
    assertThat(security.getIsin(), is("DE000A0DPMW9"));
    assertThat(security.getWkn(), is("A0DPMW"));
    assertThat(security.getCurrencyCode(), is(CurrencyUnit.EUR));
    // check transaction
    Optional<Item> item = results.stream().filter(i -> i instanceof TransactionItem).findFirst();
    assertThat(item.isPresent(), is(true));
    assertThat(item.get().getSubject(), instanceOf(AccountTransaction.class));
    AccountTransaction transaction = (AccountTransaction) item.get().getSubject();
    assertThat(transaction.getType(), is(AccountTransaction.Type.DIVIDENDS));
    assertThat(transaction.getSecurity(), is(security));
    assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2015-07-20T00:00")));
    assertThat(transaction.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 1045_67L)));
    assertThat(transaction.getShares(), is(Values.Share.factorize(1234)));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) Client(name.abuchen.portfolio.model.Client) Item(name.abuchen.portfolio.datatransfer.Extractor.Item) CommerzbankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.CommerzbankPDFExtractor) CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) LocalDateTime(java.time.LocalDateTime) IsEmptyCollection.empty(org.hamcrest.collection.IsEmptyCollection.empty) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) ArrayList(java.util.ArrayList) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) Assert.assertThat(org.junit.Assert.assertThat) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) PDFInputFile(name.abuchen.portfolio.datatransfer.pdf.PDFInputFile) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) IOException(java.io.IOException) Test(org.junit.Test) Security(name.abuchen.portfolio.model.Security) List(java.util.List) AssertImportActions(name.abuchen.portfolio.datatransfer.actions.AssertImportActions) Optional(java.util.Optional) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) ArrayList(java.util.ArrayList) CommerzbankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.CommerzbankPDFExtractor) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Security(name.abuchen.portfolio.model.Security) IOException(java.io.IOException) AssertImportActions(name.abuchen.portfolio.datatransfer.actions.AssertImportActions) Item(name.abuchen.portfolio.datatransfer.Extractor.Item) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) Client(name.abuchen.portfolio.model.Client) Test(org.junit.Test)

Example 4 with CommerzbankPDFExtractor

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

the class ImportExtractedItemsWizard method addDefaultExtractors.

private void addDefaultExtractors() throws IOException {
    extractors.add(new BaaderBankPDFExtractor(client));
    extractors.add(new BankSLMPDFExtractor(client));
    extractors.add(new ComdirectPDFExtractor(client));
    extractors.add(new CommerzbankPDFExtractor(client));
    extractors.add(new ConsorsbankPDFExtractor(client));
    extractors.add(new DABPDFExtractor(client));
    extractors.add(new DegiroPDFExtractor(client));
    extractors.add(new DeutscheBankPDFExtractor(client));
    extractors.add(new DkbPDFExtractor(client));
    extractors.add(new FinTechGroupBankPDFExtractor(client));
    extractors.add(new INGDiBaExtractor(client));
    extractors.add(new OnvistaPDFExtractor(client));
    extractors.add(new SBrokerPDFExtractor(client));
    extractors.add(new UnicreditPDFExtractor(client));
    extractors.add(new HelloBankPDFExtractor(client));
    Collections.sort(extractors, (r, l) -> r.getLabel().compareToIgnoreCase(l.getLabel()));
}
Also used : ConsorsbankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.ConsorsbankPDFExtractor) FinTechGroupBankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.FinTechGroupBankPDFExtractor) CommerzbankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.CommerzbankPDFExtractor) DegiroPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.DegiroPDFExtractor) UnicreditPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.UnicreditPDFExtractor) BankSLMPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.BankSLMPDFExtractor) DABPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.DABPDFExtractor) DkbPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.DkbPDFExtractor) OnvistaPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.OnvistaPDFExtractor) BaaderBankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.BaaderBankPDFExtractor) DeutscheBankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.DeutscheBankPDFExtractor) ComdirectPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.ComdirectPDFExtractor) INGDiBaExtractor(name.abuchen.portfolio.datatransfer.pdf.INGDiBaExtractor) HelloBankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.HelloBankPDFExtractor) SBrokerPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.SBrokerPDFExtractor)

Aggregations

CommerzbankPDFExtractor (name.abuchen.portfolio.datatransfer.pdf.CommerzbankPDFExtractor)4 IOException (java.io.IOException)3 LocalDateTime (java.time.LocalDateTime)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Optional (java.util.Optional)3 BuySellEntryItem (name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem)3 Item (name.abuchen.portfolio.datatransfer.Extractor.Item)3 SecurityItem (name.abuchen.portfolio.datatransfer.Extractor.SecurityItem)3 TransactionItem (name.abuchen.portfolio.datatransfer.Extractor.TransactionItem)3 AssertImportActions (name.abuchen.portfolio.datatransfer.actions.AssertImportActions)3 PDFInputFile (name.abuchen.portfolio.datatransfer.pdf.PDFInputFile)3 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)3 BuySellEntry (name.abuchen.portfolio.model.BuySellEntry)3 Client (name.abuchen.portfolio.model.Client)3 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)3 Security (name.abuchen.portfolio.model.Security)3 CurrencyUnit (name.abuchen.portfolio.money.CurrencyUnit)3 Money (name.abuchen.portfolio.money.Money)3 Values (name.abuchen.portfolio.money.Values)3