use of name.abuchen.portfolio.model.Security in project portfolio by buchen.
the class FinTechGroupBankPDFExtractorTest method testWertpapierÜbertrag1.
@Test
public void testWertpapierÜbertrag1() throws IOException {
FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexDepoteingang1.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.getIsin(), is("DE000US9RGR9"));
assertThat(security.getName(), is("UBS AG LONDON 14/16 RWE"));
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_INBOUND));
assertThat(entry.getAmount(), is(Values.Amount.factorize(7517.50)));
assertThat(entry.getDateTime(), is(LocalDateTime.parse("2015-11-24T00:00")));
assertThat(entry.getShares(), is(Values.Share.factorize(250)));
}
use of name.abuchen.portfolio.model.Security in project portfolio by buchen.
the class FinTechGroupBankPDFExtractorTest method testWertpapierVerkauf.
@Test
public void testWertpapierVerkauf() throws IOException {
FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexVerkauf.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.getIsin(), is("DE000US9RGR9"));
assertThat(security.getWkn(), is("US9RGR"));
assertThat(security.getName(), is("UBS AG LONDON 14/16 RWE"));
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(16508.16)));
assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2016-01-22T00: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(250)));
}
use of name.abuchen.portfolio.model.Security 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.model.Security in project portfolio by buchen.
the class FinTechGroupBankPDFExtractorTest method testWertpapierKauf9Sammelabrechnung.
@Test
public void testWertpapierKauf9Sammelabrechnung() throws IOException {
FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexKauf9Sammelabrechnung.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.getIsin(), is("DE000A1MECS1"));
assertThat(security.getWkn(), is("A1MECS"));
assertThat(security.getName(), is("SOURCE PHY.MRKT.ETC00 XAU"));
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(2.72)));
assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2018-01-09T00:00")));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("EUR", Values.Amount.factorize(0))));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(0.025361)));
}
use of name.abuchen.portfolio.model.Security in project portfolio by buchen.
the class HelloBankPDFExtractorTest method testErtrag01.
@Test
public void testErtrag01() throws IOException {
HelloBankPDFExtractor extractor = new HelloBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "Ertrag01.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("NO0003054108"));
assertThat(security.getName(), is("M a r i n e H a r v est ASA"));
assertThat(security.getCurrencyCode(), is("NOK"));
// check transaction
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-09-06T00:00")));
assertThat(transaction.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(48.71))));
assertThat(transaction.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(0.95 + 0.19 + (176.01 / 9.308)))));
assertThat(transaction.getShares(), is(Values.Share.factorize(200)));
Unit grossValueUnit = transaction.getUnit(Unit.Type.GROSS_VALUE).get();
assertThat(grossValueUnit.getAmount(), is(Money.of("EUR", Values.Amount.factorize(640 / 9.308))));
assertThat(grossValueUnit.getForex(), is(Money.of("NOK", Values.Amount.factorize(640))));
assertThat(grossValueUnit.getExchangeRate(), is(BigDecimal.ONE.divide(BigDecimal.valueOf(9.308), 10, BigDecimal.ROUND_HALF_UP)));
assertThat(grossValueUnit.getAmount().getAmount() - transaction.getUnitSum(Unit.Type.TAX).getAmount(), is(transaction.getMonetaryAmount().getAmount()));
}
Aggregations