use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem 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.Extractor.TransactionItem 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.Extractor.TransactionItem 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))));
}
use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem in project portfolio by buchen.
the class ConsorsbankPDFExtractorTest method testErtragsgutschrift9.
@Test
public void testErtragsgutschrift9() throws IOException {
ConsorsbankPDFExtractor extractor = new ConsorsbankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "ConsorsbankErtragsgutschrift9.txt"), 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("A1409D"));
assertThat(security.getName(), is("Welltower 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-05-20T00:00")));
assertThat(t.getShares(), is(Values.Share.factorize(50)));
assertThat(t.getMonetaryAmount(), is(Money.of("EUR", 32_51)));
assertThat(t.getGrossValue(), is(Money.of("EUR", 38_25)));
// check tax
assertThat(t.getUnitSum(Type.TAX), is(Money.of("EUR", 5_74)));
checkCurrency(CurrencyUnit.EUR, t);
}
use of name.abuchen.portfolio.datatransfer.Extractor.TransactionItem in project portfolio by buchen.
the class ConsorsbankPDFExtractorTest method testErtragsgutschrift8WithExistingSecurity.
@Test
public void testErtragsgutschrift8WithExistingSecurity() throws IOException {
Client client = new Client();
ConsorsbankPDFExtractor extractor = new ConsorsbankPDFExtractor(client);
Security existingSecurity = new Security("ROCHE HOLDING AG", CurrencyUnit.EUR);
existingSecurity.setWkn("891106");
client.addSecurity(existingSecurity);
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "ConsorsbankErtragsgutschrift8.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(1));
// 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.getSecurity(), is(existingSecurity));
assertThat(t.getDateTime(), is(LocalDateTime.parse("2014-04-22T00:00")));
assertThat(t.getShares(), is(Values.Share.factorize(80)));
assertThat(t.getMonetaryAmount(), is(Money.of("EUR", 33_51)));
assertThat(t.getGrossValue(), is(Money.of("EUR", 64_08)));
// check tax
assertThat(t.getUnitSum(Type.TAX), is(Money.of("EUR", 30_57)));
checkCurrency(CurrencyUnit.EUR, t);
}
Aggregations