Search in sources :

Example 51 with BuySellEntry

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

the class ComdirectPDFExtractorTest method testWertpapierKauf2.

@Test
public void testWertpapierKauf2() throws IOException {
    ComdirectPDFExtractor extractor = new ComdirectPDFExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "comdirectWertpapierabrechnung_Kauf2.txt"), errors);
    assertThat(errors, empty());
    assertThat(results.size(), is(2));
    Optional<Item> item;
    // security
    item = results.stream().filter(i -> i instanceof SecurityItem).findFirst();
    assertThat(item.isPresent(), is(true));
    Security security = ((SecurityItem) item.get()).getSecurity();
    assertThat(security.getName(), is("ComSta foobar .ETF"));
    assertThat(security.getIsin(), is("LU1234444444"));
    assertThat(security.getWkn(), is("ETF999"));
    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().getAmount(), is(Values.Amount.factorize(1413.46)));
    assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2011-01-01T00:00")));
    assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("EUR", Values.Amount.factorize(13.6))));
    assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(42)));
}
Also used : 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) ComdirectPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.ComdirectPDFExtractor) 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 52 with BuySellEntry

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

the class ComdirectPDFExtractorTest method testWertpapierVerkauf2.

@Test
public void testWertpapierVerkauf2() throws IOException {
    ComdirectPDFExtractor extractor = new ComdirectPDFExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "comdirectWertpapierabrechnung_Verkauf2.txt"), errors);
    assertThat(errors, empty());
    assertThat(results.size(), is(2));
    Optional<Item> item;
    // security
    item = results.stream().filter(i -> i instanceof SecurityItem).findFirst();
    assertThat(item.isPresent(), is(true));
    Security security = ((SecurityItem) item.get()).getSecurity();
    assertThat(security.getName(), is("Boeing Co."));
    assertThat(security.getIsin(), is("US0970231058"));
    assertThat(security.getWkn(), is("850471"));
    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().getAmount(), is(Values.Amount.factorize(20413.33)));
    assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2016-12-08T00:00")));
    assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("EUR", Values.Amount.factorize(56.07))));
    assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(1140)));
}
Also used : 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) ComdirectPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.ComdirectPDFExtractor) 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 53 with BuySellEntry

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

the class CrossEntryCheckTest method testThatCorrectBuySellEntriesAreNotReported.

@Test
public void testThatCorrectBuySellEntriesAreNotReported() {
    BuySellEntry entry = new BuySellEntry(portfolio, account);
    entry.setType(PortfolioTransaction.Type.BUY);
    entry.setDate(LocalDateTime.now());
    entry.setSecurity(security);
    entry.setShares(1);
    entry.setCurrencyCode(CurrencyUnit.EUR);
    entry.setAmount(100);
    entry.insert();
    assertThat(new CrossEntryCheck().execute(client).size(), is(0));
}
Also used : BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) Test(org.junit.Test)

Example 54 with BuySellEntry

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

the class IBFlexStatementExtractorTest method assertFirstTransaction.

private void assertFirstTransaction(Optional<Item> item) {
    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().getSecurity().getName(), is("GRAN COLOMBIA GOLD CORP"));
    assertThat(entry.getPortfolioTransaction().getMonetaryAmount(), is(Money.of("CAD", 1356_75L)));
    assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2013-04-01T09:34")));
    assertThat(entry.getPortfolioTransaction().getShares(), is(5000_000000L));
    assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("CAD", 6_75L)));
    assertThat(entry.getPortfolioTransaction().getGrossPricePerShare(), is(Quote.of("CAD", Values.Quote.factorize(0.27))));
}
Also used : BuySellEntry(name.abuchen.portfolio.model.BuySellEntry)

Example 55 with BuySellEntry

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

the class IBFlexStatementExtractorTest method assertFourthTransaction.

private void assertFourthTransaction(Optional<Item> item) {
    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().getSecurity().getName(), is("URANIUM ONE INC."));
    assertThat(entry.getPortfolioTransaction().getMonetaryAmount(), is(Money.of("CAD", 232_00L)));
    assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2013-01-02T15:12")));
    assertThat(entry.getPortfolioTransaction().getShares(), is(100_000000L));
    assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("CAD", 1_00L)));
}
Also used : BuySellEntry(name.abuchen.portfolio.model.BuySellEntry)

Aggregations

BuySellEntry (name.abuchen.portfolio.model.BuySellEntry)169 Client (name.abuchen.portfolio.model.Client)150 IOException (java.io.IOException)141 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)125 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)125 Unit (name.abuchen.portfolio.model.Transaction.Unit)122 Money (name.abuchen.portfolio.money.Money)119 Security (name.abuchen.portfolio.model.Security)111 Test (org.junit.Test)108 ArrayList (java.util.ArrayList)107 Item (name.abuchen.portfolio.datatransfer.Extractor.Item)105 SecurityItem (name.abuchen.portfolio.datatransfer.Extractor.SecurityItem)105 BuySellEntryItem (name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem)104 TransactionItem (name.abuchen.portfolio.datatransfer.Extractor.TransactionItem)104 Values (name.abuchen.portfolio.money.Values)83 CurrencyUnit (name.abuchen.portfolio.money.CurrencyUnit)79 LocalDateTime (java.time.LocalDateTime)78 List (java.util.List)78 Optional (java.util.Optional)78 PDFInputFile (name.abuchen.portfolio.datatransfer.pdf.PDFInputFile)75