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

Modify Consorbank PDF-Importer to support new transaction (Add tests) #3850

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3504,7 +3504,7 @@ public void testDividende18()
hasName("ComStage Vermoeg.str.UCITS ETF Inhaber-Anteile I"), //
hasCurrencyCode("EUR"))));

// check dividende transaction
// check dividends transaction
assertThat(results, hasItem(dividend( //
hasDate("2017-10-13T00:00"), hasShares(27.47377), //
hasSource("Dividende18.txt"), //
Expand Down Expand Up @@ -3535,7 +3535,7 @@ public void testDividende19()
hasName("GLADSTONE CAPITAL CORP. Registered Shares o.N."), //
hasCurrencyCode("USD"))));

// check dividende transaction
// check dividends transaction
assertThat(results, hasItem(dividend( //
hasDate("2018-09-28T00:00"), hasShares(1000.00), //
hasSource("Dividende19.txt"), //
Expand Down Expand Up @@ -3606,7 +3606,7 @@ public void testDividende20()
hasName("Allianz SE vink.Namens-Aktien o.N."), //
hasCurrencyCode("EUR"))));

// check dividende transaction
// check dividends transaction
assertThat(results, hasItem(dividend( //
hasDate("2019-05-13T00:00"), hasShares(80.00), //
hasSource("Dividende20.txt"), //
Expand All @@ -3616,13 +3616,13 @@ public void testDividende20()
}

@Test
public void testDividendeNeuabrechnung01()
public void testDividende21()
{
ConsorsbankPDFExtractor extractor = new ConsorsbankPDFExtractor(new Client());

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

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

assertThat(errors, empty());
Expand All @@ -3638,13 +3638,297 @@ public void testDividendeNeuabrechnung01()
hasName("Xtr.Stoxx Gbl Sel.Div.100 Swap Inhaber-Anteile 1D o.N."), //
hasCurrencyCode("EUR"))));

// check dividende transaction
// check dividends transaction
assertThat(results, hasItem(dividend( //
hasDate("2024-03-07T00:00"), hasShares(100.4205), //
hasSource("DividendeNeuabrechnung01.txt"), //
hasSource("Dividende21.txt"), //
hasNote(null), //
hasAmount("EUR", 45.68), hasGrossValue("EUR", 56.02), //
hasTaxes("EUR", 9.8 + 0.54), hasFees("EUR", 0.00))));
hasTaxes("EUR", 9.80 + 0.54), hasFees("EUR", 0.00))));
}

@Test
public void testDividende22()
{
ConsorsbankPDFExtractor extractor = new ConsorsbankPDFExtractor(new Client());

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

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

assertThat(errors, empty());
assertThat(countSecurities(results), is(1L));
assertThat(countBuySell(results), is(0L));
assertThat(countAccountTransactions(results), is(1L));
assertThat(results.size(), is(2));
new AssertImportActions().check(results, CurrencyUnit.EUR);

// check security
assertThat(results, hasItem(security( //
hasIsin("US49456B1017"), hasWkn("A1H6GK"), hasTicker(null), //
hasName("Kinder Morgan Inc. Registered Shares P DL -,01"), //
hasCurrencyCode("USD"))));

// check dividends transaction
assertThat(results, hasItem(dividend( //
hasDate("2024-02-28T00:00"), hasShares(290.00), //
hasSource("Dividende22.txt"), //
hasNote(null), //
hasAmount("EUR", 56.33), hasGrossValue("EUR", 56.33), //
hasForexGrossValue("USD", 61.45), //
hasTaxes("EUR", 0.00), hasFees("EUR", 0.00))));
}

@Test
public void testDividende22WithSecurityInEUR()
{
Security security = new Security("Kinder Morgan Inc. Registered Shares P DL -,01", CurrencyUnit.EUR);
security.setIsin("US49456B1017");
security.setWkn("A1H6GK");

Client client = new Client();
client.addSecurity(security);

ConsorsbankPDFExtractor extractor = new ConsorsbankPDFExtractor(client);

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

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

assertThat(errors, empty());
assertThat(countSecurities(results), is(0L));
assertThat(countBuySell(results), is(0L));
assertThat(countAccountTransactions(results), is(1L));
assertThat(results.size(), is(1));
new AssertImportActions().check(results, CurrencyUnit.EUR);

// check dividends transaction
assertThat(results, hasItem(dividend( //
hasDate("2024-02-28T00:00"), hasShares(290.00), //
hasSource("Dividende22.txt"), //
hasNote(null), //
hasAmount("EUR", 56.33), hasGrossValue("EUR", 56.33), //
hasTaxes("EUR", 0.00), hasFees("EUR", 0.00), //
check(tx -> {
CheckCurrenciesAction c = new CheckCurrenciesAction();
Account account = new Account();
account.setCurrencyCode(CurrencyUnit.EUR);
Status s = c.process((AccountTransaction) tx, account);
assertThat(s, is(Status.OK_STATUS));
}))));
}

@Test
public void testDividende23()
{
ConsorsbankPDFExtractor extractor = new ConsorsbankPDFExtractor(new Client());

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

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

assertThat(errors, empty());
assertThat(countSecurities(results), is(1L));
assertThat(countBuySell(results), is(0L));
assertThat(countAccountTransactions(results), is(1L));
assertThat(results.size(), is(2));
new AssertImportActions().check(results, CurrencyUnit.EUR);

// check security
assertThat(results, hasItem(security( //
hasIsin("US3026352068"), hasWkn("A2P6TH"), hasTicker(null), //
hasName("FS KKR Capital Corp. Registered Shares DL -,001"), //
hasCurrencyCode("USD"))));

// check dividends transaction
assertThat(results, hasItem(dividend( //
hasDate("2024-02-28T00:00"), hasShares(42.27894), //
hasSource("Dividende23.txt"), //
hasNote(null), //
hasAmount("EUR", 1.44), hasGrossValue("EUR", 1.94), //
hasForexGrossValue("USD", 2.11), //
hasTaxes("EUR", 0.29 + 0.19 + 0.01 + 0.01), hasFees("EUR", 0.00))));
}

@Test
public void testDividende23WithSecurityInEUR()
{
Security security = new Security("FS KKR Capital Corp. Registered Shares DL -,001", CurrencyUnit.EUR);
security.setIsin("US3026352068");
security.setWkn("A2P6TH");

Client client = new Client();
client.addSecurity(security);

ConsorsbankPDFExtractor extractor = new ConsorsbankPDFExtractor(client);

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

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

assertThat(errors, empty());
assertThat(countSecurities(results), is(0L));
assertThat(countBuySell(results), is(0L));
assertThat(countAccountTransactions(results), is(1L));
assertThat(results.size(), is(1));
new AssertImportActions().check(results, CurrencyUnit.EUR);

// check dividends transaction
assertThat(results, hasItem(dividend( //
hasDate("2024-02-28T00:00"), hasShares(42.27894), //
hasSource("Dividende23.txt"), //
hasNote(null), //
hasAmount("EUR", 1.44), hasGrossValue("EUR", 1.94), //
hasTaxes("EUR", 0.29 + 0.19 + 0.01 + 0.01), hasFees("EUR", 0.00), //
check(tx -> {
CheckCurrenciesAction c = new CheckCurrenciesAction();
Account account = new Account();
account.setCurrencyCode(CurrencyUnit.EUR);
Status s = c.process((AccountTransaction) tx, account);
assertThat(s, is(Status.OK_STATUS));
}))));
}

@Test
public void testDividende24()
{
ConsorsbankPDFExtractor extractor = new ConsorsbankPDFExtractor(new Client());

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

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

assertThat(errors, empty());
assertThat(countSecurities(results), is(1L));
assertThat(countBuySell(results), is(0L));
assertThat(countAccountTransactions(results), is(1L));
assertThat(results.size(), is(2));
new AssertImportActions().check(results, CurrencyUnit.EUR);

// check security
assertThat(results, hasItem(security( //
hasIsin("US7561581015"), hasWkn("A0YCXM"), hasTicker(null), //
hasName("Reaves Utility Income Fund Reg. Shs of Benef. Int. DL-,01"), //
hasCurrencyCode("USD"))));

// check dividends transaction
assertThat(results, hasItem(dividend( //
hasDate("2024-02-29T00:00"), hasShares(70.00), //
hasSource("Dividende24.txt"), //
hasNote(null), //
hasAmount("EUR", 10.38), hasGrossValue("EUR", 12.22), //
hasForexGrossValue("USD", 13.30), //
hasTaxes("EUR", 1.84), hasFees("EUR", 0.00))));
}

@Test
public void testDividende24WithSecurityInEUR()
{
Security security = new Security("FS KKR Capital Corp. Registered Shares DL -,001", CurrencyUnit.EUR);
security.setIsin("US7561581015");
security.setWkn("A0YCXM");

Client client = new Client();
client.addSecurity(security);

ConsorsbankPDFExtractor extractor = new ConsorsbankPDFExtractor(client);

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

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

assertThat(errors, empty());
assertThat(countSecurities(results), is(0L));
assertThat(countBuySell(results), is(0L));
assertThat(countAccountTransactions(results), is(1L));
assertThat(results.size(), is(1));
new AssertImportActions().check(results, CurrencyUnit.EUR);

// check dividends transaction
assertThat(results, hasItem(dividend( //
hasDate("2024-02-29T00:00"), hasShares(70.00), //
hasSource("Dividende24.txt"), //
hasNote(null), //
hasAmount("EUR", 10.38), hasGrossValue("EUR", 12.22), //
hasTaxes("EUR", 1.84), hasFees("EUR", 0.00), //
check(tx -> {
CheckCurrenciesAction c = new CheckCurrenciesAction();
Account account = new Account();
account.setCurrencyCode(CurrencyUnit.EUR);
Status s = c.process((AccountTransaction) tx, account);
assertThat(s, is(Status.OK_STATUS));
}))));
}

@Test
public void testDividende25()
{
ConsorsbankPDFExtractor extractor = new ConsorsbankPDFExtractor(new Client());

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

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

assertThat(errors, empty());
assertThat(countSecurities(results), is(1L));
assertThat(countBuySell(results), is(0L));
assertThat(countAccountTransactions(results), is(1L));
assertThat(results.size(), is(2));
new AssertImportActions().check(results, CurrencyUnit.EUR);

// check security
assertThat(results, hasItem(security( //
hasIsin("IE00BK1PV551"), hasWkn("A1XEY2"), hasTicker(null), //
hasName("Xtr.(IE) - MSCI World Registered Shares 1D o.N."), //
hasCurrencyCode("USD"))));

// check dividends transaction
assertThat(results, hasItem(dividend( //
hasDate("2024-03-07T00:00"), hasShares(80.43549), //
hasSource("Dividende25.txt"), //
hasNote(null), //
hasAmount("EUR", 41.99), hasGrossValue("EUR", 41.99), //
hasForexGrossValue("USD", 46.03), //
hasTaxes("EUR", 0.00), hasFees("EUR", 0.00))));
}

@Test
public void testDividende25WithSecurityInEUR()
{
Security security = new Security("Xtr.(IE) - MSCI World Registered Shares 1D o.N.", CurrencyUnit.EUR);
security.setIsin("IE00BK1PV551");
security.setWkn("A1XEY2");

Client client = new Client();
client.addSecurity(security);

ConsorsbankPDFExtractor extractor = new ConsorsbankPDFExtractor(client);

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

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

assertThat(errors, empty());
assertThat(countSecurities(results), is(0L));
assertThat(countBuySell(results), is(0L));
assertThat(countAccountTransactions(results), is(1L));
assertThat(results.size(), is(1));
new AssertImportActions().check(results, CurrencyUnit.EUR);

// check dividends transaction
assertThat(results, hasItem(dividend( //
hasDate("2024-03-07T00:00"), hasShares(80.43549), //
hasSource("Dividende25.txt"), //
hasNote(null), //
hasAmount("EUR", 41.99), hasGrossValue("EUR", 41.99), //
hasTaxes("EUR", 0.00), hasFees("EUR", 0.00), //
check(tx -> {
CheckCurrenciesAction c = new CheckCurrenciesAction();
Account account = new Account();
account.setCurrencyCode(CurrencyUnit.EUR);
Status s = c.process((AccountTransaction) tx, account);
assertThat(s, is(Status.OK_STATUS));
}))));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
PDFBox Version: 1.8.17
Portfolio Performance Version: 0.67.3
-----------------------------------------
Consorsbank • 90318 Nürnberg
Depotnummer: 1234567890
1110705074/00
Vermerk der Bank: 2100
2
Maxi Mustermax
Straße 23 Datum: 01.03.2024
12345 Musterstadt Seite: 1 von 2
Ertragsgutschrift / Neuabrechnung
Wertpapierbezeichnung WKN ISIN
Kinder Morgan Inc. Registered Shares P DL -,01 A1H6GK US49456B1017
Bestand
290 Stück
Ertragsausschüttung je Anteil 0,2119 USD Schlusstag 27.04.2023
Brutto in USD 61,45 USD
Netto in USD 61,45 USD
Devisenkurs 1,090900 USD / EUR
Brutto in EUR 56,33 EUR
Netto zugunsten IBAN DE60 7603 0080 0840 1922 64 56,33 EUR
Valuta 28.02.2024 BIC CSDBDE71XXX
Return of Capital Neuabrechnung 2
Bitte beachten Sie die weiteren Informationen auf Seite 2.
Consorsbank ist eine eingetragene Marke der BNP Paribas S.A. Niederlassung Deutschland (AG nach franz. Recht).
Standort Nürnberg: Bahnhofstraße 55, 90402 Nürnberg, HRB Nürnberg 31129, USt-IdNr. DE191528929
Fon +49 (0) 911 / 369-30 00, Fax +49 (0) 911 / 369-10 00, [email protected], www.consorsbank.de
Sitz der BNP Paribas S.A.: 16, boulevard des Italiens, 75009 Paris, Frankreich, Registergericht: R.C.S. Paris 662 042 449
Président du Conseil d‘Administration (Präsident des Verwaltungsrates): Jean Lemierre, Directeur Général (Generaldirektor): Jean-Laurent Bonnafé
1EE45331-38C6-20E0-141E-E4423403B200
Depotnummer: 1234567890
1110705074/00
Vermerk der Bank: 2100
2
Datum: 01.03.2024
Seite: 2 von 2
Details zur Abrechnung
Steuerpflichtiger Gesamtertrag 56,33 EUR
Mit Verrechnungstopf "Allgemein" verrechnet -56,33 EUR
Mit Sparerpauschbetrag verrechnet 0,00 EUR
Mit Quellensteuer verrechnet 0,00 EUR
somit verrechnete Quellensteuer 0,00 EUR
Bemessungsgrundlage für Kapitalertragsteuer gesamt 0,00 EUR
Details zu den Verrechnungstöpfen
Verrechnungstopf "Allgemein" vor der Abrechnung 75,10 EUR
Mit Verrechnungstopf "Allgemein" verrechnet -56,33 EUR
Verrechnungstopf "Allgemein" nach der Abrechnung 18,77 EUR
Sparerpauschbetrag vor der Abrechnung 0,00 EUR
Mit Sparerpauschbetrag verrechnet 0,00 EUR
Sparerpauschbetrag nach der Abrechnung 0,00 EUR
Verrechnungstopf "Quellensteuer" vor der Abrechnung -11,27 EUR
Änderung Verrechnungstopf "Quellensteuer" 0,00 EUR
Verrechnungstopf "Quellensteuer" nach der Abrechnung -11,27 EUR
Loading
Loading