Search in sources :

Example 1 with SBrokerPDFExtractor

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

the class SBrokerPDFExtractorTest method testWertpapierVerkauf1.

@Test
public void testWertpapierVerkauf1() throws IOException {
    SBrokerPDFExtractor extractor = new SBrokerPDFExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "sBroker_Verkauf1.txt"), errors);
    assertThat(errors, empty());
    assertThat(results.size(), is(2));
    // check security
    Security security = results.stream().filter(i -> i instanceof SecurityItem).findFirst().get().getSecurity();
    assertThat(security.getIsin(), is("DE000A0H0785"));
    assertThat(security.getName(), is("iS.EO G.B.C.1.5-10.5y.U.ETF DE"));
    // check buy sell 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.SELL));
    assertThat(entry.getAccountTransaction().getType(), is(AccountTransaction.Type.SELL));
    assertThat(entry.getPortfolioTransaction().getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 5648_24)));
    assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2015-06-04T00:00")));
    assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(47)));
    assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of(CurrencyUnit.EUR, 821L)));
}
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) 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) SBrokerPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.SBrokerPDFExtractor) 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) Unit(name.abuchen.portfolio.model.Transaction.Unit) Optional(java.util.Optional) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) ArrayList(java.util.ArrayList) Security(name.abuchen.portfolio.model.Security) IOException(java.io.IOException) 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) SBrokerPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.SBrokerPDFExtractor) Client(name.abuchen.portfolio.model.Client) Test(org.junit.Test)

Example 2 with SBrokerPDFExtractor

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

the class SBrokerPDFExtractorTest method testErtragsgutschrift1.

@Test
public void testErtragsgutschrift1() throws IOException {
    SBrokerPDFExtractor extractor = new SBrokerPDFExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "sBroker_Ertragsgutschrift1.txt"), errors);
    assertThat(errors, empty());
    assertThat(results.size(), is(2));
    // check security
    Security security = results.stream().filter(i -> i instanceof SecurityItem).findFirst().get().getSecurity();
    assertThat(security.getIsin(), is("DE000A0H0785"));
    assertThat(security.getName(), is("iS.EO G.B.C.1.5-10.5y.U.ETF DE"));
    // check buy sell transaction
    AccountTransaction t = (AccountTransaction) results.stream().filter(i -> i instanceof TransactionItem).findFirst().get().getSubject();
    assertThat(t.getType(), is(AccountTransaction.Type.DIVIDENDS));
    assertThat(t.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 12_70)));
    assertThat(t.getDateTime(), is(LocalDateTime.parse("2014-11-17T00:00")));
    assertThat(t.getShares(), is(Values.Share.factorize(16)));
}
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) 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) SBrokerPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.SBrokerPDFExtractor) 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) Unit(name.abuchen.portfolio.model.Transaction.Unit) Optional(java.util.Optional) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) 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) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) ArrayList(java.util.ArrayList) SBrokerPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.SBrokerPDFExtractor) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Client(name.abuchen.portfolio.model.Client) Security(name.abuchen.portfolio.model.Security) IOException(java.io.IOException) Test(org.junit.Test)

Example 3 with SBrokerPDFExtractor

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

the class SBrokerPDFExtractorTest method testWertpapierKauf1.

@Test
public void testWertpapierKauf1() throws IOException {
    SBrokerPDFExtractor extractor = new SBrokerPDFExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "sBroker_Kauf1.txt"), errors);
    assertThat(errors, empty());
    assertThat(results.size(), is(2));
    // check security
    Security security = results.stream().filter(i -> i instanceof SecurityItem).findFirst().get().getSecurity();
    assertThat(security.getIsin(), is("DE000A0H0785"));
    assertThat(security.getName(), is("iS.EO G.B.C.1.5-10.5y.U.ETF DE"));
    // check buy sell 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, 1930_17)));
    assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2014-10-01T00:00")));
    assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(16)));
    assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of(CurrencyUnit.EUR, 377L)));
}
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) 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) SBrokerPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.SBrokerPDFExtractor) 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) Unit(name.abuchen.portfolio.model.Transaction.Unit) Optional(java.util.Optional) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) ArrayList(java.util.ArrayList) Security(name.abuchen.portfolio.model.Security) IOException(java.io.IOException) 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) SBrokerPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.SBrokerPDFExtractor) Client(name.abuchen.portfolio.model.Client) Test(org.junit.Test)

Example 4 with SBrokerPDFExtractor

use of name.abuchen.portfolio.datatransfer.pdf.SBrokerPDFExtractor 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

SBrokerPDFExtractor (name.abuchen.portfolio.datatransfer.pdf.SBrokerPDFExtractor)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 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 Unit (name.abuchen.portfolio.model.Transaction.Unit)3 CurrencyUnit (name.abuchen.portfolio.money.CurrencyUnit)3 Money (name.abuchen.portfolio.money.Money)3 Values (name.abuchen.portfolio.money.Values)3