use of name.abuchen.portfolio.datatransfer.Extractor in project portfolio by buchen.
the class FinTechGroupBankPDFExtractorTest method testWertpapierKaufVerkaufSteuererstattung.
@Test
public void testWertpapierKaufVerkaufSteuererstattung() throws IOException {
FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexKaufVerkaufSteuererstattung.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(7));
Optional<Item> item;
// check Käufe
// 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("DE000VN4LAU4"));
assertThat(security.getWkn(), is("VN4LAU"));
assertThat(security.getName(), is("VONT.FINL PR CALL17 DAX"));
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(1036.40)));
assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2017-01-02T00:00")));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("EUR", Values.Amount.factorize(3.90))));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(1750)));
Item item2;
item2 = results.stream().filter(i -> i instanceof SecurityItem).collect(Collectors.toList()).get(1);
security = ((SecurityItem) item2).getSecurity();
assertThat(security.getIsin(), is("DE000VN547F8"));
assertThat(security.getWkn(), is("VN547F"));
assertThat(security.getName(), is("VONT.FINL PR PUT17 DAX"));
item2 = results.stream().filter(i -> i instanceof BuySellEntryItem).collect(Collectors.toList()).get(1);
assertThat(item2.getSubject(), instanceOf(BuySellEntry.class));
entry = (BuySellEntry) item2.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(1003.90)));
assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2017-01-02T00:00")));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("EUR", Values.Amount.factorize(3.90))));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(1250)));
// check Verkäufe
item2 = results.stream().filter(i -> i instanceof BuySellEntryItem).collect(Collectors.toList()).get(2);
assertThat(item2.getSubject(), instanceOf(BuySellEntry.class));
entry = (BuySellEntry) item2.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(1232.40)));
assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2017-01-02T00:00")));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("EUR", Values.Amount.factorize(3.90))));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(1750)));
item2 = results.stream().filter(i -> i instanceof BuySellEntryItem).collect(Collectors.toList()).get(3);
assertThat(item2.getSubject(), instanceOf(BuySellEntry.class));
entry = (BuySellEntry) item2.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(844.10)));
assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2017-01-02T00:00")));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("EUR", Values.Amount.factorize(5.90))));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(1250)));
// check Steuererstattung
Item itemTaxReturn = results.stream().filter(i -> i instanceof TransactionItem).collect(Collectors.toList()).get(0);
AccountTransaction entryTaxReturn = (AccountTransaction) itemTaxReturn.getSubject();
assertThat(entryTaxReturn.getType(), is(AccountTransaction.Type.TAX_REFUND));
assertThat(entryTaxReturn.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(44.72))));
assertThat(entryTaxReturn.getDateTime(), is(LocalDateTime.parse("2017-01-02T00:00")));
}
use of name.abuchen.portfolio.datatransfer.Extractor in project portfolio by buchen.
the class FinTechGroupBankPDFExtractorTest method testZinsBelastung.
@Test
public void testZinsBelastung() throws IOException {
FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexZinsBelastung.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(1));
Optional<Item> 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.INTEREST_CHARGE));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2010-12-31T00:00")));
assertThat(transaction.getAmount(), is(Values.Amount.factorize(0.20)));
assertThat(transaction.getCurrencyCode(), is("EUR"));
}
use of name.abuchen.portfolio.datatransfer.Extractor in project portfolio by buchen.
the class FinTechGroupBankPDFExtractorTest method testKontoauszug.
@Test
public void testKontoauszug() throws IOException {
FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexKontoauszug.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(1));
new AssertImportActions().check(results, CurrencyUnit.EUR);
Optional<Item> 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.DEPOSIT));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2016-01-29T00:00")));
assertThat(transaction.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 1100_00L)));
}
use of name.abuchen.portfolio.datatransfer.Extractor in project portfolio by buchen.
the class OnvistaPDFExtractorTest method testDepotauszug.
@Test
public void testDepotauszug() throws IOException {
OnvistaPDFExtractor extractor = new OnvistaPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "OnvistaDepotauszug.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(26));
// check first security
Security security = assertFirstSecurityDepotauszug(results);
// check transaction (first security, in)
Optional<Item> item = results.stream().filter(i -> i instanceof TransactionItem).findFirst();
assertThat(item.isPresent(), is(true));
assertThat(item.get().getSubject(), instanceOf(PortfolioTransaction.class));
PortfolioTransaction transaction = (PortfolioTransaction) item.get().getSubject();
assertThat(transaction.getType(), is(PortfolioTransaction.Type.DELIVERY_INBOUND));
assertThat(transaction.getSecurity(), is(security));
assertThat(transaction.getCurrencyCode(), is(CurrencyUnit.EUR));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2010-12-31T00:00")));
assertThat(transaction.getShares(), is(Values.Share.factorize(4)));
// check second security
assertSecurityErtragsgutschriftKupon(results.stream().filter(i -> i instanceof SecurityItem).collect(Collectors.toList()).get(3));
Item secondItem = results.stream().filter(i -> i instanceof TransactionItem).collect(Collectors.toList()).get(3);
// check second transaction (second security, in)
assertThat(secondItem.getSubject(), instanceOf(PortfolioTransaction.class));
PortfolioTransaction entry2 = (PortfolioTransaction) secondItem.getSubject();
assertThat(entry2.getType(), is(PortfolioTransaction.Type.DELIVERY_INBOUND));
assertThat(entry2.getCurrencyCode(), is(CurrencyUnit.EUR));
assertThat(entry2.getDateTime(), is(LocalDateTime.parse("2010-12-31T00:00")));
assertThat(entry2.getShares(), is(Values.Share.factorize(1)));
}
use of name.abuchen.portfolio.datatransfer.Extractor in project portfolio by buchen.
the class OnvistaPDFExtractorTest method testUmtausch.
@Test
public void testUmtausch() throws IOException {
OnvistaPDFExtractor extractor = new OnvistaPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "OnvistaUmtausch.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
assertSecurityBuyBezugsrechte(results);
// check delivery transaction
Optional<Item> 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_OUTBOUND));
assertThat(entry.getDateTime(), is(is(LocalDateTime.parse("2011-06-06T00:00"))));
assertThat(entry.getShares(), is(Values.Share.factorize(33)));
}
Aggregations