use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem in project portfolio by buchen.
the class HelloBankPDFExtractorTest method testErtrag01WithExistingSecurity.
@Test
public void testErtrag01WithExistingSecurity() throws IOException {
Security security = new Security("Marine Harvest ASA", CurrencyUnit.EUR);
security.setIsin("NO0003054108");
Client client = new Client();
client.addSecurity(security);
HelloBankPDFExtractor extractor = new HelloBankPDFExtractor(client);
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "Ertrag01.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(1));
new AssertImportActions().check(results, CurrencyUnit.EUR);
// 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("2017-09-06T00:00")));
assertThat(transaction.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(48.71))));
assertThat(transaction.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(0.95 + 0.19 + (176.01 / 9.308)))));
assertThat(transaction.getShares(), is(Values.Share.factorize(200)));
}
use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem in project portfolio by buchen.
the class HelloBankPDFExtractorTest method testErtrag04.
@Test
public void testErtrag04() throws IOException {
HelloBankPDFExtractor extractor = new HelloBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "Ertrag04.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
new AssertImportActions().check(results, CurrencyUnit.EUR);
// 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("US3682872078"));
assertThat(security.getName(), is("G a z p r o m P J S C"));
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.getDateTime(), is(LocalDateTime.parse("2017-08-21T00:00")));
assertThat(transaction.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(116.91))));
assertThat(transaction.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(0.19 + 0.95 + ((32.14 + 26.79 + 16) / 1.1805)))));
assertThat(transaction.getShares(), is(Values.Share.factorize(800)));
Unit grossValueUnit = transaction.getUnit(Unit.Type.GROSS_VALUE).get();
assertThat(grossValueUnit.getAmount(), is(Money.of("EUR", Values.Amount.factorize(214.28 / 1.1805))));
assertThat(grossValueUnit.getForex(), is(Money.of("USD", Values.Amount.factorize(214.28))));
assertThat(grossValueUnit.getExchangeRate(), is(BigDecimal.ONE.divide(BigDecimal.valueOf(1.1805), 10, BigDecimal.ROUND_HALF_UP)));
assertThat(grossValueUnit.getAmount().getAmount() - transaction.getUnitSum(Unit.Type.TAX).getAmount(), is(transaction.getMonetaryAmount().getAmount()));
}
use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem in project portfolio by buchen.
the class INGDiBaPDFExtractorTest method testErtragsgutschrift2.
@Test
public void testErtragsgutschrift2() throws IOException {
INGDiBaExtractor extractor = new INGDiBaExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "INGDiBa_Ertragsgutschrift2.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("DE000A1PGUT9"));
assertThat(security.getWkn(), is("A1PGUT"));
assertThat(security.getName(), is("7,25000% posterXXL AG"));
// 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(72.50)));
assertThat(t.getDateTime(), is(LocalDateTime.parse("2015-12-15T00:00")));
assertThat(t.getShares(), is(Values.Share.factorize(0)));
}
use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem in project portfolio by buchen.
the class INGDiBaPDFExtractorTest method testErtragsgutschrift3.
@Test
public void testErtragsgutschrift3() throws IOException {
INGDiBaExtractor extractor = new INGDiBaExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "INGDiBa_Ertragsgutschrift3.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("DE0002635281"));
assertThat(security.getWkn(), is("263528"));
assertThat(security.getName(), is("iSh.EO ST.Sel.Div.30 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(101.32)));
assertThat(t.getDateTime(), is(LocalDateTime.parse("2016-10-17T00:00")));
assertThat(t.getShares(), is(Values.Share.factorize(1112.0958)));
assertThat(t.getGrossValue(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(116.84))));
assertThat(t.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(14.72 + 0.8))));
}
use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem in project portfolio by buchen.
the class INGDiBaPDFExtractorTest method testDividendengutschrift3.
@Test
public void testDividendengutschrift3() throws IOException {
INGDiBaExtractor extractor = new INGDiBaExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "INGDiBa_Dividendengutschrift3.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("CH0038389992"));
assertThat(security.getWkn(), is("A0NFN3"));
assertThat(security.getName(), is("BB Biotech AG Namens-Aktien SF 0,20"));
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(58.19)));
assertThat(t.getDateTime(), is(LocalDateTime.parse("2017-03-20T00:00")));
assertThat(t.getShares(), is(Values.Share.factorize(35)));
assertThat(t.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(31.34))));
assertThat(t.getGrossValue(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(89.53))));
}
Aggregations