use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem in project portfolio by buchen.
the class DABPDFExtractorTest method testProceeds1.
@Test
public void testProceeds1() throws IOException {
DABPDFExtractor extractor = new DABPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "DABProceeds1.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("IE00B3F81R35"));
assertThat(security.getName(), is("iShsIII-Core EO Corp.Bd U.ETF Registered Shares o.N."));
assertThat(security.getCurrencyCode(), is(CurrencyUnit.EUR));
// check buy sell 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.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(3.47))));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2017-01-27T00:00")));
assertThat(transaction.getShares(), is(Values.Share.factorize(3.4256)));
}
use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem in project portfolio by buchen.
the class DABPDFExtractorTest method testDividendInForeignCurrencyButSecurityListedInEuro.
@Test
public void testDividendInForeignCurrencyButSecurityListedInEuro() throws IOException {
Client client = new Client();
Security security = new Security();
security.setName("Procter & Gamble Co., The Registered Shares o.N.");
security.setIsin("US7427181091");
security.setCurrencyCode(CurrencyUnit.EUR);
client.addSecurity(security);
DABPDFExtractor extractor = new DABPDFExtractor(client);
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "DABDividendForeignCurrency.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(1));
new AssertImportActions().check(results, CurrencyUnit.USD);
// check buy sell 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.getMonetaryAmount(), is(Money.of(CurrencyUnit.USD, 56_91)));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2015-05-16T00:00")));
assertThat(transaction.getShares(), is(Values.Share.factorize(100)));
}
use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem in project portfolio by buchen.
the class DeutscheBankPDFExtractorTest method testErtragsgutschrift.
@Test
public void testErtragsgutschrift() throws IOException {
DeutscheBankPDFExtractor extractor = new DeutscheBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "DeutscheBankErtragsgutschrift.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
new AssertImportActions().check(results, CurrencyUnit.EUR);
// check security
Security security = assertSecurity(results);
// 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("2014-12-15T00:00")));
assertThat(transaction.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 14_95L)));
assertThat(transaction.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, 4_52)));
assertThat(transaction.getGrossValue(), is(Money.of(CurrencyUnit.EUR, 19_47)));
assertThat(transaction.getShares(), is(Values.Share.factorize(123)));
}
use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem in project portfolio by buchen.
the class DkbPDFExtractorPDFTest method testErtragsgutschriftDividende.
@Test
public void testErtragsgutschriftDividende() throws IOException {
DkbPDFExtractor extractor = new DkbPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
URL url = FileLocator.resolve(getClass().getResource("DkBErtragsgutschrift2_GBP_Freibetrrag_ausgeschoepft.pdf"));
PDFInputFile inputFile = new PDFInputFile(new File(url.getPath()));
inputFile.parse();
List<Item> results = extractor.extract(Arrays.asList(inputFile), 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.getWkn(), is("A0DJ58"));
assertThat(security.getIsin(), is("GB00B02J6398"));
assertThat(security.getName(), is("ADMIRAL GROUP PLC"));
// 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.getCurrencyCode(), is(CurrencyUnit.EUR));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2015-10-13T00:00")));
assertThat(transaction.getMonetaryAmount(), is(Money.of("EUR", 227_63L)));
assertThat(transaction.getShares(), is(Values.Share.factorize(450)));
}
use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem in project portfolio by buchen.
the class DkbPDFExtractorTest method testInvestmentertraege.
@Test
public void testInvestmentertraege() throws IOException {
DkbPDFExtractor extractor = new DkbPDFExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "DkbInvestmentertraege.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
// check 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("IE00B6YX5D40"));
assertThat(security.getWkn(), is("A1JKS0"));
assertThat(security.getName(), is("SPDR S&P US DIVID.ARISTOCR.ETF"));
assertThat(security.getCurrencyCode(), is("USD"));
// check transaction
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.getCurrencyCode(), is(CurrencyUnit.EUR));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2017-10-04T00:00")));
assertThat(transaction.getAmount(), is(Values.Amount.factorize(2.09)));
assertThat(transaction.getShares(), is(Values.Share.factorize(10.6841)));
assertThat(transaction.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(0.39))));
}
Aggregations