Search in sources :

Example 26 with FinTechGroupBankPDFExtractor

use of name.abuchen.portfolio.datatransfer.pdf.FinTechGroupBankPDFExtractor in project portfolio by buchen.

the class FinTechGroupBankPDFExtractorTest method testWertpapierVerkaufSteuererstattung.

@Test
public void testWertpapierVerkaufSteuererstattung() throws IOException {
    FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexVerkaufSteuererstattung.txt"), errors);
    assertThat(errors, empty());
    assertThat(results.size(), is(3));
    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("DE000SKWM021"));
    assertThat(security.getWkn(), is("SKWM02"));
    assertThat(security.getName(), is("SKW STAHL-METAL.HLDG.NA"));
    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(1253.15)));
    assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2016-09-08T00:00")));
    assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("EUR", Values.Amount.factorize(11.85))));
    assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(460)));
    // check Steuererstattung
    Item itemTaxReturn = results.stream().filter(i -> i instanceof TransactionItem).collect(Collectors.toList()).get(0);
    // Optional<Item> itemTaxReturn = results.stream().filter(i -> i
    // instanceof TransactionItem).findFirst();
    AccountTransaction entryTaxReturn = (AccountTransaction) itemTaxReturn.getSubject();
    assertThat(entryTaxReturn.getType(), is(AccountTransaction.Type.TAX_REFUND));
    assertThat(entryTaxReturn.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(463.04))));
    assertThat(entryTaxReturn.getDateTime(), is(LocalDateTime.parse("2016-09-08T00:00")));
}
Also used : SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) FinTechGroupBankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.FinTechGroupBankPDFExtractor) ArrayList(java.util.ArrayList) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Security(name.abuchen.portfolio.model.Security) IOException(java.io.IOException) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) Item(name.abuchen.portfolio.datatransfer.Extractor.Item) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) Client(name.abuchen.portfolio.model.Client) Test(org.junit.Test)

Example 27 with FinTechGroupBankPDFExtractor

use of name.abuchen.portfolio.datatransfer.pdf.FinTechGroupBankPDFExtractor in project portfolio by buchen.

the class FinTechGroupBankPDFExtractorTest method testWertpapierBestandsausbuchungNeuesFormat.

@Test
public void testWertpapierBestandsausbuchungNeuesFormat() throws IOException {
    FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexBestandsausbuchung2.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("DE000SG0WRD3"));
    assertThat(security.getWkn(), is("SG0WRD"));
    assertThat(security.getName(), is("SG EFF. TURBOL ZS"));
    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(111.22)));
    assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2015-09-28T00:00")));
    assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(83)));
}
Also used : SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) Item(name.abuchen.portfolio.datatransfer.Extractor.Item) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) FinTechGroupBankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.FinTechGroupBankPDFExtractor) ArrayList(java.util.ArrayList) Client(name.abuchen.portfolio.model.Client) Security(name.abuchen.portfolio.model.Security) IOException(java.io.IOException) Test(org.junit.Test)

Example 28 with FinTechGroupBankPDFExtractor

use of name.abuchen.portfolio.datatransfer.pdf.FinTechGroupBankPDFExtractor in project portfolio by buchen.

the class FinTechGroupBankPDFExtractorTest method testWertpapierVerkauf4.

@Test
public void testWertpapierVerkauf4() throws IOException {
    FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexVerkauf4.txt"), errors);
    assertThat(errors, empty());
    assertThat(results.size(), is(2));
    List<PortfolioTransaction> tx = // 
    results.stream().filter(i -> i instanceof BuySellEntryItem).map(i -> ((BuySellEntry) i.getSubject()).getPortfolioTransaction()).collect(Collectors.toList());
    assertThat(tx.size(), is(1));
    assertThat(tx, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2018-01-09T00:00"))), // 
    hasProperty("type", is(PortfolioTransaction.Type.SELL)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(0.95)))))));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) Client(name.abuchen.portfolio.model.Client) Quote(name.abuchen.portfolio.money.Quote) Item(name.abuchen.portfolio.datatransfer.Extractor.Item) CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) LocalDateTime(java.time.LocalDateTime) IsEmptyCollection.empty(org.hamcrest.collection.IsEmptyCollection.empty) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) ArrayList(java.util.ArrayList) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) Assert.assertThat(org.junit.Assert.assertThat) FinTechGroupBankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.FinTechGroupBankPDFExtractor) Extractor(name.abuchen.portfolio.datatransfer.Extractor) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) CoreMatchers.allOf(org.hamcrest.CoreMatchers.allOf) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) PDFInputFile(name.abuchen.portfolio.datatransfer.pdf.PDFInputFile) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) IOException(java.io.IOException) Test(org.junit.Test) Security(name.abuchen.portfolio.model.Security) Collectors(java.util.stream.Collectors) List(java.util.List) AssertImportActions(name.abuchen.portfolio.datatransfer.actions.AssertImportActions) Unit(name.abuchen.portfolio.model.Transaction.Unit) Optional(java.util.Optional) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) Item(name.abuchen.portfolio.datatransfer.Extractor.Item) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) FinTechGroupBankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.FinTechGroupBankPDFExtractor) ArrayList(java.util.ArrayList) Client(name.abuchen.portfolio.model.Client) IOException(java.io.IOException) Test(org.junit.Test)

Example 29 with FinTechGroupBankPDFExtractor

use of name.abuchen.portfolio.datatransfer.pdf.FinTechGroupBankPDFExtractor in project portfolio by buchen.

the class FinTechGroupBankPDFExtractorTest method testWertpapierKauf10.

@Test
public void testWertpapierKauf10() throws IOException {
    FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexKauf10.txt"), errors);
    assertThat(errors, empty());
    assertThat(results.size(), is(2));
    // 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("LU0274211480"));
    assertThat(security.getWkn(), is("DBX1DA"));
    assertThat(security.getName(), is("DB X-TRACK.DAX ETF(DR)1C"));
    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(1000.00)));
    assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2018-01-02T00:00")));
    assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE), is(Money.of("EUR", Values.Amount.factorize(0))));
    assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(7.979324)));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) Client(name.abuchen.portfolio.model.Client) Quote(name.abuchen.portfolio.money.Quote) Item(name.abuchen.portfolio.datatransfer.Extractor.Item) CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) LocalDateTime(java.time.LocalDateTime) IsEmptyCollection.empty(org.hamcrest.collection.IsEmptyCollection.empty) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) ArrayList(java.util.ArrayList) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) Assert.assertThat(org.junit.Assert.assertThat) FinTechGroupBankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.FinTechGroupBankPDFExtractor) Extractor(name.abuchen.portfolio.datatransfer.Extractor) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) CoreMatchers.allOf(org.hamcrest.CoreMatchers.allOf) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) PDFInputFile(name.abuchen.portfolio.datatransfer.pdf.PDFInputFile) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) IOException(java.io.IOException) Test(org.junit.Test) Security(name.abuchen.portfolio.model.Security) Collectors(java.util.stream.Collectors) List(java.util.List) AssertImportActions(name.abuchen.portfolio.datatransfer.actions.AssertImportActions) Unit(name.abuchen.portfolio.model.Transaction.Unit) Optional(java.util.Optional) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) FinTechGroupBankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.FinTechGroupBankPDFExtractor) ArrayList(java.util.ArrayList) Security(name.abuchen.portfolio.model.Security) IOException(java.io.IOException) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) Item(name.abuchen.portfolio.datatransfer.Extractor.Item) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) Client(name.abuchen.portfolio.model.Client) Test(org.junit.Test)

Example 30 with FinTechGroupBankPDFExtractor

use of name.abuchen.portfolio.datatransfer.pdf.FinTechGroupBankPDFExtractor in project portfolio by buchen.

the class FinTechGroupBankPDFExtractorTest method testGutschriftsBelastungsanzeige.

@Test
public void testGutschriftsBelastungsanzeige() throws IOException {
    FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexGutschriftsBelastungsanzeige.txt"), errors);
    assertThat(errors, empty());
    assertThat(results.size(), is(20));
    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("DE0008474503"));
    assertThat(security.getName(), is("DEKAFONDS CF"));
    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(5.50)));
    assertThat(entry.getDateTime(), is(LocalDateTime.parse("2015-02-16T00:00")));
    assertThat(entry.getShares(), is(Values.Share.factorize(0.0520)));
}
Also used : SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) Item(name.abuchen.portfolio.datatransfer.Extractor.Item) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) BuySellEntryItem(name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) FinTechGroupBankPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.FinTechGroupBankPDFExtractor) ArrayList(java.util.ArrayList) Client(name.abuchen.portfolio.model.Client) Security(name.abuchen.portfolio.model.Security) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

FinTechGroupBankPDFExtractor (name.abuchen.portfolio.datatransfer.pdf.FinTechGroupBankPDFExtractor)33 IOException (java.io.IOException)32 ArrayList (java.util.ArrayList)32 BuySellEntryItem (name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem)32 Item (name.abuchen.portfolio.datatransfer.Extractor.Item)32 SecurityItem (name.abuchen.portfolio.datatransfer.Extractor.SecurityItem)32 TransactionItem (name.abuchen.portfolio.datatransfer.Extractor.TransactionItem)32 Client (name.abuchen.portfolio.model.Client)32 Security (name.abuchen.portfolio.model.Security)32 CoreMatchers.hasItem (org.hamcrest.CoreMatchers.hasItem)32 Test (org.junit.Test)32 BuySellEntry (name.abuchen.portfolio.model.BuySellEntry)29 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)23 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)21 LocalDateTime (java.time.LocalDateTime)20 List (java.util.List)20 Optional (java.util.Optional)20 Collectors (java.util.stream.Collectors)20 Extractor (name.abuchen.portfolio.datatransfer.Extractor)20 AssertImportActions (name.abuchen.portfolio.datatransfer.actions.AssertImportActions)20