use of name.abuchen.portfolio.datatransfer.Extractor.SecurityItem in project portfolio by buchen.
the class SBrokerPDFExtractorTest method testWertpapierVerkauf1.
@Test
public void testWertpapierVerkauf1() throws IOException {
SBrokerPDFExtractor extractor = new SBrokerPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "sBroker_Verkauf1.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
Optional<Item> item = results.stream().filter(i -> i instanceof BuySellEntryItem).findFirst();
assertThat(item.isPresent(), is(true));
assertThat(item.get().getSubject(), instanceOf(BuySellEntry.class));
BuySellEntry entry = (BuySellEntry) item.get().getSubject();
assertThat(entry.getPortfolioTransaction().getType(), is(PortfolioTransaction.Type.SELL));
assertThat(entry.getAccountTransaction().getType(), is(AccountTransaction.Type.SELL));
assertThat(entry.getPortfolioTransaction().getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 5648_24)));
assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2015-06-04T00:00")));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(47)));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of(CurrencyUnit.EUR, 821L)));
}
use of name.abuchen.portfolio.datatransfer.Extractor.SecurityItem 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.SecurityItem in project portfolio by buchen.
the class SecurityCache method createMissingSecurityItems.
/**
* Returns a list of {@link SecurityItem} that are implicitly created when
* extracting transactions. Do not add all newly created securities as they
* might be created out of erroneous transactions.
*/
public Collection<Item> createMissingSecurityItems(List<Item> items) {
List<Item> answer = new ArrayList<>();
Set<Security> available = new HashSet<>();
available.addAll(client.getSecurities());
items.stream().filter(i -> i instanceof SecurityItem).map(Item::getSecurity).forEach(available::add);
for (Item item : items) {
if (item instanceof SecurityItem || item.getSecurity() == null)
continue;
if (!available.contains(item.getSecurity())) {
answer.add(new SecurityItem(item.getSecurity()));
available.add(item.getSecurity());
}
}
return answer;
}
use of name.abuchen.portfolio.datatransfer.Extractor.SecurityItem 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)));
}
use of name.abuchen.portfolio.datatransfer.Extractor.SecurityItem in project portfolio by buchen.
the class FinTechGroupBankPDFExtractorTest method testWertpapierKauf11.
@Test
public void testWertpapierKauf11() throws IOException {
FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexKauf11.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("IE00B6YX5D40"));
assertThat(security.getWkn(), is("A1JKS0"));
assertThat(security.getName(), is("SPDR S+P US DIV.ARIST.ETF"));
item = results.stream().filter(i -> i instanceof BuySellEntryItem).findFirst();
assertThat(item.isPresent(), is(true));
assertThat(item.get().getSubject(), instanceOf(BuySellEntry.class));
BuySellEntry entry = (BuySellEntry) item.get().getSubject();
assertThat(entry.getPortfolioTransaction().getType(), is(PortfolioTransaction.Type.BUY));
assertThat(entry.getAccountTransaction().getType(), is(AccountTransaction.Type.BUY));
assertThat(entry.getPortfolioTransaction().getAmount(), is(Values.Amount.factorize(1000.00)));
assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2018-01-02T00:00")));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("EUR", Values.Amount.factorize(1.5))));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(22.973458)));
}
Aggregations