use of name.abuchen.portfolio.datatransfer.pdf.ConsorsbankPDFExtractor in project portfolio by buchen.
the class ConsorsbankPDFExtractorTest method testErtragsgutschrift4.
@Test
public void testErtragsgutschrift4() throws IOException {
ConsorsbankPDFExtractor extractor = new ConsorsbankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "ConsorsbankErtragsgutschrift4.txt"), errors);
assertThat(errors, empty());
// since taxes are zero, no tax transaction must be created
assertThat(results.size(), is(2));
// check security
Security security = results.stream().filter(i -> i instanceof SecurityItem).findFirst().get().getSecurity();
assertThat(security.getWkn(), is("854242"));
assertThat(security.getName(), is("WESTPAC BANKING CORP."));
// check dividend transaction
AccountTransaction t = (AccountTransaction) results.stream().filter(i -> i instanceof TransactionItem).filter(i -> ((AccountTransaction) i.getSubject()).getType() == AccountTransaction.Type.DIVIDENDS).findFirst().get().getSubject();
assertThat(t.getDateTime(), is(LocalDateTime.parse("2015-07-02T00:00")));
assertThat(t.getShares(), is(Values.Share.factorize(1.0002)));
assertThat(t.getMonetaryAmount(), is(Money.of("EUR", 46)));
assertThat(t.getUnit(Unit.Type.GROSS_VALUE).get().getForex(), is(Money.of("AUD", 93)));
// check tax
assertThat(t.getUnitSum(Type.TAX), is(Money.of("EUR", 16)));
}
use of name.abuchen.portfolio.datatransfer.pdf.ConsorsbankPDFExtractor in project portfolio by buchen.
the class ConsorsbankPDFExtractorPDFTest method testErtragsgutschrift7_USD_Freibetrag_nicht_ausgeschoepft.
@Test
public void testErtragsgutschrift7_USD_Freibetrag_nicht_ausgeschoepft() throws IOException {
ConsorsbankPDFExtractor extractor = new ConsorsbankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
URL url = FileLocator.resolve(getClass().getResource("ConsorsbankErtragsgutschrift7_USD_Freibetrag_nicht_ausgeschoepft.pdf"));
PDFInputFile inputFile = new PDFInputFile(new File(url.getPath()));
inputFile.parse();
List<Item> results = extractor.extract(Arrays.asList(inputFile), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
// check security
Security security = results.stream().filter(i -> i instanceof SecurityItem).findFirst().get().getSecurity();
assertThat(security.getWkn(), is("200417"));
assertThat(security.getName(), is("ALTRIA GROUP INC."));
// check dividend transaction
AccountTransaction t = (AccountTransaction) results.stream().filter(i -> i instanceof TransactionItem).filter(i -> ((AccountTransaction) i.getSubject()).getType() == AccountTransaction.Type.DIVIDENDS).findFirst().get().getSubject();
assertThat(t.getDateTime(), is(LocalDateTime.parse("2016-01-11T00:00")));
assertThat(t.getShares(), is(Values.Share.factorize(650)));
assertThat(t.getMonetaryAmount(), is(Money.of("EUR", 285_60)));
assertThat(t.getUnit(Unit.Type.GROSS_VALUE).get().getForex(), is(Money.of("USD", 367_25)));
// check tax
// QUEST
assertThat(t.getUnitSum(Type.TAX), is(Money.of("EUR", 50_40)));
}
use of name.abuchen.portfolio.datatransfer.pdf.ConsorsbankPDFExtractor in project portfolio by buchen.
the class ConsorsbankPDFExtractorTest method testWertpapierKaufSparplan.
@Test
public void testWertpapierKaufSparplan() throws IOException {
ConsorsbankPDFExtractor extractor = new ConsorsbankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "ConsorsbankKaufSparplan.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(2));
new AssertImportActions().check(results, CurrencyUnit.EUR);
// check security
Optional<Item> secItem = results.stream().filter(i -> i instanceof SecurityItem).findFirst();
assertThat(secItem.isPresent(), is(true));
Security security = ((SecurityItem) secItem.get()).getSecurity();
assertThat(security.getIsin(), is("PO6527623674"));
assertThat(security.getWkn(), is("SP110Y"));
assertThat(security.getName(), is("Sparplanname"));
assertThat(security.getCurrencyCode(), is(CurrencyUnit.EUR));
// 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(CurrencyUnit.EUR, 100_00L)));
assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2016-06-15T11:07:25")));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(6.43915)));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of(CurrencyUnit.EUR, 0_00L)));
assertThat(entry.getPortfolioTransaction().getGrossPricePerShare(), is(Quote.of(CurrencyUnit.EUR, Values.Quote.factorize(15.53))));
}
use of name.abuchen.portfolio.datatransfer.pdf.ConsorsbankPDFExtractor in project portfolio by buchen.
the class ConsorsbankPDFExtractorTest method testErtragsgutschrift3.
@Test
public void testErtragsgutschrift3() throws IOException {
ConsorsbankPDFExtractor extractor = new ConsorsbankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "ConsorsbankErtragsgutschrift3.txt"), errors);
assertThat(errors, empty());
// since taxes are zero, no tax transaction must be created
assertThat(results.size(), is(2));
// check security
Security security = results.stream().filter(i -> i instanceof SecurityItem).findAny().get().getSecurity();
assertThat(security.getWkn(), is("850866"));
assertThat(security.getName(), is("DEERE & CO."));
// check dividend transaction
AccountTransaction t = (AccountTransaction) results.stream().filter(i -> i instanceof TransactionItem).filter(i -> ((AccountTransaction) i.getSubject()).getType() == AccountTransaction.Type.DIVIDENDS).findAny().get().getSubject();
assertThat(t.getDateTime(), is(LocalDateTime.parse("2015-11-02T00:00")));
assertThat(t.getShares(), is(Values.Share.factorize(300)));
assertThat(t.getMonetaryAmount(), is(Money.of("EUR", 121_36)));
assertThat(t.getUnit(Unit.Type.GROSS_VALUE).get().getForex(), is(Money.of("USD", 180_00)));
// check tax
assertThat(t.getUnitSum(Type.TAX), is(Money.of("EUR", 16_30 + 89 + 24_45)));
}
use of name.abuchen.portfolio.datatransfer.pdf.ConsorsbankPDFExtractor in project portfolio by buchen.
the class ConsorsbankPDFExtractorTest method testErtragsgutschrift10WithExistingSecurityInTransactionCurrency.
@Test
public void testErtragsgutschrift10WithExistingSecurityInTransactionCurrency() throws IOException {
Client client = new Client();
Security security = new Security("Omnicom", CurrencyUnit.EUR);
security.setIsin("US6819191064");
client.addSecurity(security);
ConsorsbankPDFExtractor extractor = new ConsorsbankPDFExtractor(client);
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "ConsorsbankErtragsgutschrift10.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(1));
AccountTransaction t = //
results.stream().filter(i -> i instanceof TransactionItem).map(//
i -> (AccountTransaction) ((TransactionItem) i).getSubject()).findAny().get();
assertThat(t.getSecurity(), is(security));
assertThat(t.getDateTime(), is(LocalDateTime.parse("2018-01-09T00:00")));
assertThat(t.getShares(), is(Values.Share.factorize(25)));
assertThat(t.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(9.34))));
assertThat(t.getUnit(Unit.Type.GROSS_VALUE).isPresent(), is(false));
assertThat(t.getGrossValue(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(12.54))));
assertThat(t.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(0.06 + 1.26 + 1.88))));
}
Aggregations