Search in sources :

Example 16 with Client

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

the class INGDiBaPDFExtractorTest method testDividendengutschrift1.

@Test
public void testDividendengutschrift1() throws IOException {
    INGDiBaExtractor extractor = new INGDiBaExtractor(new Client());
    List<Exception> errors = new ArrayList<>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "INGDiBa_Dividendengutschrift1.txt"), errors);
    assertThat(errors, empty());
    assertThat(results.size(), is(2));
    Security security = results.stream().filter(i -> i instanceof SecurityItem).findFirst().get().getSecurity();
    assertThat(security.getIsin(), is("US5801351017"));
    assertThat(security.getWkn(), is("856958"));
    assertThat(security.getName(), is("McDonald's Corp."));
    AccountTransaction t = (AccountTransaction) results.stream().filter(i -> i instanceof TransactionItem).findFirst().get().getSubject();
    assertThat(t.getType(), is(AccountTransaction.Type.DIVIDENDS));
    assertThat(t.getAmount(), is(Values.Amount.factorize(44.01)));
    assertThat(t.getDateTime(), is(LocalDateTime.parse("2016-11-29T00:00")));
    assertThat(t.getShares(), is(Values.Share.factorize(66)));
    assertThat(t.getGrossValue(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(50.24 + 8.87))));
    assertThat(t.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(5.91 + 0.32 + 8.87))));
}
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) INGDiBaExtractor(name.abuchen.portfolio.datatransfer.pdf.INGDiBaExtractor) 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) 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) INGDiBaExtractor(name.abuchen.portfolio.datatransfer.pdf.INGDiBaExtractor) ArrayList(java.util.ArrayList) 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 17 with Client

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

the class INGDiBaPDFExtractorTest method testDividendengutschrift2.

@Test
public void testDividendengutschrift2() throws IOException {
    INGDiBaExtractor extractor = new INGDiBaExtractor(new Client());
    List<Exception> errors = new ArrayList<>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "INGDiBa_Dividendengutschrift2.txt"), errors);
    assertThat(errors, empty());
    assertThat(results.size(), is(2));
    Security security = results.stream().filter(i -> i instanceof SecurityItem).findFirst().get().getSecurity();
    assertThat(security.getIsin(), is("DE000A0H0744"));
    assertThat(security.getWkn(), is("A0H074"));
    assertThat(security.getName(), is("iSh.DJ Asia Pa.S.D.30 U.ETF DE"));
    AccountTransaction t = (AccountTransaction) results.stream().filter(i -> i instanceof TransactionItem).findFirst().get().getSubject();
    assertThat(t.getType(), is(AccountTransaction.Type.DIVIDENDS));
    assertThat(t.getAmount(), is(Values.Amount.factorize(234.92)));
    assertThat(t.getDateTime(), is(LocalDateTime.parse("2016-12-15T00:00")));
    assertThat(t.getShares(), is(Values.Share.factorize(694)));
    assertThat(t.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(65.1 + 3.58))));
    assertThat(t.getGrossValue(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(303.60))));
}
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) INGDiBaExtractor(name.abuchen.portfolio.datatransfer.pdf.INGDiBaExtractor) 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) 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) INGDiBaExtractor(name.abuchen.portfolio.datatransfer.pdf.INGDiBaExtractor) ArrayList(java.util.ArrayList) 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 18 with Client

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

the class INGDiBaPDFExtractorTest method testWertpapierVerkauf3.

@Test
public void testWertpapierVerkauf3() throws IOException {
    INGDiBaExtractor extractor = new INGDiBaExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "INGDiBa_Verkauf3.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("US0378331005"));
    assertThat(security.getWkn(), is("865985"));
    assertThat(security.getName(), is("Apple Inc. Registered Shares o.N."));
    // check buy sell transaction
    BuySellEntry entry = (BuySellEntry) results.stream().filter(i -> i instanceof BuySellEntryItem).findFirst().get().getSubject();
    assertThat(entry.getPortfolioTransaction().getType(), is(PortfolioTransaction.Type.SELL));
    assertThat(entry.getAccountTransaction().getType(), is(AccountTransaction.Type.SELL));
    assertThat(entry.getPortfolioTransaction().getAmount(), is(Values.Amount.factorize(3421.66)));
    assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2013-06-21T00:00")));
    assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(11)));
    assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("EUR", 9_90L)));
    assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.TAX), is(Money.of("EUR", 0)));
}
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) INGDiBaExtractor(name.abuchen.portfolio.datatransfer.pdf.INGDiBaExtractor) 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) 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) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) INGDiBaExtractor(name.abuchen.portfolio.datatransfer.pdf.INGDiBaExtractor) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) ArrayList(java.util.ArrayList) Client(name.abuchen.portfolio.model.Client) Security(name.abuchen.portfolio.model.Security) IOException(java.io.IOException) Test(org.junit.Test)

Example 19 with Client

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

the class INGDiBaPDFExtractorTest method testWertpapierKauf4.

@Test
public void testWertpapierKauf4() throws IOException {
    INGDiBaExtractor extractor = new INGDiBaExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "INGDiBa_Kauf4.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("DE000A0F5UF5"));
    assertThat(security.getWkn(), is("A0F5UF"));
    assertThat(security.getName(), is("iShare.NASDAQ-100 UCITS ETF DE"));
    // check buy sell transaction
    BuySellEntry entry = (BuySellEntry) results.stream().filter(i -> i instanceof BuySellEntryItem).findFirst().get().getSubject();
    assertThat(entry.getPortfolioTransaction().getType(), is(PortfolioTransaction.Type.BUY));
    assertThat(entry.getAccountTransaction().getType(), is(AccountTransaction.Type.BUY));
    assertThat(entry.getPortfolioTransaction().getAmount(), is(Values.Amount.factorize(50)));
    assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2015-12-15T00:00")));
    assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(1.19591)));
    assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("EUR", 86L)));
}
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) INGDiBaExtractor(name.abuchen.portfolio.datatransfer.pdf.INGDiBaExtractor) 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) 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) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) INGDiBaExtractor(name.abuchen.portfolio.datatransfer.pdf.INGDiBaExtractor) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) ArrayList(java.util.ArrayList) Client(name.abuchen.portfolio.model.Client) Security(name.abuchen.portfolio.model.Security) IOException(java.io.IOException) Test(org.junit.Test)

Example 20 with Client

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

the class INGDiBaPDFExtractorTest method testErtragsgutschrift1.

@Test
public void testErtragsgutschrift1() throws IOException {
    INGDiBaExtractor extractor = new INGDiBaExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "INGDiBa_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("DE0002635307"));
    assertThat(security.getWkn(), is("263530"));
    assertThat(security.getName(), is("iSh.STOXX Europe 600 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.getAmount(), is(Values.Amount.factorize(6.70)));
    assertThat(t.getDateTime(), is(LocalDateTime.parse("2015-09-15T00:00")));
    assertThat(t.getShares(), is(Values.Share.factorize(18)));
}
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) INGDiBaExtractor(name.abuchen.portfolio.datatransfer.pdf.INGDiBaExtractor) 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) 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) INGDiBaExtractor(name.abuchen.portfolio.datatransfer.pdf.INGDiBaExtractor) ArrayList(java.util.ArrayList) 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)

Aggregations

Client (name.abuchen.portfolio.model.Client)352 Test (org.junit.Test)315 Security (name.abuchen.portfolio.model.Security)285 ArrayList (java.util.ArrayList)268 Item (name.abuchen.portfolio.datatransfer.Extractor.Item)230 SecurityItem (name.abuchen.portfolio.datatransfer.Extractor.SecurityItem)230 IOException (java.io.IOException)221 TransactionItem (name.abuchen.portfolio.datatransfer.Extractor.TransactionItem)220 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)218 BuySellEntryItem (name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem)204 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)204 BuySellEntry (name.abuchen.portfolio.model.BuySellEntry)198 List (java.util.List)195 Money (name.abuchen.portfolio.money.Money)195 Values (name.abuchen.portfolio.money.Values)195 CoreMatchers.is (org.hamcrest.CoreMatchers.is)194 Assert.assertThat (org.junit.Assert.assertThat)194 LocalDateTime (java.time.LocalDateTime)193 CurrencyUnit (name.abuchen.portfolio.money.CurrencyUnit)187 Unit (name.abuchen.portfolio.model.Transaction.Unit)174