use of name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem in project portfolio by buchen.
the class BankSLMPDFExtractorTest method testKauf_Inland2.
@Test
public void testKauf_Inland2() throws IOException {
BankSLMPDFExtractor extractor = new BankSLMPDFExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "BankSLM_Kauf_Inland2.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
new AssertImportActions().check(results, "CHF");
// check security
Security security = results.stream().filter(i -> i instanceof SecurityItem).findFirst().get().getSecurity();
assertThat(security.getWkn(), is("24476758"));
assertThat(security.getName(), is("UBS Group AG"));
// 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.BUY));
assertThat(entry.getAccountTransaction().getType(), is(AccountTransaction.Type.BUY));
assertThat(entry.getPortfolioTransaction().getMonetaryAmount(), is(Money.of("CHF", Values.Amount.factorize(43412.10))));
assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2016-02-10T00:00")));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(3000)));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("CHF", 32_40L + 3_50 + 176_20)));
}
use of name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem in project portfolio by buchen.
the class ComdirectPDFExtractorTest method testWertpapierVerkauf3.
@Test
public void testWertpapierVerkauf3() throws IOException {
ComdirectPDFExtractor extractor = new ComdirectPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "comdirectWertpapierabrechnung_Verkauf3.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(3));
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.getName(), is("ITC Holdings Corp."));
assertThat(security.getIsin(), is("US4656851056"));
assertThat(security.getWkn(), is("A0F401"));
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().getAmount(), is(Values.Amount.factorize(21239.83)));
assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2016-02-25T00:00")));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("EUR", Values.Amount.factorize(66.47))));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(570)));
// tax refund
AccountTransaction t = (AccountTransaction) results.stream().filter(i -> i instanceof TransactionItem).findFirst().get().getSubject();
assertThat(t.getSecurity(), is(security));
assertThat(t.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(71.73))));
}
use of name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem in project portfolio by buchen.
the class ComdirectPDFExtractorTest method testWertpapierVerkauf.
@Test
public void testWertpapierVerkauf() throws IOException {
ComdirectPDFExtractor extractor = new ComdirectPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "comdirectWertpapierabrechnung_Verkauf.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.getName(), is("FooBar. ETF"));
assertThat(security.getIsin(), is("DE1234567890"));
assertThat(security.getWkn(), is("ABC123"));
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));
// expected total is total amount minux taxes
long expectedTotal = Values.Amount.factorize(10111.11 - 11.11);
assertThat(entry.getPortfolioTransaction().getAmount(), is(expectedTotal));
assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2010-01-01T00:00")));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("EUR", Values.Amount.factorize(11.51))));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.TAX), is(Money.of("EUR", Values.Amount.factorize(11.11))));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(100)));
}
use of name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem in project portfolio by buchen.
the class ComdirectPDFExtractorTest method testWertpapierKauf6.
@Test
public void testWertpapierKauf6() throws IOException {
ComdirectPDFExtractor extractor = new ComdirectPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "comdirectWertpapierabrechnung_Kauf6.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.getName(), is("BayWa AG"));
assertThat(security.getIsin(), is("DE0005194062"));
assertThat(security.getWkn(), is("519406"));
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(16312.80)));
assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2013-03-14T00:00")));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("EUR", Values.Amount.factorize(47.66))));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(1437)));
}
use of name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem in project portfolio by buchen.
the class ComdirectPDFExtractorTest method testWertpapierKauf8.
@Test
public void testWertpapierKauf8() throws IOException {
ComdirectPDFExtractor extractor = new ComdirectPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "comdirectWertpapierabrechnung_Kauf8.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.getName(), is("T. Rowe Price Group Inc."));
assertThat(security.getIsin(), is("US74144T1088"));
assertThat(security.getWkn(), is("870967"));
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(1469.55)));
assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2016-11-08T00:00")));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("EUR", Values.Amount.factorize(2.9 + 9.9))));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(25)));
}
Aggregations