Skip to content

Commit

Permalink
Modify DKB PDF-Importer to support new fee format (#2316)
Browse files Browse the repository at this point in the history
* Modify DBK PDF-Importer to support new fee format
https://forum.portfolio-performance.info/t/pdf-import-von-dkb/4449/74

* Modify DBK PDF-Importer to support new fee format
https://forum.portfolio-performance.info/t/pdf-import-von-dkb/4449/74
  • Loading branch information
Nirus2000 authored Jul 10, 2021
1 parent 967fe04 commit 4d440e6
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import name.abuchen.portfolio.datatransfer.Extractor.Item;
import name.abuchen.portfolio.datatransfer.Extractor.SecurityItem;
import name.abuchen.portfolio.datatransfer.Extractor.TransactionItem;
import name.abuchen.portfolio.datatransfer.actions.AssertImportActions;
import name.abuchen.portfolio.datatransfer.pdf.DkbPDFExtractor;
import name.abuchen.portfolio.datatransfer.pdf.PDFInputFile;
import name.abuchen.portfolio.model.AccountTransaction;
Expand Down Expand Up @@ -983,6 +984,50 @@ public void testWertpapierVerkauf4ausKapitalmassnahme() throws IOException
is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(0.00))));
}

@Test
public void testWertpapierVerkauf5()
{
DkbPDFExtractor extractor = new DkbPDFExtractor(new Client());

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

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

assertThat(errors, empty());
assertThat(results.size(), is(2));
new AssertImportActions().check(results, CurrencyUnit.EUR);

// check security
Security security = results.stream().filter(i -> i instanceof SecurityItem).findFirst()
.orElseThrow(IllegalArgumentException::new).getSecurity();
assertThat(security.getIsin(), is("CA3012831077"));
assertThat(security.getWkn(), is("A1C30Q"));
assertThat(security.getName(), is("EXCHANGE INCOME CORP. REGISTERED SHARES O.N."));
assertThat(security.getCurrencyCode(), is(CurrencyUnit.EUR));

Optional<Item> item = results.stream().filter(i -> i instanceof BuySellEntryItem).findFirst();
assertThat(item.isPresent(), is(true));

// check buy sell transaction
BuySellEntry entry = (BuySellEntry) results.stream().filter(i -> i instanceof BuySellEntryItem)
.collect(Collectors.toList()).get(0).getSubject();

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

assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2021-07-06T00:00")));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(75)));

assertThat(entry.getPortfolioTransaction().getMonetaryAmount(),
is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(2051.02))));
assertThat(entry.getPortfolioTransaction().getGrossValue(),
is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(2085.00))));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.TAX),
is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(19.63 + 1.07))));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE),
is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(10.00 + 0.06 + 1.55 + 1.67))));
}

@Test
public void testWertpapierRueckzahlung() throws IOException
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
PDF Autor: ''
PDFBox Version: 1.8.16
-----------------------------------------
10919 Berlin Seite 1 von 2
Depotnummer 123456789
Kundennummer 123456789
Max Mustermann
Auftragsnummer 1234567879/84.00
Herrn Datum 06.07.2021
Max Mustermann Rechnungsnummer W123456-1234567879/21
Musterstraße 12 Umsatzsteuer-ID DE137178746
88888 Musterstadt
Wertpapier Abrechnung Verkauf
Nominale Wertpapierbezeichnung ISIN (WKN)
Stück 75 EXCHANGE INCOME CORP. CA3012831077 (A1C30Q)
REGISTERED SHARES O.N.
Handels-/Ausführungsplatz München (Best Execution)
Börsensegment MUNB
Limit-Order
Limit 27,80 EUR
Schlusstag/-Zeit 06.07.2021 14:49:39 Auftraggeber Max Mustermann
Ausführungskurs 27,80 EUR Auftragserteilung/ -ort Online-Banking
Wertpapierrechnung Lagerland Kanada
Kurswert 2.085,00 EUR
Provision 10,00- EUR
Abwicklungskosten Börse 0,06- EUR
Transaktionsentgelt Börse 1,55- EUR
Maklercourtage 0,0800 % vom Kurswert 1,67- EUR
Ermittlung steuerrelevante Erträge
Veräußerungsgewinn 78,53 EUR
Berechnungsgrundlage für die Kapitalertragsteuer 78,53 EUR
Steuerberechnung
Kapitalertragsteuer 25,00% auf 78,53 EUR 19,63- EUR
Solidaritätszuschlag 5,50% auf 19,63 EUR 1,07- EUR
Ausmachender Betrag 2.051,02 EUR
Den Gegenwert buchen wir mit Valuta 08.07.2021 zu Gunsten des Kontos 123456789
(IBAN DE12 1203 0000 123456789), BLZ 12030000 (BIC BYLADEM1001).
Die Wertpapiere entnehmen wir Ihrem Depotkonto.
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,22 @@ private <T extends Transaction<?>> void addFeesSectionsTransaction(T pdfTransact

.section("fee", "currency").optional()
.match("(^Übertragungs-/Liefergebühr) (?<fee>\\d{1,3}(\\.\\d{3})*(,\\d{2})?[-]) (?<currency>\\w{3})")
.assign((t, v) -> {
getTransaction(t).addUnit(new Unit(Unit.Type.FEE,
Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("fee")))));
})

// Maklercourtage 0,0800 % vom Kurswert 1,67- EUR
.section("fee", "currency").optional()
.match("^Maklercourtage [.,\\d]+ % .* (?<fee>[.,\\d]+)[-] (?<currency>[\\w]{3})$")
.assign((t, v) -> {
getTransaction(t).addUnit(new Unit(Unit.Type.FEE,
Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("fee")))));
})

// Abwicklungskosten Börse 0,06- EUR
.section("fee", "currency").optional()
.match("^Abwicklungskosten B.rse (?<fee>[.,\\d]+)[-] (?<currency>[\\w]{3})$")
.assign((t, v) -> {
getTransaction(t).addUnit(new Unit(Unit.Type.FEE,
Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("fee")))));
Expand Down

0 comments on commit 4d440e6

Please sign in to comment.