use of name.abuchen.portfolio.datatransfer.actions.AssertImportActions in project portfolio by buchen.
the class BankSLMPDFExtractorTest method testDividende_Ausland1.
@Test
public void testDividende_Ausland1() throws IOException {
BankSLMPDFExtractor extractor = new BankSLMPDFExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "BankSLM_Dividende_Ausland1.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
new AssertImportActions().check(results, "CHF");
// check security
Security security = results.stream().filter(i -> i instanceof SecurityItem).findFirst().get().getSecurity();
assertThat(security.getWkn(), is("472672"));
assertThat(security.getName(), is("Nokia Corp"));
// 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("2016-07-05T00:00")));
assertThat(transaction.getMonetaryAmount(), is(Money.of("CHF", 3302_00L)));
assertThat(transaction.getUnitSum(Unit.Type.TAX), is(Money.of("CHF", 1415_14L)));
assertThat(transaction.getGrossValue(), is(Money.of("CHF", 4717_14L)));
assertThat(transaction.getShares(), is(Values.Share.factorize(17000)));
}
use of name.abuchen.portfolio.datatransfer.actions.AssertImportActions in project portfolio by buchen.
the class CSVAccountTransactionExtractorTest method testTaxesOnDividends.
@Test
public void testTaxesOnDividends() {
Client client = new Client();
CSVExtractor extractor = new CSVAccountTransactionExtractor(client);
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(0, //
Arrays.<String[]>asList(new String[] { "2013-01-01", "DE0007164600", "SAP.DE", "", "100", "EUR", "DIVIDENDS", "SAP SE", "10", "Notiz", "10" }), buildField2Column(extractor), errors);
assertThat(results.size(), is(2));
new AssertImportActions().check(results, CurrencyUnit.EUR);
AccountTransaction t = (AccountTransaction) results.stream().filter(i -> i instanceof TransactionItem).findAny().get().getSubject();
assertThat(t.getType(), is(AccountTransaction.Type.DIVIDENDS));
assertThat(t.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 100_00)));
assertThat(t.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, 10_00)));
}
use of name.abuchen.portfolio.datatransfer.actions.AssertImportActions in project portfolio by buchen.
the class FinTechGroupBankPDFExtractorTest method testKontoauszug2.
@Test
public void testKontoauszug2() throws IOException {
FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexKontoauszug2.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(1));
new AssertImportActions().check(results, CurrencyUnit.EUR);
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.REMOVAL));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2016-01-26T00:00")));
assertThat(transaction.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 15000_00L)));
}
use of name.abuchen.portfolio.datatransfer.actions.AssertImportActions 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.actions.AssertImportActions 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()));
}
Aggregations