Search in sources :

Example 96 with BuySellEntryItem

use of name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem in project portfolio by buchen.

the class DABPDFExtractorTest method testWertpapierKauf3.

@Test
public void testWertpapierKauf3() throws IOException {
    DABPDFExtractor extractor = new DABPDFExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "DABKauf3.txt"), errors);
    assertThat(errors, empty());
    assertThat(results.size(), is(2));
    new AssertImportActions().check(results, CurrencyUnit.EUR);
    // check security
    Security security = getSecurity(results);
    assertThat(security.getIsin(), is("LU0635178014"));
    assertThat(security.getName(), is("ComSta.-MSCI Em.Mkts.TRN U.ETF Inhaber-Anteile I o.N."));
    assertThat(security.getCurrencyCode(), is(CurrencyUnit.EUR));
    // check buy sell transaction
    Optional<Item> item = results.stream().filter(i -> i instanceof BuySellEntryItem).findFirst();
    BuySellEntry entry = (BuySellEntry) item.get().getSubject();
    assertThat(entry.getPortfolioTransaction().getType(), is(PortfolioTransaction.Type.BUY));
    assertThat(entry.getPortfolioTransaction().getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 325_00)));
    assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2016-01-04T00:00")));
    assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(10.9468)));
    assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of(CurrencyUnit.EUR, 0L)));
}
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) 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) Unit(name.abuchen.portfolio.model.Transaction.Unit) DABPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.DABPDFExtractor) Optional(java.util.Optional) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) ArrayList(java.util.ArrayList) Security(name.abuchen.portfolio.model.Security) IOException(java.io.IOException) AssertImportActions(name.abuchen.portfolio.datatransfer.actions.AssertImportActions) DABPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.DABPDFExtractor) 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 97 with BuySellEntryItem

use of name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem in project portfolio by buchen.

the class DeutscheBankPDFExtractorTest method testWertpapierVerkauf.

@Test
public void testWertpapierVerkauf() throws IOException {
    DeutscheBankPDFExtractor extractor = new DeutscheBankPDFExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "DeutscheBankVerkauf.txt"), errors);
    assertThat(errors, empty());
    assertThat(results.size(), is(2));
    new AssertImportActions().check(results, CurrencyUnit.EUR);
    assertSecurity(results);
    // 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, Values.Amount.factorize(2074.71))));
    assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2015-04-08T00:00")));
    assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(61)));
    assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(122.94 + 6.76 + 1.23))));
    assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(7.90 + 0.60 + 2))));
}
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) IsCloseTo(org.hamcrest.number.IsCloseTo) 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) DeutscheBankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.DeutscheBankPDFExtractor) List(java.util.List) AssertImportActions(name.abuchen.portfolio.datatransfer.actions.AssertImportActions) Unit(name.abuchen.portfolio.model.Transaction.Unit) Optional(java.util.Optional) 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) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) DeutscheBankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.DeutscheBankPDFExtractor) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) ArrayList(java.util.ArrayList) Client(name.abuchen.portfolio.model.Client) IOException(java.io.IOException) AssertImportActions(name.abuchen.portfolio.datatransfer.actions.AssertImportActions) Test(org.junit.Test)

Example 98 with BuySellEntryItem

use of name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem in project portfolio by buchen.

the class DeutscheBankPDFExtractorTest method testWertpapierKauf2.

@Test
public void testWertpapierKauf2() throws IOException {
    DeutscheBankPDFExtractor extractor = new DeutscheBankPDFExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "DeutscheBankKauf2.txt"), errors);
    assertThat(errors, empty());
    assertThat(results.size(), is(2));
    new AssertImportActions().check(results, CurrencyUnit.EUR);
    assertSecurity(results);
    // 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, Values.Amount.factorize(3524.98))));
    assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2015-04-08T00:00")));
    assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(36)));
    assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of(CurrencyUnit.EUR, 11_38L)));
}
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) IsCloseTo(org.hamcrest.number.IsCloseTo) 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) DeutscheBankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.DeutscheBankPDFExtractor) List(java.util.List) AssertImportActions(name.abuchen.portfolio.datatransfer.actions.AssertImportActions) Unit(name.abuchen.portfolio.model.Transaction.Unit) Optional(java.util.Optional) 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) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) DeutscheBankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.DeutscheBankPDFExtractor) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) ArrayList(java.util.ArrayList) Client(name.abuchen.portfolio.model.Client) IOException(java.io.IOException) AssertImportActions(name.abuchen.portfolio.datatransfer.actions.AssertImportActions) Test(org.junit.Test)

Example 99 with BuySellEntryItem

use of name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem 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 100 with BuySellEntryItem

use of name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem in project portfolio by buchen.

the class UnicreditPDFExtractorTest method testWertpapierKauf1.

@Test
public void testWertpapierKauf1() throws IOException {
    UnicreditPDFExtractor extractor = new UnicreditPDFExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "UniCreditHypoVereinsbankWertpapierKauf1.txt"), errors);
    assertThat(errors, empty());
    assertThat(results.size(), is(2));
    new AssertImportActions().check(results, CurrencyUnit.EUR);
    Optional<Item> item;
    // get security
    item = results.stream().filter(i -> i instanceof SecurityItem).findFirst();
    assertThat(item.isPresent(), is(true));
    Security security = ((SecurityItem) item.get()).getSecurity();
    // assert security
    assertThat(security.getIsin(), is("FR0000120578"));
    assertThat(security.getWkn(), is("920657"));
    assertThat(security.getName(), is("SANOFI S.A."));
    assertThat(security.getCurrencyCode(), is(CurrencyUnit.EUR));
    // get transaction
    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();
    // assert transaction
    assertThat(entry.getAccountTransaction().getType(), is(AccountTransaction.Type.BUY));
    assertThat(entry.getPortfolioTransaction().getType(), is(PortfolioTransaction.Type.BUY));
    assertThat(entry.getPortfolioTransaction().getAmount(), is(Values.Amount.factorize(1560.83)));
    assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2016-02-17T00:00")));
    assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(13.57))));
    assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(22)));
}
Also used : SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) ArrayList(java.util.ArrayList) Security(name.abuchen.portfolio.model.Security) UnicreditPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.UnicreditPDFExtractor) 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) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) Client(name.abuchen.portfolio.model.Client) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)101 BuySellEntryItem (name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem)101 Item (name.abuchen.portfolio.datatransfer.Extractor.Item)101 SecurityItem (name.abuchen.portfolio.datatransfer.Extractor.SecurityItem)101 BuySellEntry (name.abuchen.portfolio.model.BuySellEntry)101 Client (name.abuchen.portfolio.model.Client)101 Security (name.abuchen.portfolio.model.Security)101 Test (org.junit.Test)101 IOException (java.io.IOException)99 TransactionItem (name.abuchen.portfolio.datatransfer.Extractor.TransactionItem)99 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)78 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)77 LocalDateTime (java.time.LocalDateTime)75 List (java.util.List)75 Optional (java.util.Optional)75 Unit (name.abuchen.portfolio.model.Transaction.Unit)75 Money (name.abuchen.portfolio.money.Money)75 Values (name.abuchen.portfolio.money.Values)75 CoreMatchers.instanceOf (org.hamcrest.CoreMatchers.instanceOf)75 CoreMatchers.is (org.hamcrest.CoreMatchers.is)75