Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature currencies CSV export and import #322

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1115747
Initial Version of Interactive Brokers FlexStatement Importer
alani1 Jun 2, 2015
ff1bd4d
Minor changes to the import of Interactive Brokers Activity Statements
buchen Jun 5, 2015
2b7ad48
some small typos I just noticed while testing the application.
sebasbaumh Jun 10, 2015
d3ac832
additions for typo.
sebasbaumh Jun 10, 2015
cf92a0b
Merge pull request #312 from sebasbaumh/typoHistoricalDate
buchen Jun 11, 2015
31bbe47
Enhancements for CSV Importer
sebasbaumh Jun 10, 2015
30a3b81
Merge pull request #313
buchen Jun 11, 2015
5592f99
Updated about text with new contributions
buchen Jun 11, 2015
8226cde
* correctly throw exceptions for unsupported transactions interest pa…
alani1 Jun 12, 2015
113a42e
Prevent auto-update if update information indicates it is not support…
buchen Jun 13, 2015
a0ad458
* fix typo Broker Interest Received
alani1 Jun 13, 2015
e504827
* fix Testcase for IBActivitystatement.xml
alani1 Jun 13, 2015
c2ed1fb
Merge pull request #314 from alainschaefer/feature_interactive_brokers
buchen Jun 15, 2015
5469043
Merge pull request #315 from buchen/feature_interactive_brokers
buchen Jun 15, 2015
6c202fd
Add currency support to CSVExporter
alani1 Jun 20, 2015
c57bfa8
handle null Forex object in PortfolioTransaction
alani1 Jun 20, 2015
cfb346e
Merge branch 'master' into feature_currencies
buchen Jun 20, 2015
cb3c381
Add currency support to CSVExporter
alani1 Jun 20, 2015
3688922
handle null Forex object in PortfolioTransaction
alani1 Jun 20, 2015
6072673
add currency support to CSVImporter and CrossEntryCheck
alani1 Jun 20, 2015
1bbfce4
resolve merge conflict on message.properties
alani1 Jun 20, 2015
d77e48d
swapped labels for currency/basecurrency in CSVExport
alani1 Jun 20, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions name.abuchen.portfolio.bootstrap/Application.e4xmi
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
<children xsi:type="menu:HandledMenuItem" xmi:id="_VDIBcALOEeW4ucTlYYYvbw" elementId="name.abuchen.portfolio.ui.menu.file.import.flatex" label="%command.import.pdf.flatex" command="_pgC00EYREeSRXYVe298mXg">
<parameters xmi:id="_VDIBcQLOEeW4ucTlYYYvbw" elementId="" name="name.abuchen.portfolio.ui.param.pdf-type" value="flatex"/>
</children>
<children xsi:type="menu:MenuSeparator" xmi:id="_30NnAAtvEeW4ucTlYYYvbw" elementId="name.abuchen.portfolio.bootstrap.menuseparator.2"/>
<children xsi:type="menu:DirectMenuItem" xmi:id="_24C5sAtvEeW4ucTlYYYvbw" elementId="name.abuchen.portfolio.ui.menu.file.import.import-xml" label="%command.import.xml.import-xml" enabled="false"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_EbXUwAtwEeW4ucTlYYYvbw" elementId="name.abuchen.portfolio.ui.menu.file.import.ib" label="%command.import.xml.ib" command="_pgC00EYREeSRXYVe298mXg">
<parameters xmi:id="_EbXUwQtwEeW4ucTlYYYvbw" elementId="" name="name.abuchen.portfolio.ui.param.pdf-type" value="ib"/>
</children>
<children xsi:type="menu:MenuSeparator" xmi:id="_gNzZUPr7EeS4ucTlYYYvbw" elementId="name.abuchen.portfolio.bootstrap.menuseparator.1"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_C1cmoLptEeSHOs-ah25CLg" elementId="name.abuchen.portfolio.ui.menu.file.import.create-text" label="%command.import.pdf.create-text" command="_Jw7yELptEeSHOs-ah25CLg"/>
</children>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ command.import.pdf.dab = DAB Bank
command.import.pdf.db = Deutsche Bank
command.import.pdf.flatex = Flatex
command.import.pdf.import-pdf = PDF Documents (experimental)
command.import.xml.ib = Interactive Brokers Activity Statement
command.import.xml.import-xml = XML Documents (experimental)
command.newFile.mnemonic = N
command.newFile.name = New...
command.openFile.mnemonic = O
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ command.import.pdf.dab = DAB Bank
command.import.pdf.db = Deutsche Bank
command.import.pdf.flatex = Flatex
command.import.pdf.import-pdf = PDF Dokumente (experimentell)
command.import.xml.ib = Interactive Brokers Activity Statement
command.import.xml.import-xml = XML Dokumente (experimentell)
command.newFile.mnemonic = N
command.newFile.name = Neu...
command.openFile.mnemonic = O
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package name.abuchen.portfolio.datatransfer;

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem;
import name.abuchen.portfolio.datatransfer.Extractor.Item;
import name.abuchen.portfolio.datatransfer.Extractor.SecurityItem;
import name.abuchen.portfolio.model.AccountTransaction;
import name.abuchen.portfolio.model.BuySellEntry;
import name.abuchen.portfolio.model.Client;
import name.abuchen.portfolio.model.PortfolioTransaction;
import name.abuchen.portfolio.model.Security;
import name.abuchen.portfolio.util.Dates;

import org.junit.Test;

@SuppressWarnings("nls")
public class IBFlexStatementExtractorTest
{

private InputStream activityStatement;
private InputStream otherFile;

public IBFlexStatementExtractorTest()
{
activityStatement = getClass().getResourceAsStream("IBActivityStatement.xml");
otherFile = getClass().getResourceAsStream("Gutschrift.txt");
}

@Test
public void testIBAcitvityStatement() throws IOException
{

Client client = new Client();
IBFlexStatementExtractor extractor = new IBFlexStatementExtractor(client);
List<Exception> errors = new ArrayList<Exception>();
extractor.importActivityStatement(activityStatement, errors);
List<Item> results = extractor.getResults();

// 1 Error Messages for negative interest which is not yet supported
assertThat(errors.size(), is(1));
assertThat(results.size(), is(25));

assertFirstSecurity(results.stream().filter(i -> i instanceof SecurityItem).findFirst());
assertFirstTransaction(results.stream().filter(i -> i instanceof BuySellEntryItem).findFirst());

assertSecondSecurity(results.stream().filter(i -> i instanceof SecurityItem)
.reduce((previous, current) -> current).get());
assertFourthTransaction(results.stream().filter(i -> i instanceof BuySellEntryItem).skip(3).findFirst());

// TODO Check CorporateActions
}

private void assertFirstSecurity(Optional<Item> item)
{
assertThat(item.isPresent(), is(true));
Security security = ((SecurityItem) item.get()).getSecurity();
assertThat(security.getIsin(), is("CA38501D2041"));
assertThat(security.getWkn(), is("80845553"));
assertThat(security.getName(), is("GRAN COLOMBIA GOLD CORP"));
assertThat(security.getTickerSymbol(), is("GCM.TO"));
}

private void assertSecondSecurity(Item item)
{
// Why is the second Security the GCM after Split ??? expected to be UUU
Security security = ((SecurityItem) item).getSecurity();
assertThat(security.getIsin(), is("CA38501D5010"));
assertThat(security.getWkn(), is("129258970"));
assertThat(security.getName(),
is("GCM(CA38501D2041) SPLIT 1 FOR 25 (GCM, GRAN COLOMBIA GOLD CORP, CA38501D5010)"));

// setting GCM.TO as ticker symbol
// currently fails because the exchange is empty in corporate actions.
}

private void assertFirstTransaction(Optional<Item> item)
{
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().getSecurity().getName(), is("GRAN COLOMBIA GOLD CORP"));
assertThat(entry.getPortfolioTransaction().getAmount(), is(1356_75L));
assertThat(entry.getPortfolioTransaction().getDate(), is(Dates.date("2013-04-01")));
assertThat(entry.getPortfolioTransaction().getShares(), is(5000_000000L));
assertThat(entry.getPortfolioTransaction().getFees(), is(6_75L));
assertThat(entry.getPortfolioTransaction().getActualPurchasePrice(), is(27L));

}

private void assertFourthTransaction(Optional<Item> item)
{
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().getSecurity().getName(), is("URANIUM ONE INC."));
assertThat(entry.getPortfolioTransaction().getAmount(), is(232_00L));
assertThat(entry.getPortfolioTransaction().getDate(), is(Dates.date("2013-01-02")));
assertThat(entry.getPortfolioTransaction().getShares(), is(100_000000L));
assertThat(entry.getPortfolioTransaction().getFees(), is(1_00L));
}

@Test
public void testThatExceptionIsAddedForNonFlexStatementDocuments() throws IOException
{
Client client = new Client();
IBFlexStatementExtractor extractor = new IBFlexStatementExtractor(client);
List<Exception> errors = new ArrayList<Exception>();
extractor.importActivityStatement(otherFile, errors);
List<Item> results = extractor.getResults();

assertThat(results.isEmpty(), is(true));
assertThat(errors.size(), is(1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import name.abuchen.portfolio.datatransfer.DeutscheBankPDFExctractor;
import name.abuchen.portfolio.datatransfer.Extractor;
import name.abuchen.portfolio.datatransfer.FlatexPDFExctractor;
import name.abuchen.portfolio.datatransfer.IBFlexStatementExtractor;
import name.abuchen.portfolio.model.Client;
import name.abuchen.portfolio.ui.wizards.datatransfer.ImportExtractedItemsWizard;

Expand Down Expand Up @@ -64,6 +65,9 @@ public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart part,
case "flatex": //$NON-NLS-1$
extractor = new FlatexPDFExctractor(client);
break;
case "ib": //$NON-NLS-1$
extractor = new IBFlexStatementExtractor(client);
break;
default:
throw new UnsupportedOperationException("Unknown pdf type: " + type); //$NON-NLS-1$
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

AboutText = Portfolio Performance\n\nVersion {0}\n\n(c) Copyright Andreas Buchen 2012 - 2015. All rights reserved.\n\nWith contributions by simpsus, jahzoo, gynngr, nistude, mwhesse, derari and necoro.\n\nThis product includes software developed by the\n Eclipse Foundation http://eclipse.org/\n Apache Software Foundation http://apache.org/\n SWT Chart Project http://www.swtchart.org/\n Tree Map Library http://code.google.com/p/treemaplib/\n jsoup Java HTML Parser http://jsoup.org\n JSON.simple https://code.google.com/p/json-simple/\n D3.js http://d3js.org\n\nSome icons are based on\n FatCow Hosting Icons http://www.fatcow.com/free-icons\n (Creative Commons Attribution 3.0 United States)\n iconmonstr http://iconmonstr.com\n\nThis product is published under the Eclipse Public License\nhttp://www.eclipse.org/legal/epl-v10.html
AboutText = Portfolio Performance\n\nVersion {0}\n\n(c) Copyright Andreas Buchen 2012 - 2015. All rights reserved.\n\nWith contributions by simpsus, jahzoo, gynngr, nistude, mwhesse,\n derari, necoro, alainschaefer and sebasbaumh.\n\nThis product includes software developed by the\n Eclipse Foundation http://eclipse.org/\n Apache Software Foundation http://apache.org/\n SWT Chart Project http://www.swtchart.org/\n Tree Map Library http://code.google.com/p/treemaplib/\n jsoup Java HTML Parser http://jsoup.org\n JSON.simple https://code.google.com/p/json-simple/\n D3.js http://d3js.org\n\nSome icons are based on\n FatCow Hosting Icons http://www.fatcow.com/free-icons\n (Creative Commons Attribution 3.0 United States)\n iconmonstr http://iconmonstr.com\n\nThis product is published under the Eclipse Public License\nhttp://www.eclipse.org/legal/epl-v10.html

AccountFilterRetiredAccounts = Hide inactive accounts

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

AboutText = Portfolio Performance\n\nVersion {0}\n\n(c) Copyright Andreas Buchen 2012 - 2015. All rights reserved.\n\nWith contributions by simpsus, jahzoo, gynngr, nistude, mwhesse, derari and necoro.\n\nThis product includes software developed by the\n Eclipse Foundation http://eclipse.org/\n Apache Software Foundation http://apache.org/\n SWT Chart Project http://www.swtchart.org/\n Tree Map Library http://code.google.com/p/treemaplib/\n jsoup Java HTML Parser http://jsoup.org\n JSON.simple https://code.google.com/p/json-simple/\n D3.js http://d3js.org\n\nSome icons are based on\n FatCow Hosting Icons http://www.fatcow.com/free-icons\n (Creative Commons Attribution 3.0 United States)\n iconmonstr http://iconmonstr.com\n\nThis product is published under the Eclipse Public License\nhttp://www.eclipse.org/legal/epl-v10.html
AboutText = Portfolio Performance\n\nVersion {0}\n\n(c) Copyright Andreas Buchen 2012 - 2015. All rights reserved.\n\nWith contributions by simpsus, jahzoo, gynngr, nistude, mwhesse,\n derari, necoro, alainschaefer and sebasbaumh.\n\nThis product includes software developed by the\n Eclipse Foundation http://eclipse.org/\n Apache Software Foundation http://apache.org/\n SWT Chart Project http://www.swtchart.org/\n Tree Map Library http://code.google.com/p/treemaplib/\n jsoup Java HTML Parser http://jsoup.org\n JSON.simple https://code.google.com/p/json-simple/\n D3.js http://d3js.org\n\nSome icons are based on\n FatCow Hosting Icons http://www.fatcow.com/free-icons\n (Creative Commons Attribution 3.0 United States)\n iconmonstr http://iconmonstr.com\n\nThis product is published under the Eclipse Public License\nhttp://www.eclipse.org/legal/epl-v10.html

AccountFilterRetiredAccounts = Inaktive Konten verbergen

Expand Down Expand Up @@ -187,7 +187,7 @@ ColumnExchangeRate = Wechselkurs

ColumnFees = Geb\u00FChren

ColumnFees_Description = Angefallen Geb\u00FChren f\u00FCr K\u00E4ufe, Verk\u00E4ufe, Einlieferungen und Auslieferungen.
ColumnFees_Description = Angefallene Geb\u00FChren f\u00FCr K\u00E4ufe, Verk\u00E4ufe, Einlieferungen und Auslieferungen.

ColumnFix = Fix

Expand Down Expand Up @@ -219,7 +219,7 @@ ColumnLatest = Letzter

ColumnLatestDate = Letzter (Datum)

ColumnLatestHistoricalDate = Letzer historischer (Datum)
ColumnLatestHistoricalDate = Letzter historischer (Datum)

ColumnLatestPrice = Letzter Kurs

Expand Down Expand Up @@ -807,7 +807,7 @@ MsgNoFileOpenText = \u00D6ffnen oder erstellen Sie zun\u00E4chst eine Portfolio

MsgNoIssuesFound = Keine Probleme gefunden.

MsgNoProfileFound = Kein Installationsprofile gefunden. L\u00E4uft die Anwendung in der IDE?
MsgNoProfileFound = Kein Installationsprofil gefunden. L\u00E4uft die Anwendung in der IDE?

MsgNoUpdatesAvailable = Keine Updates vorhanden.

Expand Down Expand Up @@ -967,7 +967,7 @@ SplitWizardDefinitionDescription = F\u00FCr welches Papier, zu welchem Datum (Ex

SplitWizardDefinitionTitle = Aktiensplit

SplitWizardErrorNewAndOldMustNotBeEqual = Das Splitverh\u00E4ltnis (neu f\u00FCr alt) ist identisch sein.
SplitWizardErrorNewAndOldMustNotBeEqual = Das Splitverh\u00E4ltnis (neu f\u00FCr alt) ist identisch.

SplitWizardLabelNewForOld = f\u00FCr

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ protected Control createContents(Composite parent)
@Override
public boolean performOk()
{
// check if viewer is initialized at all
if (viewer == null)
return true;

Language language = (Language) ((IStructuredSelection) viewer.getSelection()).getFirstElement();

switch (language)
Expand Down
Loading