use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.
the class HelloBankPDFExtractorTest method testErtrag02.
@Test
public void testErtrag02() throws IOException {
HelloBankPDFExtractor extractor = new HelloBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "Ertrag02.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("US56035L1044"));
assertThat(security.getName(), is("M a i n S t r e e t Capital Corp."));
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-05-15T00:00")));
assertThat(transaction.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(12.34))));
assertThat(transaction.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(0.95 + 0.19 + ((3.05 + 2.55) / 1.0942)))));
assertThat(transaction.getShares(), is(Values.Share.factorize(110)));
Unit grossValueUnit = transaction.getUnit(Unit.Type.GROSS_VALUE).get();
assertThat(grossValueUnit.getAmount(), is(Money.of("EUR", Values.Amount.factorize(20.35 / 1.0942))));
assertThat(grossValueUnit.getForex(), is(Money.of("USD", Values.Amount.factorize(20.35))));
assertThat(grossValueUnit.getExchangeRate(), is(BigDecimal.ONE.divide(BigDecimal.valueOf(1.0942), 10, BigDecimal.ROUND_HALF_UP)));
assertThat(grossValueUnit.getAmount().getAmount() - transaction.getUnitSum(Unit.Type.TAX).getAmount(), is(transaction.getMonetaryAmount().getAmount()));
}
use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.
the class INGDiBaPDFExtractorTest method testDividendengutschrift1.
@Test
public void testDividendengutschrift1() throws IOException {
INGDiBaExtractor extractor = new INGDiBaExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "INGDiBa_Dividendengutschrift1.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("US5801351017"));
assertThat(security.getWkn(), is("856958"));
assertThat(security.getName(), is("McDonald's Corp."));
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(44.01)));
assertThat(t.getDateTime(), is(LocalDateTime.parse("2016-11-29T00:00")));
assertThat(t.getShares(), is(Values.Share.factorize(66)));
assertThat(t.getGrossValue(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(50.24 + 8.87))));
assertThat(t.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(5.91 + 0.32 + 8.87))));
}
use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.
the class INGDiBaPDFExtractorTest method testDividendengutschrift2.
@Test
public void testDividendengutschrift2() throws IOException {
INGDiBaExtractor extractor = new INGDiBaExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "INGDiBa_Dividendengutschrift2.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("DE000A0H0744"));
assertThat(security.getWkn(), is("A0H074"));
assertThat(security.getName(), is("iSh.DJ Asia Pa.S.D.30 U.ETF DE"));
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(234.92)));
assertThat(t.getDateTime(), is(LocalDateTime.parse("2016-12-15T00:00")));
assertThat(t.getShares(), is(Values.Share.factorize(694)));
assertThat(t.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(65.1 + 3.58))));
assertThat(t.getGrossValue(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(303.60))));
}
use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.
the class INGDiBaPDFExtractorTest method testErtragsgutschrift1.
@Test
public void testErtragsgutschrift1() throws IOException {
INGDiBaExtractor extractor = new INGDiBaExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "INGDiBa_Ertragsgutschrift1.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("DE0002635307"));
assertThat(security.getWkn(), is("263530"));
assertThat(security.getName(), is("iSh.STOXX Europe 600 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(6.70)));
assertThat(t.getDateTime(), is(LocalDateTime.parse("2015-09-15T00:00")));
assertThat(t.getShares(), is(Values.Share.factorize(18)));
}
use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.
the class INGDiBaPDFExtractorTest method testGemeinschaftskontoDividendengutschrift1.
@Test
public void testGemeinschaftskontoDividendengutschrift1() throws IOException {
INGDiBaExtractor extractor = new INGDiBaExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "INGDiBa_Gemeinschaftskonto_Dividendengutschrift1.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("DE000TLX1005"));
assertThat(security.getWkn(), is("TLX100"));
assertThat(security.getName(), is("Talanx AG Namens-Aktien o.N."));
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(468.04)));
assertThat(t.getDateTime(), is(LocalDateTime.parse("2016-05-12T00:00")));
assertThat(t.getShares(), is(Values.Share.factorize(500)));
assertThat(t.getGrossValue(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(650.00))));
assertThat(t.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(79.46 + 7.15 + 4.37 + 79.46 + 7.15 + 4.37))));
}
Aggregations