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)));
}
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)));
}
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));
}
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))));
}
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)));
}
Aggregations