use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem in project portfolio by buchen.
the class ComdirectPDFExtractorTest method testDividende3.
@Test
public void testDividende3() throws IOException {
ComdirectPDFExtractor extractor = new ComdirectPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "comdirectDividende3.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
// security
Optional<Item> item = results.stream().filter(i -> i instanceof SecurityItem).findFirst();
assertThat(item.isPresent(), is(true));
Security security = ((SecurityItem) item.get()).getSecurity();
assertThat(security.getIsin(), is("US1266501006"));
assertThat(security.getName(), is("C V S He a lt h C or p ."));
assertThat(security.getWkn(), is("859034"));
item = results.stream().filter(i -> i instanceof TransactionItem).findFirst();
assertThat(item.isPresent(), is(true));
assertThat(item.get().getSubject(), instanceOf(AccountTransaction.class));
AccountTransaction transaction = (AccountTransaction) item.get().getSubject();
assertThat(transaction.getType(), is(AccountTransaction.Type.DIVIDENDS));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2017-11-07T00:00")));
assertThat(transaction.getSecurity(), is(security));
assertThat(transaction.getAmount(), is(Values.Amount.factorize(11.65)));
assertThat(transaction.getShares(), is(Values.Share.factorize(32)));
}
use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem in project portfolio by buchen.
the class ComdirectPDFExtractorTest method testDividende3withTax.
@Test
public void testDividende3withTax() throws IOException {
ComdirectPDFExtractor extractor = new ComdirectPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "comdirectDividende3.txt", "comdirectDividende3_Steuer.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(3));
// security
Optional<Item> item = results.stream().filter(i -> i instanceof SecurityItem).findFirst();
assertThat(item.isPresent(), is(true));
Security security = ((SecurityItem) item.get()).getSecurity();
assertThat(security.getIsin(), is("US1266501006"));
assertThat(security.getName(), is("C V S He a lt h C or p ."));
assertThat(security.getWkn(), is("859034"));
List<AccountTransaction> items = results.stream().filter(i -> i instanceof TransactionItem && i.getSubject() instanceof AccountTransaction).map(i -> (AccountTransaction) i.getSubject()).collect(Collectors.toList());
assertThat(items.size(), is(2));
// dividend
Optional<AccountTransaction> oTransaction = items.stream().filter(t -> AccountTransaction.Type.DIVIDENDS.equals(t.getType())).findFirst();
assertThat(oTransaction.isPresent(), is(true));
AccountTransaction transaction = oTransaction.get();
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2017-11-07T00:00")));
assertThat(transaction.getSecurity(), is(security));
assertThat(transaction.getAmount(), is(Values.Amount.factorize(11.65)));
assertThat(transaction.getShares(), is(Values.Share.factorize(32)));
// tax
oTransaction = items.stream().filter(t -> AccountTransaction.Type.TAXES.equals(t.getType())).findFirst();
assertThat(oTransaction.isPresent(), is(true));
transaction = oTransaction.get();
assertThat(transaction.getShares(), is(Values.Share.factorize(32)));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2017-11-07T00:00")));
assertThat(transaction.getUnitSum(Type.TAX), is(Money.of("EUR", 1_37 + 7)));
assertThat(transaction.getAmount(), is(Values.Amount.factorize(1.44)));
}
use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem in project portfolio by buchen.
the class ComdirectPDFExtractorTest method testGutschrift5.
@Test
public void testGutschrift5() throws IOException {
ComdirectPDFExtractor extractor = new ComdirectPDFExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "comdirectGutschrift5.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
// security
Optional<Item> item = results.stream().filter(i -> i instanceof SecurityItem).findFirst();
assertThat(item.isPresent(), is(true));
Security security = ((SecurityItem) item.get()).getSecurity();
assertThat(security.getIsin(), is("US0378331005"));
assertThat(security.getName(), is("A p pl e I nc ."));
assertThat(security.getWkn(), is("865985"));
item = results.stream().filter(i -> i instanceof TransactionItem).findFirst();
assertThat(item.isPresent(), is(true));
assertThat(item.get().getSubject(), instanceOf(AccountTransaction.class));
AccountTransaction transaction = (AccountTransaction) item.get().getSubject();
assertThat(transaction.getType(), is(AccountTransaction.Type.DIVIDENDS));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2017-11-20T00:00")));
assertThat(transaction.getSecurity(), is(security));
assertThat(transaction.getAmount(), is(Values.Amount.factorize(4.5)));
assertThat(transaction.getShares(), is(Values.Share.factorize(9.914)));
}
use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem in project portfolio by buchen.
the class ComdirectPDFExtractorTest method testDividende1.
@Test
public void testDividende1() throws IOException {
ComdirectPDFExtractor extractor = new ComdirectPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "comdirectDividende1.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
// security
Optional<Item> item = results.stream().filter(i -> i instanceof SecurityItem).findFirst();
assertThat(item.isPresent(), is(true));
Security security = ((SecurityItem) item.get()).getSecurity();
assertThat(security.getIsin(), is("NL0000009355"));
assertThat(security.getName(), is("U n il e ve r N . V ."));
assertThat(security.getWkn(), is("A0JMZB"));
item = results.stream().filter(i -> i instanceof TransactionItem).findFirst();
assertThat(item.isPresent(), is(true));
assertThat(item.get().getSubject(), instanceOf(AccountTransaction.class));
AccountTransaction transaction = (AccountTransaction) item.get().getSubject();
assertThat(transaction.getType(), is(AccountTransaction.Type.DIVIDENDS));
assertThat(transaction.getSecurity(), is(security));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2010-12-15T00:00")));
assertThat(transaction.getAmount(), is(Values.Amount.factorize(335.92)));
assertThat(transaction.getShares(), is(Values.Share.factorize(1900)));
assertThat(transaction.getUnitSum(Unit.Type.TAX).getAmount(), is(Values.Amount.factorize(59.28)));
}
use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem in project portfolio by buchen.
the class DeutscheBankPDFExtractorTest method testErtragsgutschrift2.
@Test
public void testErtragsgutschrift2() throws IOException {
DeutscheBankPDFExtractor extractor = new DeutscheBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "DeutscheBankErtragsgutschrift2.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
new AssertImportActions().check(results, CurrencyUnit.EUR);
// check security
Security security = results.stream().filter(i -> i instanceof SecurityItem).findFirst().get().getSecurity();
assertThat(security.getName(), is("ISHS-MSCI N. AMERIC.UCITS ETF BE.SH.(DT.ZT.)"));
assertThat(security.getIsin(), is("DE000A0J2060"));
assertThat(security.getWkn(), is("A0J206"));
assertThat(security.getCurrencyCode(), is("USD"));
// check transaction
Optional<Item> item = results.stream().filter(i -> i instanceof TransactionItem).findFirst();
assertThat(item.isPresent(), is(true));
assertThat(item.get().getSubject(), instanceOf(AccountTransaction.class));
AccountTransaction transaction = (AccountTransaction) item.get().getSubject();
assertThat(transaction.getType(), is(AccountTransaction.Type.DIVIDENDS));
assertThat(transaction.getSecurity(), is(security));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2015-03-24T00:00")));
assertThat(transaction.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 16_17L)));
assertThat(transaction.getShares(), is(Values.Share.factorize(123)));
Optional<Unit> grossValue = transaction.getUnit(Unit.Type.GROSS_VALUE);
assertThat(grossValue.isPresent(), is(true));
assertThat(grossValue.get().getAmount(), is(Money.of("EUR", 16_17L)));
assertThat(grossValue.get().getForex(), is(Money.of("USD", 17_38L)));
assertThat(grossValue.get().getExchangeRate().doubleValue(), IsCloseTo.closeTo(0.930578, 0.000001));
}
Aggregations