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

Add new Hargreaves Landsdown PDF-Importer #2966

Merged
merged 1 commit into from Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,201 @@
package name.abuchen.portfolio.datatransfer.pdf.hargreaveslansdownplc;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.collection.IsEmptyCollection.empty;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

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.datatransfer.actions.AssertImportActions;
import name.abuchen.portfolio.datatransfer.pdf.HargreavesLansdownPlcExtractor;
import name.abuchen.portfolio.datatransfer.pdf.PDFInputFile;
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.model.Transaction.Unit;
import name.abuchen.portfolio.money.Money;
import name.abuchen.portfolio.money.Values;

@SuppressWarnings("nls")
public class HargreavesLansdownPlcTest
{
@Test
public void testWertpapierKauf01()
{
HargreavesLansdownPlcExtractor extractor = new HargreavesLansdownPlcExtractor(new Client());

List<Exception> errors = new ArrayList<>();

List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "Kauf01.txt"), errors);

assertThat(errors, empty());
assertThat(results.size(), is(2));
new AssertImportActions().check(results, "GBP");

// check security
Security security = results.stream().filter(SecurityItem.class::isInstance).findFirst()
.orElseThrow(IllegalArgumentException::new).getSecurity();
assertThat(security.getIsin(), is("IE00B4X9L533"));
assertThat(security.getTickerSymbol(), is("HMWO"));
assertThat(security.getName(), is("HSBC ETFs Plc MSCI World ETF GBP"));
assertThat(security.getCurrencyCode(), is("GBP"));

// check buy sell transaction
BuySellEntry entry = (BuySellEntry) results.stream().filter(BuySellEntryItem.class::isInstance).findFirst()
.orElseThrow(IllegalArgumentException::new).getSubject();

assertThat(entry.getPortfolioTransaction().getType(), is(PortfolioTransaction.Type.BUY));
assertThat(entry.getAccountTransaction().getType(), is(AccountTransaction.Type.BUY));

assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2021-10-15T09:47")));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(2539)));
assertThat(entry.getSource(), is("Kauf01.txt"));
assertThat(entry.getNote(), is("Ref.: B105372223-01000000"));

assertThat(entry.getPortfolioTransaction().getMonetaryAmount(),
is(Money.of("GBP", Values.Amount.factorize(57581.69))));
assertThat(entry.getPortfolioTransaction().getGrossValue(),
is(Money.of("GBP", Values.Amount.factorize(57569.74))));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.TAX),
is(Money.of("GBP", Values.Amount.factorize(0.00))));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE),
is(Money.of("GBP", Values.Amount.factorize(11.95))));
}

@Test
public void testWertpapierKauf02()
{
HargreavesLansdownPlcExtractor extractor = new HargreavesLansdownPlcExtractor(new Client());

List<Exception> errors = new ArrayList<>();

List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "Kauf02.txt"), errors);

assertThat(errors, empty());
assertThat(results.size(), is(2));
new AssertImportActions().check(results, "GBP");

// check security
Security security = results.stream().filter(SecurityItem.class::isInstance).findFirst()
.orElseThrow(IllegalArgumentException::new).getSecurity();
assertThat(security.getIsin(), is("GB00BG0QPJ30"));
assertThat(security.getName(), is("Legal & General UK Index Class C - Accumulation (GBP)"));
assertThat(security.getCurrencyCode(), is("GBP"));

// check buy sell transaction
BuySellEntry entry = (BuySellEntry) results.stream().filter(BuySellEntryItem.class::isInstance).findFirst()
.orElseThrow(IllegalArgumentException::new).getSubject();

assertThat(entry.getPortfolioTransaction().getType(), is(PortfolioTransaction.Type.BUY));
assertThat(entry.getAccountTransaction().getType(), is(AccountTransaction.Type.BUY));

assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2017-04-03T08:00")));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(1043.478)));
assertThat(entry.getSource(), is("Kauf02.txt"));
assertThat(entry.getNote(), is("Ref.: B918390061-01000000"));

assertThat(entry.getPortfolioTransaction().getMonetaryAmount(),
is(Money.of("GBP", Values.Amount.factorize(3000.00))));
assertThat(entry.getPortfolioTransaction().getGrossValue(),
is(Money.of("GBP", Values.Amount.factorize(3000.00))));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.TAX),
is(Money.of("GBP", Values.Amount.factorize(0.00))));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE),
is(Money.of("GBP", Values.Amount.factorize(0.00))));
}

@Test
public void testWertpapierVerkauf01()
{
HargreavesLansdownPlcExtractor extractor = new HargreavesLansdownPlcExtractor(new Client());

List<Exception> errors = new ArrayList<>();

List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "Verkauf01.txt"), errors);

assertThat(errors, empty());
assertThat(results.size(), is(2));
new AssertImportActions().check(results, "GBP");

// check security
Security security = results.stream().filter(SecurityItem.class::isInstance).findFirst()
.orElseThrow(IllegalArgumentException::new).getSecurity();
assertThat(security.getIsin(), is("GB00BKX5CN86"));
assertThat(security.getTickerSymbol(), is("JE."));
assertThat(security.getName(), is("Just Eat plc Ordinary Shares 1p"));
assertThat(security.getCurrencyCode(), is("GBP"));

// check buy sell transaction
BuySellEntry entry = (BuySellEntry) results.stream().filter(BuySellEntryItem.class::isInstance).findFirst()
.orElseThrow(IllegalArgumentException::new).getSubject();

assertThat(entry.getPortfolioTransaction().getType(), is(PortfolioTransaction.Type.SELL));
assertThat(entry.getAccountTransaction().getType(), is(AccountTransaction.Type.SELL));

assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2019-03-27T11:46")));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(132)));
assertThat(entry.getSource(), is("Verkauf01.txt"));
assertThat(entry.getNote(), is("Ref.: S362136892-01000000"));

assertThat(entry.getPortfolioTransaction().getMonetaryAmount(),
is(Money.of("GBP", Values.Amount.factorize(981.87))));
assertThat(entry.getPortfolioTransaction().getGrossValue(),
is(Money.of("GBP", Values.Amount.factorize(993.82))));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.TAX),
is(Money.of("GBP", Values.Amount.factorize(0.00))));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE),
is(Money.of("GBP", Values.Amount.factorize(11.95))));
}

@Test
public void testWertpapierVerkauf02()
{
HargreavesLansdownPlcExtractor extractor = new HargreavesLansdownPlcExtractor(new Client());

List<Exception> errors = new ArrayList<>();

List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "Verkauf02.txt"), errors);

assertThat(errors, empty());
assertThat(results.size(), is(2));
new AssertImportActions().check(results, "GBP");

// check security
Security security = results.stream().filter(SecurityItem.class::isInstance).findFirst()
.orElseThrow(IllegalArgumentException::new).getSecurity();
assertThat(security.getIsin(), is("IE00BKX55S42"));
assertThat(security.getTickerSymbol(), is("VERX"));
assertThat(security.getName(), is("Vanguard Funds plc FTSE Developed Europe ex-UK UCITS ETF"));
assertThat(security.getCurrencyCode(), is("GBP"));

// check buy sell transaction
BuySellEntry entry = (BuySellEntry) results.stream().filter(BuySellEntryItem.class::isInstance).findFirst()
.orElseThrow(IllegalArgumentException::new).getSubject();

assertThat(entry.getPortfolioTransaction().getType(), is(PortfolioTransaction.Type.SELL));
assertThat(entry.getAccountTransaction().getType(), is(AccountTransaction.Type.SELL));

assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2022-01-25T09:35")));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(5700)));
assertThat(entry.getSource(), is("Verkauf02.txt"));
assertThat(entry.getNote(), is("Ref.: S186039383-01000000"));

assertThat(entry.getPortfolioTransaction().getMonetaryAmount(),
is(Money.of("GBP", Values.Amount.factorize(172287.66))));
assertThat(entry.getPortfolioTransaction().getGrossValue(),
is(Money.of("GBP", Values.Amount.factorize(172299.61))));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.TAX),
is(Money.of("GBP", Values.Amount.factorize(0.00))));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE),
is(Money.of("GBP", Values.Amount.factorize(11.95))));
}
}
@@ -0,0 +1,35 @@
PDFBox Version: 1.8.16
Portfolio Performance Version: 0.59.1
-----------------------------------------
One College Square South, Anchor Road, Bristol, BS1 5HL
Vantage Share Dealing: (0117) 980 9800 Vantage Fund Dealing: (0117) 980 9807 Vantage Helpdesk: (0117) 900 9000 www.h-l.co.uk
Hargreaves Lansdown is a trading name of Hargreaves Lansdown Asset Management Limited.
Authorised & Regulated by the Financial Conduct Authority, No. 115248 Company Registration No. 01896481.
A member firm of the London Stock Exchange. VAT No. GB 433 8716 440. A Wholly Owned Subsidiary of Hargreaves Lansdown Plc
Contract Note
Mr XXX XXX
Apartment XXX
XXXXX
London
XXXX XXX
A/C Designation :
Date 15/10/2021 Time 09:47 Contract Note No. B105372223-01000000
(To be quoted in all correspondence)
We have today on your instructions **BOUGHT** the security detailed below.
IMPORTANT Please check all details are correct. You should advise us of any discrepancy immediately
Quantity Security Price Consideration
IE00B4X9L533 STOCK CODE: HMWO
HSBC ETFs Plc
2,539.00 MSCI World ETF GBP 2267.4179 57,569.74
Market Order
Venue of Execution: London Stock Exchange (XLON)
Commission 11.95
These shares / units have been dealt using the following account:
HL SIPP Settlement Date: 19/10/2021 57,581.69
E and OE
Note: Retain this document as a record of your investment.
Always quote your client number and contract note number in correspondence.
This contract is subject to our normal terms and conditions of business and may also be subject to the rules of
the London Stock Exchange.
Details of any commission shared with third parties is available upon request.
HL ASSCON 03130
@@ -0,0 +1,34 @@
PDFBox Version: 1.8.16
Portfolio Performance Version: 0.59.1
-----------------------------------------
One College Square South, Anchor Road, Bristol, BS1 5HL
Vantage Share Dealing: (0117) 980 9800 Vantage Fund Dealing: (0117) 980 9807 Vantage Helpdesk: (0117) 900 9000 www.h-l.co.uk
Hargreaves Lansdown is a trading name of Hargreaves Lansdown Asset Management Limited.
Authorised & Regulated by the Financial Conduct Authority, No. 115248 Company Registration No. 01896481.
A member firm of the London Stock Exchange. VAT No. GB 433 8716 440. A Wholly Owned Subsidiary of Hargreaves Lansdown Plc
Contract Note
Mr XXX XXX
XXXX
XXXX
XXXX
London
XX XXX
A/C Designation :
Date 03/04/2017 Time 08:00 Contract Note No. B918390061-01000000
(To be quoted in all correspondence)
We have today on your instructions **BOUGHT** the security detailed below.
IMPORTANT Please check all details are correct. You should advise us of any discrepancy immediately
Quantity Security Price Consideration
GB00BG0QPJ30
Legal & General UK Index
1,043.478 Class C - Accumulation (GBP) 287.500000 3,000.00
Venue of Execution: The manager of the unit trust
These shares / units have been dealt using the following account:
HL Vantage SIPP Settlement Date: 07/04/2017 3,000.00
E and OE
Note: Retain this document as a record of your investment.
Always quote your client number and contract note number in correspondence.
This contract is subject to our normal terms and conditions of business and may also be subject to the rules of
the London Stock Exchange.
Details of any commission shared with third parties is available upon request.
HL ASSCON 03130
@@ -0,0 +1,35 @@
PDFBox Version: 1.8.16
Portfolio Performance Version: 0.59.1
-----------------------------------------
One College Square South, Anchor Road, Bristol, BS1 5HL
Vantage Share Dealing: (0117) 980 9800 Vantage Fund Dealing: (0117) 980 9807 Vantage Helpdesk: (0117) 900 9000 www.h-l.co.uk
Hargreaves Lansdown is a trading name of Hargreaves Lansdown Asset Management Limited.
Authorised & Regulated by the Financial Conduct Authority, No. 115248 Company Registration No. 01896481.
A member firm of the London Stock Exchange. VAT No. GB 433 8716 440. A Wholly Owned Subsidiary of Hargreaves Lansdown Plc
Contract Note
Mr XXX XXX
XXXX
XXXX
XXXX
XXXX
A/C Designation :
Date 27/03/2019 Time 11:46 Contract Note No. S362136892-01000000
(To be quoted in all correspondence)
We have today on your instructions **SOLD** the security detailed below.
IMPORTANT Please check all details are correct. You should advise us of any discrepancy immediately
Quantity Security Price Consideration
GB00BKX5CN86 STOCK CODE: JE.
Just Eat plc
132.00 Ordinary Shares 1p 752.896 993.82
Market Order
Venue of Execution: London Stock Exchange (XLON)
Commission 11.95
These shares / units have been dealt using the following account:
HL SIPP Settlement Date: 29/03/2019 981.87
E and OE
Note: Retain this document as a record of your investment.
Always quote your client number and contract note number in correspondence.
This contract is subject to our normal terms and conditions of business and may also be subject to the rules of
the London Stock Exchange.
Details of any commission shared with third parties is available upon request.
HL ASSCON 03130
@@ -0,0 +1,39 @@
PDFBox Version: 1.8.16
Portfolio Performance Version: 0.59.1
-----------------------------------------
Hargreaves Lansdown is a trading name of Hargreaves Lansdown Asset Management Limited.
Authorised and regulated by the Financial Conduct Authority, No. 115248 Company registered in England
and Wales No. 1896481. A member firm of the London Stock Exchange. VAT No. GB 433 8716 440.
A Wholly Owned Subsidiary of Hargreaves Lansdown Plc.
One College Square South
Contract Note Anchor RoadBristol
BS1 5HL
Mr XXXX XXXX Share Dealing:
XXXX (0117) 980 9800
XXXX Fund Dealing:
XXXX
XXXX (0117) 980 9807
Helpdesk:
(0117) 900 9000
www.hl.co.uk
A/C Designation :
Date 25 /01/202 2 Time 09:35 Contract Note No. S186039383-01000000
(To be quoted in all correspondence)
We have today on your instructions ** SOL D** the security detailed below.
IMPORTANT Please check all details are correct. You should advise us of any discrepancy immediately
Quantity Security Price Consideration
IE00BKX55S42 STOCK CODE: VERX
Vanguard Funds plc
5,700.00 FTSE Developed Europe ex-UK UCITS ETF 3022.8001 172,299.61
Market Order
Venue of Execution: London Stock Exchange (XLON)
Commission 11.95
These shares / units have been dealt using the following account:

HL Fund & Shar e A c c o u n t Settlement Date: 27/01/2022 172,287.66
E and OE
Note:
Retain this document as a record of your investment.
Always quote your client number and contract note number in correspondence.
This contract is subject to our normal terms and conditions of business and may also be subject to the rules of the London Stock Exchange.
Details of any commission shared with third parties is available upon request.