use of name.abuchen.portfolio.datatransfer.actions.AssertImportActions in project portfolio by buchen.
the class BankSLMPDFExtractorTest method testDividende_Inland1.
@Test
public void testDividende_Inland1() throws IOException {
BankSLMPDFExtractor extractor = new BankSLMPDFExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "BankSLM_Dividende_Inland1.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("135186"));
assertThat(security.getName(), is("Bank SLM AG"));
// 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.getDateTime(), is(LocalDateTime.parse("2016-05-02T00:00")));
assertThat(transaction.getMonetaryAmount(), is(Money.of("CHF", 18_20L)));
assertThat(transaction.getUnitSum(Unit.Type.TAX), is(Money.of("CHF", 9_80L)));
assertThat(transaction.getGrossValue(), is(Money.of("CHF", 28_00L)));
assertThat(transaction.getShares(), is(Values.Share.factorize(1)));
}
use of name.abuchen.portfolio.datatransfer.actions.AssertImportActions in project portfolio by buchen.
the class BankSLMPDFExtractorTest method testKauf_Inland1.
@Test
public void testKauf_Inland1() throws IOException {
BankSLMPDFExtractor extractor = new BankSLMPDFExtractor(new Client());
List<Exception> errors = new ArrayList<>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "BankSLM_Kauf_Inland1.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("135186"));
assertThat(security.getName(), is("Bank SLM 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(1481.10))));
assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2016-06-21T00:00")));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(1)));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("CHF", 1_10L)));
}
use of name.abuchen.portfolio.datatransfer.actions.AssertImportActions 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.actions.AssertImportActions in project portfolio by buchen.
the class DeutscheBankPDFExtractorTest method testDividendengutschriftWhenSecurityExists.
@Test
public void testDividendengutschriftWhenSecurityExists() throws IOException {
Client client = new Client();
Security security = new Security("CISCO", "US17275R1023", null, null);
client.addSecurity(security);
DeutscheBankPDFExtractor extractor = new DeutscheBankPDFExtractor(client);
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "DeutscheBankDividendengutschrift.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(1));
new AssertImportActions().check(results, CurrencyUnit.EUR);
// check transaction
AccountTransaction transaction = (AccountTransaction) results.get(0).getSubject();
assertThat(transaction.getType(), is(AccountTransaction.Type.DIVIDENDS));
assertThat(transaction.getSecurity(), is(security));
assertThat(transaction.getType(), is(AccountTransaction.Type.DIVIDENDS));
assertThat(transaction.getSecurity(), is(security));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2014-12-15T00:00")));
assertThat(transaction.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 64_88L)));
assertThat(transaction.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, 8_71 + 47 + 13_07)));
assertThat(transaction.getGrossValue(), is(Money.of(CurrencyUnit.EUR, 87_13)));
assertThat(transaction.getShares(), is(Values.Share.factorize(380)));
}
use of name.abuchen.portfolio.datatransfer.actions.AssertImportActions in project portfolio by buchen.
the class DeutscheBankPDFExtractorTest method testWertpapierVerkauf2.
@Test
public void testWertpapierVerkauf2() throws IOException {
DeutscheBankPDFExtractor extractor = new DeutscheBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "DeutscheBankVerkauf2.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
new AssertImportActions().check(results, CurrencyUnit.EUR);
assertSecurity(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().getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(453.66))));
assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2015-01-30T00:00")));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(8)));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(0))));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(7.90 + 0.60 + 2))));
}
Aggregations