use of name.abuchen.portfolio.datatransfer.Extractor in project portfolio by buchen.
the class OnvistaPDFExtractorTest method testKontoauszugEinzelneBuchung.
@Test
public void testKontoauszugEinzelneBuchung() throws IOException {
OnvistaPDFExtractor extractor = new OnvistaPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "OnvistaKontoauszugEinzelneBuchung.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("2010-10-31T00:00")));
assertThat(transaction.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(37.66))));
}
use of name.abuchen.portfolio.datatransfer.Extractor in project portfolio by buchen.
the class OnvistaPDFExtractorTest method testMehrereTransaktionenInEinerDatei.
@Test
public void testMehrereTransaktionenInEinerDatei() throws IOException {
OnvistaPDFExtractor extractor = new OnvistaPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "OnvistaMultipartKaufVerkauf.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(3));
new AssertImportActions().check(results, CurrencyUnit.EUR);
List<Item> item = results.stream().filter(i -> i instanceof BuySellEntryItem).collect(Collectors.toList());
assertThat(item.isEmpty(), is(false));
Item firstItem = item.get(0);
assertNotNull(firstItem);
assertThat(firstItem.getSubject(), instanceOf(BuySellEntry.class));
BuySellEntry firstEntry = (BuySellEntry) firstItem.getSubject();
assertThat(firstEntry.getPortfolioTransaction().getType(), is(PortfolioTransaction.Type.SELL));
assertThat(firstEntry.getAccountTransaction().getType(), is(AccountTransaction.Type.SELL));
assertThat(firstEntry.getPortfolioTransaction().getCurrencyCode(), is(CurrencyUnit.EUR));
assertThat(firstEntry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(20)));
assertThat(firstEntry.getPortfolioTransaction().getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(623.49))));
assertThat(firstEntry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.of(2016, 9, 2, 9, 10)));
assertThat(firstEntry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(5))));
Item secondItem = item.get(1);
assertNotNull(secondItem);
assertThat(secondItem.getSubject(), instanceOf(BuySellEntry.class));
BuySellEntry secondEntry = (BuySellEntry) secondItem.getSubject();
assertThat(secondEntry.getPortfolioTransaction().getType(), is(PortfolioTransaction.Type.SELL));
assertThat(secondEntry.getAccountTransaction().getType(), is(AccountTransaction.Type.SELL));
assertThat(secondEntry.getPortfolioTransaction().getCurrencyCode(), is(CurrencyUnit.EUR));
assertThat(secondEntry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(80)));
assertThat(secondEntry.getPortfolioTransaction().getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(2508.47))));
assertThat(secondEntry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2016-09-02T09:10")));
assertThat(secondEntry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(1.5))));
}
use of name.abuchen.portfolio.datatransfer.Extractor in project portfolio by buchen.
the class OnvistaPDFExtractorTest method testWertpapierEinloesung.
@Test
public void testWertpapierEinloesung() throws IOException {
OnvistaPDFExtractor extractor = new OnvistaPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "OnvistaEinloesung.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
assertSecurityEinloesung(results);
// 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().getCurrencyCode(), is(CurrencyUnit.EUR));
assertThat(entry.getPortfolioTransaction().getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(51.85))));
assertThat(entry.getPortfolioTransaction().getDateTime(), is(is(LocalDateTime.parse("2014-11-17T00:00"))));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(1)));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(4.45))));
}
use of name.abuchen.portfolio.datatransfer.Extractor in project portfolio by buchen.
the class OnvistaPDFExtractorTest method testErtragsgutschriftDividende2.
@Test
public void testErtragsgutschriftDividende2() throws IOException {
OnvistaPDFExtractor extractor = new OnvistaPDFExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "OnvistaErtragsgutschriftDividende2.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(6));
// transaction #1
Security security = //
results.stream().filter(//
i -> i instanceof Extractor.SecurityItem).map(//
i -> i.getSecurity()).filter(//
s -> "FR0010296061".equals(s.getIsin())).findFirst().get();
assertThat(security.getName(), is("Lyxor ETF MSCI USA Actions au Porteur D-EUR o.N."));
AccountTransaction transaction = //
results.stream().filter(//
i -> i instanceof Extractor.TransactionItem).filter(//
i -> "FR0010296061".equals(i.getSecurity().getIsin())).map(i -> (AccountTransaction) ((Extractor.TransactionItem) i).getSubject()).findFirst().get();
assertThat(transaction.getType(), is(AccountTransaction.Type.DIVIDENDS));
assertThat(transaction.getSecurity(), is(security));
assertThat(transaction.getCurrencyCode(), is(CurrencyUnit.EUR));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2016-12-16T00:00")));
assertThat(transaction.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(1.8))));
assertThat(transaction.getShares(), is(Values.Share.factorize(1.0545)));
// transaction #2
security = //
results.stream().filter(//
i -> i instanceof Extractor.SecurityItem).map(//
i -> i.getSecurity()).filter(//
s -> "FR0010315770".equals(s.getIsin())).findFirst().get();
assertThat(security.getName(), is("Lyxor ETF MSCI WORLD FCP Actions au Port.D-EUR o.N."));
transaction = //
results.stream().filter(//
i -> i instanceof Extractor.TransactionItem).filter(//
i -> "FR0010315770".equals(i.getSecurity().getIsin())).map(i -> (AccountTransaction) ((Extractor.TransactionItem) i).getSubject()).findFirst().get();
assertThat(transaction.getType(), is(AccountTransaction.Type.DIVIDENDS));
assertThat(transaction.getSecurity(), is(security));
assertThat(transaction.getCurrencyCode(), is(CurrencyUnit.EUR));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2016-12-16T00:00")));
assertThat(transaction.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(1.8))));
assertThat(transaction.getShares(), is(Values.Share.factorize(1.2879)));
}
use of name.abuchen.portfolio.datatransfer.Extractor in project portfolio by buchen.
the class OnvistaPDFExtractorTest method testErtragsgutschriftDividende.
@Test
public void testErtragsgutschriftDividende() throws IOException {
OnvistaPDFExtractor extractor = new OnvistaPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "OnvistaErtragsgutschriftDividende.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
// check security
Security security = assertSecurityErtragsgutschriftDividende(results);
// check transaction
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.DIVIDENDS));
assertThat(transaction.getSecurity(), is(security));
assertThat(transaction.getCurrencyCode(), is(CurrencyUnit.EUR));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2016-04-21T00:00")));
assertThat(transaction.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(10.00))));
assertThat(transaction.getShares(), is(Values.Share.factorize(50)));
}
Aggregations