use of name.abuchen.portfolio.model.BuySellEntry in project portfolio by buchen.
the class FinTechGroupBankPDFExtractorTest method assertSecondTransactionBestandsausbuchung.
private void assertSecondTransactionBestandsausbuchung(Item item) {
assertThat(item.getSubject(), instanceOf(BuySellEntry.class));
BuySellEntry entry = (BuySellEntry) item.getSubject();
assertThat(entry.getPortfolioTransaction().getType(), is(PortfolioTransaction.Type.TRANSFER_OUT));
assertThat(entry.getAccountTransaction().getType(), is(AccountTransaction.Type.TRANSFER_OUT));
assertThat(entry.getPortfolioTransaction().getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 0_00L)));
assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2010-03-16T00:00")));
assertThat(entry.getPortfolioTransaction().getShares(), is(1250_000000L));
}
use of name.abuchen.portfolio.model.BuySellEntry 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.BuySellEntry 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.BuySellEntry 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.BuySellEntry in project portfolio by buchen.
the class HelloBankPDFExtractorTest method testKauf01.
@Test
public void testKauf01() throws IOException {
HelloBankPDFExtractor extractor = new HelloBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "Kauf01.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 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))));
Unit grossValueUnit = tx.getUnit(Unit.Type.GROSS_VALUE).get();
assertThat(grossValueUnit.getAmount(), is(Money.of("EUR", Values.Amount.factorize(1092.14))));
assertThat(grossValueUnit.getForex(), is(Money.of("NOK", Values.Amount.factorize(10360))));
assertThat(grossValueUnit.getExchangeRate(), is(BigDecimal.ONE.divide(BigDecimal.valueOf(9.486), 10, BigDecimal.ROUND_HALF_UP)));
}
Aggregations