Skip to content

Commit

Permalink
Modify DKB PDF-Importer to support new transaction (#4578)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nirus2000 authored Mar 7, 2025
1 parent 8000f46 commit 1e4e187
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4637,6 +4637,32 @@ public void testGiroKontoauszug29()
hasSource("GiroKontoauszug29.txt"), hasNote("Abrechnungszeitraum vom 01.10.2024 bis 31.12.2024"))));
}

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

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

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

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

// assert transaction
assertThat(results, hasItem(removal(hasDate("2025-02-06"), hasAmount("EUR", 460.00), //
hasSource("GiroKontoauszug30.txt"), hasNote("Kartenzahlung online"))));

// assert transaction
assertThat(results, hasItem(removal(hasDate("2025-02-17"), hasAmount("EUR", 44.00), //
hasSource("GiroKontoauszug30.txt"), hasNote("Kartenzahlung"))));
}

@Test
public void testTagesgeldKontoauszug01()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
```
PDFBox Version: 3.0.3 != 1.8.17
Portfolio Performance Version: 0.74.2.qualifier
System: win32 | x86_64 | 21.0.5+11-LTS | Azul Systems, Inc.
-----------------------------------------
Deutsche Kreditbank AG
Herrn Internes Zeichen:
Max Mustermann 180 41 00
Musterstr. Str. 3
01111 City






5. März 2025
Kontoauszug 3/2025 Seite 1 von 3
G irokonto 1111111111, DE45 1203 0000 1111 1111 11
Datum Erläuterung Betrag Soll EUR Betrag Haben EUR
Kontostand am 04.02.2025, Auszug Nr. 2 585,61
06.02.2025 Kartenzahlung onl -460,00
WOKO.GMBH..TEAMDUELL.D/LEIPZIG/../D E
2025-02-05T02:44 Debitk.54 1111-12 Zahl.System VISA
Debit
1 7.02.2025 Kartenzahlung -44,00
FREIBERGER.SCHANKHAUS/City/../DE
2025-02-14T14:59 Debitk.54 1111-12 Zahl.System VISA
Debit
Kontostand am 04.03.2025 um 18:04 Uhr 81,61
Ihr Dispositionskredit EUR: 2.000,00
Gesamtumsatzsummen Summe Soll EUR Anzahl Summe Haben EUR Anzahl
. -3.219,29 25 3.279,75 4
Hinweise zum Kontoauszug:
l Bitte den Kontoauszug prüfen. Nicht autorisierte oder fehlerhaft ausgeführte Aufträge müssen uns unverzüglich angezeigt
werden.
l Der Kontoauszug am Ende eines Kalenderquartals beinhaltet regelmäßig einen Rechnungsabschluss. Dieser gilt als genehmigt,
wenn ihm nicht vor Ablauf von sechs Wochen nach Zugang widersprochen wird. Einwendungen gegen Rechnungsabschlüsse
müssen der Deutschen Kreditbank AG in Textform zugehen. Zur Fristwahrung genügt die rechtzeitige Absendung (Nr. 7 Abs. 3
der Allgemeinen Geschäftsbedingungen).
l Der angegebene Kontostand berücksichtigt nicht die Wertstellung der einzelnen Buchungen. Dies bedeutet, dass der genannte
Betrag nicht dem für die Zinsrechnung maßgeblichen Kontostand entsprechen muss und bei Verfügungen möglicherweise
Zinsen für die Inanspruchnahme einer eingeräumten oder geduldeten Kontoüberziehung anfallen können.
l Die Gutschrift von Schecks, Lastschriften oder anderen Einzugspapieren vor ihrer Einlösung geschieht unter Vorbehalt
(E.v.-Gutschrift). Werden Schecks oder Lastschriften nicht eingelöst oder geht der DKB der Gegenwert nicht zu, so macht sie die
Gutschrift gemäß Nr. 23 der AGB rückgängig (Stornobuchung), und zwar auch nach einem zwischenzeitlich erfolgten
Rechnungsabschluss.
l Guthaben sind als Einlagen nach Maßgabe des Einlagensicherungsgesetzes entschädigungsfähig. Nähere Informationen: im
"Informationsbogen für Einleger" sowie auf unserer Webseite unter dkb.de/kundenservice/einlagensicherung.
Deutsche Kreditbank AG Vorsitzender des Aufsichtsrats Telefon 030 120 300 00 BIC: BYLADEM1001
Taubenstraße 7 - 9 Stephan Winkelmeier Telefax 030 120 300 01
10117 Berlin Vorstand USt-ID-Nr.: DE137178746
Dr. Sven Deglow (Vorsitzender) [email protected] Handelsregister
Ein Unternehmen der Tilo Hacke, Jan Walther, www.dkb.de Berlin-CharlMustermannenburg
Bayerischen Landesbank Arnulf Keese, Kristina Trink (HRB 34165 B)

```
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static name.abuchen.portfolio.datatransfer.ExtractorUtils.checkAndSetGrossUnit;
import static name.abuchen.portfolio.util.TextUtil.concatenate;
import static name.abuchen.portfolio.util.TextUtil.stripBlanks;
import static name.abuchen.portfolio.util.TextUtil.trim;

import java.math.BigDecimal;
Expand Down Expand Up @@ -1055,7 +1056,7 @@ private void addAccountStatementTransaction_Format02()
.section("type", "amount", "date", "note").optional() //
.documentContext("currency") //
.match("^[\\s]+ (?<type>[\\-\\s])(?<amount>[\\.,\\d]+)$") //
.match("^(?<date>[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}) " //
.match("^(?<date>[\\d\\s]{1,4}\\.[\\d]{2}\\.[\\d]{4}) " //
+ "(?!(Wertpapierabrechnung|Abrechnung [\\d]{2}\\.[\\d]{2}\\.[\\d]{4}))" //
+ "(?<note>(Lohn, Gehalt, Rente" //
+ "|Zahlungseingang" //
Expand All @@ -1080,7 +1081,7 @@ private void addAccountStatementTransaction_Format02()
if ("-".equals(trim(v.get("type"))))
t.setType(AccountTransaction.Type.REMOVAL);

t.setDateTime(asDate(v.get("date")));
t.setDateTime(asDate(stripBlanks(v.get("date"))));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(v.get("currency"));

Expand Down Expand Up @@ -1123,9 +1124,11 @@ private void addAccountStatementTransaction_Format02()

// @formatter:off
// 09.12.2024 Kartenzahlung -10,00
// 9.12.2024 Zahlungseingang 500,00
// 09.12.2024 Zahlungseingang 500,00
// 06.02.2025 Kartenzahlung onl -460,00
// 1 7.02.2025 Kartenzahlung -44,00
// @formatter:on
Block depositRemovalBlock_Format02 = new Block("^[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}(?!(Wertpapierabrechnung|Abrechnung [\\d]{2}\\.[\\d]{2}\\.[\\d]{4})).*[\\.,\\d]+$");
Block depositRemovalBlock_Format02 = new Block("^[\\d\\s]{1,4}\\.[\\d]{2}\\.[\\d]{4}(?!(Wertpapierabrechnung|Abrechnung [\\d]{2}\\.[\\d]{2}\\.[\\d]{4})).*[\\.,\\d]+$");
type.addBlock(depositRemovalBlock_Format02);
depositRemovalBlock_Format02.setMaxSize(1);
depositRemovalBlock_Format02.set(new Transaction<AccountTransaction>()
Expand All @@ -1138,7 +1141,7 @@ private void addAccountStatementTransaction_Format02()

.section("date", "note", "type", "amount").optional() //
.documentContext("currency") //
.match("^(?<date>[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}) " //
.match("^(?<date>[\\d\\s]{1,4}.[\\d]{2}\\.[\\d]{4}) " //
+ "(?<note>(Lohn, Gehalt, Rente" //
+ "|Zahlungseingang" //
+ "|Storno Gutschrift" //
Expand All @@ -1151,6 +1154,7 @@ private void addAccountStatementTransaction_Format02()
+ "|Basislastschrift" //
+ "|Lastschrift" //
+ "|Kartenzahlung" //
+ "|Kartenzahlung onl" //
+ "|Kreditkartenabr\\." //
+ "|Verf.gung Geldautomat" //
+ "|Verf.g\\. Geldautom\\. FW" //
Expand All @@ -1163,7 +1167,7 @@ private void addAccountStatementTransaction_Format02()
if ("-".equals(trim(v.get("type"))))
t.setType(AccountTransaction.Type.REMOVAL);

t.setDateTime(asDate(v.get("date")));
t.setDateTime(asDate(stripBlanks(v.get("date"))));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(v.get("currency"));

Expand Down Expand Up @@ -1218,7 +1222,7 @@ private void addAccountStatementTransaction_Format02()
.section("type", "amount", "date", "note1", "note2").optional() //
.documentContext("currency") //
.match("^[\\s]+ (?<type>[\\-\\s])(?<amount>[\\.,\\d]+)$") //
.match("^(?<date>[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}) " //
.match("^(?<date>[\\d\\s]{1,4}\\.[\\d]{2}\\.[\\d]{4}) " //
+ "(?!(Wertpapierabrechnung|Abrechnung [\\d]{2}\\.[\\d]{2}\\.[\\d]{4}))" //
+ "(?<note1>(Rechnung" //
+ "|Buchung" //
Expand All @@ -1236,7 +1240,7 @@ private void addAccountStatementTransaction_Format02()
if ("-".equals(trim(v.get("type"))))
t.setType(AccountTransaction.Type.FEES);

t.setDateTime(asDate(v.get("date")));
t.setDateTime(asDate(stripBlanks(v.get("date"))));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(v.get("currency"));
t.setNote(v.get("note1") + " " + v.get("note2"));
Expand Down

0 comments on commit 1e4e187

Please sign in to comment.