use of name.abuchen.portfolio.model.Security in project portfolio by buchen.
the class HelloBankPDFExtractorTest method testVerkauf01WithExistingSecurity.
@Test
public void testVerkauf01WithExistingSecurity() throws IOException {
Security security = new Security("SELECT HARVEST LTD.", CurrencyUnit.EUR);
security.setIsin("AU000000SHV6");
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(), "Verkauf01.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 BuySellEntryItem).findFirst();
assertThat(item.isPresent(), is(true));
assertThat(item.get().getSubject(), instanceOf(BuySellEntry.class));
BuySellEntry entry = (BuySellEntry) item.get().getSubject();
PortfolioTransaction tx = entry.getPortfolioTransaction();
assertThat(tx.getType(), is(PortfolioTransaction.Type.SELL));
assertThat(entry.getAccountTransaction().getType(), is(AccountTransaction.Type.SELL));
assertThat(tx.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(3096.85))));
assertThat(tx.getDateTime(), is(LocalDateTime.parse("2017-10-12T00:00")));
assertThat(tx.getShares(), is(Values.Share.factorize(1000)));
assertThat(tx.getUnitSum(Unit.Type.FEE), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(14.99 + 6.42 + 7.95))));
assertThat(tx.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(254.1 / 1.5181))));
}
use of name.abuchen.portfolio.model.Security in project portfolio by buchen.
the class HelloBankPDFExtractorTest method testInboundDelivery02.
@Test
public void testInboundDelivery02() throws IOException {
HelloBankPDFExtractor extractor = new HelloBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "InboundDelivery02.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("US56035L1044"));
assertThat(security.getName(), is("M a i n S t r e e t Capital Corp."));
assertThat(security.getCurrencyCode(), is(CurrencyUnit.EUR));
// check transaction
item = results.stream().filter(i -> i instanceof TransactionItem).findFirst();
assertThat(item.isPresent(), is(true));
assertThat(item.get().getSubject(), instanceOf(PortfolioTransaction.class));
PortfolioTransaction tx = (PortfolioTransaction) item.get().getSubject();
assertThat(tx.getType(), is(PortfolioTransaction.Type.DELIVERY_INBOUND));
assertThat(tx.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(3021.70))));
assertThat(tx.getDateTime(), is(LocalDateTime.parse("2017-03-31T00:00")));
assertThat(tx.getShares(), is(Values.Share.factorize(110)));
}
use of name.abuchen.portfolio.model.Security in project portfolio by buchen.
the class HelloBankPDFExtractorTest method testKauf01WithExistingSecurity.
@Test
public void testKauf01WithExistingSecurity() 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(), "Kauf01.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 BuySellEntryItem).findFirst();
assertThat(item.isPresent(), is(true));
assertThat(item.get().getSubject(), instanceOf(BuySellEntry.class));
BuySellEntry entry = (BuySellEntry) item.get().getSubject();
PortfolioTransaction tx = entry.getPortfolioTransaction();
assertThat(tx.getType(), is(PortfolioTransaction.Type.BUY));
assertThat(entry.getAccountTransaction().getType(), is(AccountTransaction.Type.BUY));
assertThat(tx.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(1118.8))));
assertThat(tx.getDateTime(), is(LocalDateTime.parse("2017-06-30T00:00")));
assertThat(tx.getShares(), is(Values.Share.factorize(74)));
assertThat(tx.getUnitSum(Unit.Type.FEE), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(25.20 + 1.46))));
}
use of name.abuchen.portfolio.model.Security in project portfolio by buchen.
the class INGDiBaPDFExtractorTest method testDividendengutschrift1.
@Test
public void testDividendengutschrift1() throws IOException {
INGDiBaExtractor extractor = new INGDiBaExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "INGDiBa_Dividendengutschrift1.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
Security security = results.stream().filter(i -> i instanceof SecurityItem).findFirst().get().getSecurity();
assertThat(security.getIsin(), is("US5801351017"));
assertThat(security.getWkn(), is("856958"));
assertThat(security.getName(), is("McDonald's Corp."));
AccountTransaction t = (AccountTransaction) results.stream().filter(i -> i instanceof TransactionItem).findFirst().get().getSubject();
assertThat(t.getType(), is(AccountTransaction.Type.DIVIDENDS));
assertThat(t.getAmount(), is(Values.Amount.factorize(44.01)));
assertThat(t.getDateTime(), is(LocalDateTime.parse("2016-11-29T00:00")));
assertThat(t.getShares(), is(Values.Share.factorize(66)));
assertThat(t.getGrossValue(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(50.24 + 8.87))));
assertThat(t.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(5.91 + 0.32 + 8.87))));
}
use of name.abuchen.portfolio.model.Security in project portfolio by buchen.
the class INGDiBaPDFExtractorTest method testDividendengutschrift2.
@Test
public void testDividendengutschrift2() throws IOException {
INGDiBaExtractor extractor = new INGDiBaExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "INGDiBa_Dividendengutschrift2.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
Security security = results.stream().filter(i -> i instanceof SecurityItem).findFirst().get().getSecurity();
assertThat(security.getIsin(), is("DE000A0H0744"));
assertThat(security.getWkn(), is("A0H074"));
assertThat(security.getName(), is("iSh.DJ Asia Pa.S.D.30 U.ETF DE"));
AccountTransaction t = (AccountTransaction) results.stream().filter(i -> i instanceof TransactionItem).findFirst().get().getSubject();
assertThat(t.getType(), is(AccountTransaction.Type.DIVIDENDS));
assertThat(t.getAmount(), is(Values.Amount.factorize(234.92)));
assertThat(t.getDateTime(), is(LocalDateTime.parse("2016-12-15T00:00")));
assertThat(t.getShares(), is(Values.Share.factorize(694)));
assertThat(t.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(65.1 + 3.58))));
assertThat(t.getGrossValue(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(303.60))));
}
Aggregations