use of name.abuchen.portfolio.model.PortfolioTransaction in project portfolio by buchen.
the class CSVPortfolioTransactionExtractorTest method testDeliveryTransactionPlusSecurityCreation.
@Test
public void testDeliveryTransactionPlusSecurityCreation() throws ParseException {
Client client = new Client();
CSVExtractor extractor = new CSVPortfolioTransactionExtractor(client);
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(0, Arrays.<String[]>asList(new String[] { "2013-01-01", "DE0007164600", "SAP.DE", "", "SAP SE", "100", "EUR", "11", "10", "", "", "", "1,2", "DELIVERY_INBOUND", "Notiz" }), buildField2Column(extractor), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
new AssertImportActions().check(results, CurrencyUnit.EUR);
Security security = results.stream().filter(i -> i instanceof SecurityItem).findAny().get().getSecurity();
assertThat(security.getName(), is("SAP SE"));
assertThat(security.getIsin(), is("DE0007164600"));
assertThat(security.getWkn(), is(nullValue()));
assertThat(security.getTickerSymbol(), is("SAP.DE"));
PortfolioTransaction t = (PortfolioTransaction) results.stream().filter(i -> i instanceof TransactionItem).findAny().get().getSubject();
assertThat(t.getType(), is(PortfolioTransaction.Type.DELIVERY_INBOUND));
assertThat(t.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 100_00)));
assertThat(t.getNote(), is("Notiz"));
assertThat(t.getDateTime(), is(LocalDateTime.parse("2013-01-01T00:00")));
assertThat(t.getShares(), is(Values.Share.factorize(1.2)));
assertThat(t.getSecurity(), is(security));
assertThat(t.getUnitSum(Unit.Type.FEE), is(Money.of("EUR", 11_00)));
assertThat(t.getUnitSum(Unit.Type.TAX), is(Money.of("EUR", 10_00)));
}
use of name.abuchen.portfolio.model.PortfolioTransaction in project portfolio by buchen.
the class FinTechGroupBankPDFExtractorTest method testWertpapierKauf7.
@Test
public void testWertpapierKauf7() throws IOException {
FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexKauf7.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(20));
List<PortfolioTransaction> tx = //
results.stream().filter(i -> i instanceof BuySellEntryItem).map(i -> ((BuySellEntry) i.getSubject()).getPortfolioTransaction()).collect(Collectors.toList());
assertThat(tx.size(), is(10));
assertThat(tx, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2017-11-01T00:00"))), //
hasProperty("type", is(PortfolioTransaction.Type.BUY)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(3008.9)))))));
}
use of name.abuchen.portfolio.model.PortfolioTransaction in project portfolio by buchen.
the class FinTechGroupBankPDFExtractorTest method testWertpapierKauf4.
@Test
public void testWertpapierKauf4() throws IOException {
FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexKauf4.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
Optional<Item> item;
// security
item = results.stream().filter(i -> i instanceof SecurityItem).findFirst();
assertThat(item.isPresent(), is(true));
Security security = ((SecurityItem) item.get()).getSecurity();
assertThat(security.getIsin(), is("LU0392494992"));
assertThat(security.getWkn(), is("ETF113"));
assertThat(security.getName(), is("C.-MSCI NO.AM.TRN U.ETF I"));
PortfolioTransaction transaction = results.stream().filter(i -> i instanceof Extractor.BuySellEntryItem).map(i -> (BuySellEntry) ((Extractor.BuySellEntryItem) i).getSubject()).map(b -> b.getPortfolioTransaction()).findAny().get();
assertThat(transaction.getType(), is(PortfolioTransaction.Type.BUY));
assertThat(transaction.getAmount(), is(Values.Amount.factorize(800)));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2017-06-16T00:00")));
assertThat(transaction.getUnitSum(Unit.Type.FEE), is(Money.of("EUR", Values.Amount.factorize(0))));
assertThat(transaction.getShares(), is(Values.Share.factorize(13.268957)));
}
use of name.abuchen.portfolio.model.PortfolioTransaction in project portfolio by buchen.
the class FinTechGroupBankPDFExtractorTest method testWertpapierVerkauf4.
@Test
public void testWertpapierVerkauf4() throws IOException {
FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexVerkauf4.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
List<PortfolioTransaction> tx = //
results.stream().filter(i -> i instanceof BuySellEntryItem).map(i -> ((BuySellEntry) i.getSubject()).getPortfolioTransaction()).collect(Collectors.toList());
assertThat(tx.size(), is(1));
assertThat(tx, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2018-01-09T00:00"))), //
hasProperty("type", is(PortfolioTransaction.Type.SELL)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(0.95)))))));
}
use of name.abuchen.portfolio.model.PortfolioTransaction in project portfolio by buchen.
the class FinTechGroupBankPDFExtractorTest method testGutschriftsBelastungsanzeige.
@Test
public void testGutschriftsBelastungsanzeige() throws IOException {
FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexGutschriftsBelastungsanzeige.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(20));
Optional<Item> item;
// security
item = results.stream().filter(i -> i instanceof SecurityItem).findFirst();
assertThat(item.isPresent(), is(true));
Security security = ((SecurityItem) item.get()).getSecurity();
assertThat(security.getIsin(), is("DE0008474503"));
assertThat(security.getName(), is("DEKAFONDS CF"));
item = results.stream().filter(i -> i instanceof TransactionItem).findFirst();
assertThat(item.isPresent(), is(true));
assertThat(item.get().getSubject(), instanceOf(PortfolioTransaction.class));
PortfolioTransaction entry = (PortfolioTransaction) item.get().getSubject();
assertThat(entry.getType(), is(PortfolioTransaction.Type.DELIVERY_INBOUND));
assertThat(entry.getAmount(), is(Values.Amount.factorize(5.50)));
assertThat(entry.getDateTime(), is(LocalDateTime.parse("2015-02-16T00:00")));
assertThat(entry.getShares(), is(Values.Share.factorize(0.0520)));
}
Aggregations