Skip to content

Commit

Permalink
Modify UBS PDF-Importer to support new transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Nirus2000 authored and buchen committed Mar 19, 2024
1 parent d75e61a commit 64051ec
Show file tree
Hide file tree
Showing 3 changed files with 637 additions and 435 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
PDFBox Version: 1.8.17
Portfolio Performance Version: 0.67.3
-----------------------------------------
UBS UBS Switzerland AGa Postfach, 8098 Zürich
www.ubs.com
Für Auskünfte:
PURI-00111111
Tel. +41-44-234 11 11
UBS Wertschriftendepot CHF
Herr Depot-Nr. 206-111111.S2
Vorname Nachname Kunden-Nr. 206-111111
Musterstraße 1
11111 Musterstadt
Deutschland
Auftrags-Nr. 4083256
Eingang unter Vorbehalt
Dest 3800
Anzeige / Abrechnung Erstellt am 21. Dezember 2023
Gutschrift
DIVIDENDENZAHLUNG
VERFALL 20.12.2023 EX-TAG 16.11.2023 DIVIDENDE
STUECKZAHL VALOR 115606002 ISIN GB00BP6MXD84 ANSATZ
546 N-AKT SHELL PLC BRUTTO
(SHEL)
EUR 0.307
BRUTTO EUR 167.62
TOTAL EUR 167.62
UMRECHNUNGSKURS EUR/CHF 0.928528
FX-Marge von CHF 2.62 inbegriffen
GUTSCHRIFT KONTO 206-111111.M2L VALUTA 20.12.2023 CHF 155.64
Freundliche Grüsse
UBS Switzerland AG
Formular ohne Unterschrift Seite 1 / 1
KE642L04 / 021630 / WK9B4SA7DZCV3BYA00001 20.12.2023
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
package name.abuchen.portfolio.datatransfer.pdf.ubsag;

import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.check;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.dividend;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasAmount;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasCurrencyCode;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasDate;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasFees;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasForexGrossValue;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasGrossValue;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasIsin;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasName;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasNote;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasShares;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasSource;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasTaxes;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasTicker;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasWkn;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.security;
import static name.abuchen.portfolio.datatransfer.ExtractorTestUtilities.countAccountTransactions;
import static name.abuchen.portfolio.datatransfer.ExtractorTestUtilities.countBuySell;
import static name.abuchen.portfolio.datatransfer.ExtractorTestUtilities.countSecurities;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.collection.IsEmptyCollection.empty;
Expand Down Expand Up @@ -796,6 +817,78 @@ public void testDividende01WithSecurityInCHF()
assertThat(s, is(Status.OK_STATUS));
}

@Test
public void testDividende02()
{
UBSAGBankingAGPDFExtractor extractor = new UBSAGBankingAGPDFExtractor(new Client());

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

List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "Dividende02.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, "CHF");

// check security
assertThat(results, hasItem(security( //
hasIsin("GB00BP6MXD84"), hasWkn("115606002"), hasTicker("SHEL"), //
hasName("N-AKT SHELL PLC"), //
hasCurrencyCode("EUR"))));

// check dividends transaction
assertThat(results, hasItem(dividend( //
hasDate("2023-12-20T00:00"), hasShares(546), //
hasSource("Dividende02.txt"), //
hasNote(null), //
hasAmount("CHF", 155.64), hasGrossValue("CHF", 158.26), //
hasForexGrossValue("EUR", 170.44), //
hasTaxes("CHF", 0.00), hasFees("CHF", 2.62))));
}

@Test
public void testDividende02WithSecurityInCHF()
{
Security security = new Security("N-AKT SHELL PLC", "CHF");
security.setIsin("GB00BP6MXD84");
security.setWkn("115606002");
security.setTickerSymbol("SHEL");

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

UBSAGBankingAGPDFExtractor extractor = new UBSAGBankingAGPDFExtractor(client);

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

List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "Dividende02.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, "CHF");

// check dividends transaction
assertThat(results, hasItem(dividend( //
hasDate("2023-12-20T00:00"), hasShares(546), //
hasSource("Dividende02.txt"), //
hasNote(null), //
hasAmount("CHF", 155.64), hasGrossValue("CHF", 158.26), //
hasTaxes("CHF", 0.00), hasFees("CHF", 2.62), //
check(tx -> {
CheckCurrenciesAction c = new CheckCurrenciesAction();
Account account = new Account();
account.setCurrencyCode("CHF");
Status s = c.process((AccountTransaction) tx, account);
assertThat(s, is(Status.OK_STATUS));
}))));
}

@Test
public void testaddDepotAccountFee01()
{
Expand Down
Loading

0 comments on commit 64051ec

Please sign in to comment.