use of name.abuchen.portfolio.model.Security in project portfolio by buchen.
the class FinTechGroupBankPDFExtractorTest method testDividendeAusland.
@Test
public void testDividendeAusland() throws IOException {
FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FinTechGroupBankDividendeAusland1.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("US8552441094"));
assertThat(security.getWkn(), is("884437"));
assertThat(security.getName(), is("STARBUCKS CORP."));
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-25T00:00")));
assertThat(transaction.getAmount(), is(Values.Amount.factorize(14.45)));
assertThat(transaction.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(7.78))));
assertThat(transaction.getShares(), is(Values.Share.factorize(105)));
}
use of name.abuchen.portfolio.model.Security in project portfolio by buchen.
the class CSVPortfolioTransactionExtractorTest method testBuyTransaction.
@Test
public void testBuyTransaction() throws ParseException {
Client client = new Client();
Security security = new Security();
security.setTickerSymbol("SAP.DE");
client.addSecurity(security);
CSVExtractor extractor = new CSVPortfolioTransactionExtractor(client);
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(0, Arrays.<String[]>asList(new String[] { "2013-01-02", "DE0007164600", "SAP.DE", "", "SAP SE", "100", "EUR", "11", "", "", "", "", "1,9", "BUY", "Notiz" }), buildField2Column(extractor), errors);
assertThat(errors, empty());
assertThat(results.size(), is(1));
new AssertImportActions().check(results, CurrencyUnit.EUR);
BuySellEntry entry = (BuySellEntry) results.stream().filter(i -> i instanceof BuySellEntryItem).findAny().get().getSubject();
PortfolioTransaction t = entry.getPortfolioTransaction();
assertThat(t.getType(), is(PortfolioTransaction.Type.BUY));
assertThat(t.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 100_00)));
assertThat(t.getNote(), is("Notiz"));
assertThat(t.getDateTime(), is(LocalDateTime.parse("2013-01-02T00:00")));
assertThat(t.getShares(), is(Values.Share.factorize(1.9)));
assertThat(t.getSecurity(), is(security));
assertThat(t.getUnitSum(Unit.Type.FEE), is(Money.of("EUR", 11_00)));
assertThat(t.getUnit(Unit.Type.TAX).isPresent(), is(false));
AccountTransaction at = entry.getAccountTransaction();
assertThat(at.getType(), is(AccountTransaction.Type.BUY));
assertThat(at.getUnitSum(Unit.Type.FEE), is(Money.of("EUR", 0)));
}
use of name.abuchen.portfolio.model.Security in project portfolio by buchen.
the class CSVSecurityExtractorTest method testSecurityCreation.
@Test
public void testSecurityCreation() throws ParseException {
Client client = new Client();
CSVExtractor extractor = new CSVSecurityExtractor(client);
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(0, Arrays.<String[]>asList(new String[] { "DE0007164600", "716460", "SAP.DE", "SAP SE", "EUR", "Notiz" }), buildField2Column(extractor), errors);
assertThat(errors, empty());
assertThat(results.size(), is(1));
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("716460"));
assertThat(security.getTickerSymbol(), is("SAP.DE"));
assertThat(security.getCurrencyCode(), is("EUR"));
assertThat(security.getNote(), is("Notiz"));
}
use of name.abuchen.portfolio.model.Security in project portfolio by buchen.
the class ISINFieldTest method testPartialMatch.
@Test
public void testPartialMatch() throws ParseException {
ISINField field = new ISINField(Messages.CSVColumn_ISIN);
Format format = field.createFormat(Arrays.asList(new Security("SAP", "DE0007164600", "SAP.DE", QuoteFeed.MANUAL)));
assertThat(format.parseObject("Zins/Dividende ISIN DE0007164600 SAP SE O."), is("DE0007164600"));
assertThat(format.parseObject("ISIN DE0007164600"), is("DE0007164600"));
}
use of name.abuchen.portfolio.model.Security in project portfolio by buchen.
the class ISINFieldTest method testValidAndExistingISIN.
@Test
public void testValidAndExistingISIN() throws ParseException {
ISINField field = new ISINField(Messages.CSVColumn_ISIN);
Format format = field.createFormat(Arrays.asList(new Security("BASF", "DE000BASF111", "BAS.DE", QuoteFeed.MANUAL)));
assertThat(format.parseObject("DE000BASF111"), is("DE000BASF111"));
}
Aggregations