use of name.abuchen.portfolio.datatransfer.Extractor in project portfolio by buchen.
the class ReviewExtractedItemsPage method createControl.
@Override
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
setControl(container);
container.setLayout(new FormLayout());
Composite targetContainer = new Composite(container, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(4).applyTo(targetContainer);
lblPrimaryAccount = new Label(targetContainer, SWT.NONE);
lblPrimaryAccount.setText(Messages.ColumnAccount);
Combo cmbAccount = new Combo(targetContainer, SWT.READ_ONLY);
primaryAccount = new ComboViewer(cmbAccount);
primaryAccount.setContentProvider(ArrayContentProvider.getInstance());
primaryAccount.setInput(client.getActiveAccounts());
primaryAccount.addSelectionChangedListener(e -> checkEntriesAndRefresh(allEntries));
lblSecondaryAccount = new Label(targetContainer, SWT.NONE);
lblSecondaryAccount.setText(Messages.LabelTransferTo);
lblSecondaryAccount.setVisible(false);
Combo cmbAccountTarget = new Combo(targetContainer, SWT.READ_ONLY);
secondaryAccount = new ComboViewer(cmbAccountTarget);
secondaryAccount.setContentProvider(ArrayContentProvider.getInstance());
secondaryAccount.setInput(client.getActiveAccounts());
secondaryAccount.getControl().setVisible(false);
lblPrimaryPortfolio = new Label(targetContainer, SWT.NONE);
lblPrimaryPortfolio.setText(Messages.ColumnPortfolio);
Combo cmbPortfolio = new Combo(targetContainer, SWT.READ_ONLY);
primaryPortfolio = new ComboViewer(cmbPortfolio);
primaryPortfolio.setContentProvider(ArrayContentProvider.getInstance());
primaryPortfolio.setInput(client.getActivePortfolios());
primaryPortfolio.addSelectionChangedListener(e -> checkEntriesAndRefresh(allEntries));
lblSecondaryPortfolio = new Label(targetContainer, SWT.NONE);
lblSecondaryPortfolio.setText(Messages.LabelTransferTo);
lblSecondaryPortfolio.setVisible(false);
Combo cmbPortfolioTarget = new Combo(targetContainer, SWT.READ_ONLY);
secondaryPortfolio = new ComboViewer(cmbPortfolioTarget);
secondaryPortfolio.setContentProvider(ArrayContentProvider.getInstance());
secondaryPortfolio.setInput(client.getActivePortfolios());
secondaryPortfolio.getControl().setVisible(false);
lblImportAssistantExtractor = new Label(targetContainer, SWT.NONE);
lblImportAssistantExtractor.setText(Messages.PDFImportWizardExtractor);
Combo cmbImportAssistantExtractor = new Combo(targetContainer, SWT.READ_ONLY);
comboExtractors = new ComboViewer(cmbImportAssistantExtractor);
comboExtractors.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((Extractor) element).getLabel();
}
});
comboExtractors.addSelectionChangedListener(e -> runExtractionJob());
if (extractor instanceof AssistantPDFExtractor) {
List<Extractor> extractors = ((AssistantPDFExtractor) extractor).getAvailableExtractors();
comboExtractors.add(extractors.toArray());
} else {
lblImportAssistantExtractor.setVisible(false);
comboExtractors.getCombo().setVisible(false);
}
preselectDropDowns();
cbConvertToDelivery = new Button(container, SWT.CHECK);
cbConvertToDelivery.setText(Messages.LabelConvertBuySellIntoDeliveryTransactions);
Composite compositeTable = new Composite(container, SWT.NONE);
Composite errorTable = new Composite(container, SWT.NONE);
//
// form layout
//
//
FormDataFactory.startingWith(targetContainer).top(new FormAttachment(0, 0)).left(new FormAttachment(0, 0)).right(new FormAttachment(100, 0)).thenBelow(//
cbConvertToDelivery).thenBelow(compositeTable).right(targetContainer).bottom(//
new FormAttachment(80, 0)).thenBelow(errorTable).right(targetContainer).bottom(new FormAttachment(100, 0));
//
// table & columns
//
TableColumnLayout layout = new TableColumnLayout();
compositeTable.setLayout(layout);
tableViewer = new TableViewer(compositeTable, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
Table table = tableViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
addColumns(tableViewer, layout);
attachContextMenu(table);
layout = new TableColumnLayout();
errorTable.setLayout(layout);
errorTableViewer = new TableViewer(errorTable, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
errorTableViewer.setContentProvider(ArrayContentProvider.getInstance());
table = errorTableViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
addColumnsExceptionTable(errorTableViewer, layout);
}
use of name.abuchen.portfolio.datatransfer.Extractor in project portfolio by buchen.
the class FinTechGroupBankPDFExtractorTest method testKontoauszug2.
@Test
public void testKontoauszug2() throws IOException {
FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexKontoauszug2.txt"), errors);
assertThat(errors, empty());
assertThat(results.size(), is(1));
new AssertImportActions().check(results, CurrencyUnit.EUR);
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.REMOVAL));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2016-01-26T00:00")));
assertThat(transaction.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 15000_00L)));
}
use of name.abuchen.portfolio.datatransfer.Extractor in project portfolio by buchen.
the class FinTechGroupBankPDFExtractorTest method testZinsgutschriftInland.
@Test
public void testZinsgutschriftInland() throws IOException {
FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexZinsgutschriftInland.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("DE1234567890"));
assertThat(security.getWkn(), is("AB1234"));
assertThat(security.getName(), is("ISH.FOOBAR 12345666 x.EFT"));
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-04-28T00:00")));
assertThat(transaction.getAmount(), is(Values.Amount.factorize(73.75)));
assertThat(transaction.getShares(), is(Values.Share.factorize(1000)));
}
use of name.abuchen.portfolio.datatransfer.Extractor in project portfolio by buchen.
the class FinTechGroupBankPDFExtractorTest method testWertpapierKauf11.
@Test
public void testWertpapierKauf11() throws IOException {
FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexKauf11.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("IE00B6YX5D40"));
assertThat(security.getWkn(), is("A1JKS0"));
assertThat(security.getName(), is("SPDR S+P US DIV.ARIST.ETF"));
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(1.5))));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(22.973458)));
}
use of name.abuchen.portfolio.datatransfer.Extractor in project portfolio by buchen.
the class FinTechGroupBankPDFExtractorTest method testWertpapierKauf6.
@Test
public void testWertpapierKauf6() throws IOException {
FinTechGroupBankPDFExtractor extractor = new FinTechGroupBankPDFExtractor(new Client());
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "FlatexKauf6.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("IE00B2NPKV68"));
assertThat(security.getWkn(), is("A0NECU"));
assertThat(security.getName(), is("ISHSII-JPM DL EM BD DLDIS"));
PortfolioTransaction transaction = results.stream().filter(i -> i instanceof Extractor.BuySellEntryItem).map(i -> (BuySellEntry) ((Extractor.BuySellEntryItem) i).getSubject()).map(b -> b.getPortfolioTransaction()).findAny().get();
assertThat(transaction.getType(), is(PortfolioTransaction.Type.BUY));
assertThat(transaction.getAmount(), is(Values.Amount.factorize(1000)));
assertThat(transaction.getDateTime(), is(LocalDateTime.parse("2017-06-15T00:00")));
assertThat(transaction.getUnitSum(Unit.Type.FEE), is(Money.of("EUR", Values.Amount.factorize(0.9))));
assertThat(transaction.getShares(), is(Values.Share.factorize(9.703363)));
}
Aggregations