use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem in project portfolio by buchen.
the class IBFlexStatementExtractorTest method testIBAcitvityStatement.
@Test
public void testIBAcitvityStatement() throws IOException {
InputStream activityStatement = getClass().getResourceAsStream("IBActivityStatement.xml");
Client client = new Client();
IBFlexStatementExtractor extractor = new IBFlexStatementExtractor(client);
Extractor.InputFile tempFile = createTempFile(activityStatement);
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(Collections.singletonList(tempFile), errors);
results.stream().filter(i -> !(i instanceof SecurityItem)).forEach(i -> assertThat(i.getAmount(), notNullValue()));
assertThat(results.size(), is(29));
assertFirstSecurity(results.stream().filter(i -> i instanceof SecurityItem).findFirst());
assertFirstTransaction(results.stream().filter(i -> i instanceof BuySellEntryItem).findFirst());
assertSecondSecurity(results.stream().filter(i -> i instanceof SecurityItem).reduce((previous, current) -> current).get());
assertFourthTransaction(results.stream().filter(i -> i instanceof BuySellEntryItem).skip(3).findFirst());
assertInterestCharge(results.stream().filter(i -> i instanceof TransactionItem).filter(i -> i.getSubject() instanceof AccountTransaction && ((AccountTransaction) i.getSubject()).getType() == Type.INTEREST_CHARGE).findFirst());
assertTax(results.stream().filter(i -> i instanceof TransactionItem).filter(i -> i.getSubject() instanceof AccountTransaction && ((AccountTransaction) i.getSubject()).getType() == Type.TAXES).findFirst());
assertFee(results.stream().filter(i -> i instanceof TransactionItem).filter(i -> i.getSubject() instanceof AccountTransaction && ((AccountTransaction) i.getSubject()).getType() == Type.FEES).skip(2).findFirst());
assertFeeRefund(results.stream().filter(i -> i instanceof TransactionItem).filter(i -> i.getSubject() instanceof AccountTransaction && ((AccountTransaction) i.getSubject()).getType() == Type.FEES_REFUND).findFirst());
// TODO Check CorporateActions
}
use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem 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.Extractor.TransactionItem in project portfolio by buchen.
the class SBrokerPDFExtractorTest method testErtragsgutschrift1.
@Test
public void testErtragsgutschrift1() throws IOException {
SBrokerPDFExtractor extractor = new SBrokerPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "sBroker_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("DE000A0H0785"));
assertThat(security.getName(), is("iS.EO G.B.C.1.5-10.5y.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.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 12_70)));
assertThat(t.getDateTime(), is(LocalDateTime.parse("2014-11-17T00:00")));
assertThat(t.getShares(), is(Values.Share.factorize(16)));
}
use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem 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.Extractor.TransactionItem in project portfolio by buchen.
the class FinTechGroupBankPDFExtractorTest method testZinsgutschriftInland.
@Test
public void testZinsgutschriftInland() throws IOException {
FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexZinsgutschriftInland.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("DE1234567890"));
assertThat(security.getWkn(), is("AB1234"));
assertThat(security.getName(), is("ISH.FOOBAR 12345666 x.EFT"));
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-04-28T00:00")));
assertThat(transaction.getAmount(), is(Values.Amount.factorize(73.75)));
assertThat(transaction.getShares(), is(Values.Share.factorize(1000)));
}
Aggregations