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 ING DIBa PDF-Importer to support new transaction #3800

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,27 @@
PDFBox Version: 1.8.17
Portfolio Performance Version: 0.67.3
-----------------------------------------
ING-DiBa AG · 60628 Frankfurt am Main
Datum 31.05.2023
Herrn Auszugsnummer 5
ZeSZqBPmOO SzNRflx Eingeräumte Kontoüberziehung 500,00 Euro
dfsedfsefsef. 19 Alter Saldo 00,00 Euro
38009 puapgt Neuer Saldo 00,00 Euro
IBAN me78 5165 7390 8983 3859 90
BIC xqjomHSESxA
Seite 1 von 5
Girokonto Nummer 01403hh91642
Kontoauszug Mai 2023
Buchung Buchung / Verwendungszweck Betrag (EUR)
Valuta
03.05.2023 Entgelt EgumoUc -0,99
03.05.2023 GIROCARD 453500234221743 MONATLICHES ENTGELT GIROCARD
(DEBITKARTE)
Kunden-Information
Vorliegender Freistellungsauftrag 1.000,00
Verbrauchter Sparer-Pauschbetrag 0,00
Bitte beachten Sie auch die Hinweise auf der Folgeseite.
ING-DiBa AG
34GKKA5426920156_T
Bitte beachten Sie die nachstehenden Hinweise:
Kontoauszug ohne Rechnungsabschluss (Kontoübersicht)
@@ -0,0 +1,29 @@
PDFBox Version: 1.8.17
Portfolio Performance Version: 0.67.3
-----------------------------------------
ING-DiBa AG · 60628 Frankfurt am Main
Datum 30.04.2021
Herrn Auszugsnummer 4
CiDpQLkMDg JbfLExp Eingeräumte Kontoüberziehung 500,00 Euro
kOUoaYWmUwe MDiUVMC 938 Alter Saldo 00,00 Euro
11111 aaaaa Neuer Saldo 00,00 Euro
IBAN rU57 3065 2237 8024 5214 10
BIC uiUnlxYdZLV
Seite 1 von 4
Girokonto Nummer 7990087452
Kontoauszug April 2021
Buchung Buchung / Verwendungszweck Betrag (EUR)
Valuta

29.04.2021 Gehalt/Rente Hauptkasse des Freistaates Sachsen 806,83
29.04.2021 BEZUEGE 04.21
Referenz: 0137366062104100000000034544

Neuer Saldo 00,00
Kunden-Information
Vorliegender Freistellungsauftrag 300,00
Verbrauchter Sparer-Pauschbetrag 0,00
Bitte beachten Sie auch die Hinweise auf der Folgeseite.
ING-DiBa AG
34GKKA5426920156_T
Bitte beachten Sie die nachstehenden Hinweise:
@@ -1,7 +1,9 @@
package name.abuchen.portfolio.datatransfer.pdf.ingdiba;

import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.check;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.deposit;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.dividend;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.fee;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasAmount;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasCurrencyCode;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasDate;
Expand Down Expand Up @@ -3495,4 +3497,48 @@ public void testGiroKontoauszug02()
assertThat(transaction.getSource(), is("GiroKontoauszug02.txt"));
assertThat(transaction.getNote(), is("Kirchensteuer"));
}

@Test
public void testKGiroKontoauszug03()
{
INGDiBaPDFExtractor extractor = new INGDiBaPDFExtractor(new Client());

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

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

// assert transaction
assertThat(results, hasItem(fee(hasDate("2023-05-03"), hasAmount("EUR", 0.99), //
hasSource("GiroKontoauszug03.txt"), hasNote(null))));
}

@Test
public void testKGiroKontoauszug04()
{
INGDiBaPDFExtractor extractor = new INGDiBaPDFExtractor(new Client());

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

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

// assert transaction
assertThat(results, hasItem(deposit(hasDate("2021-04-29"), hasAmount("EUR", 806.83), //
hasSource("GiroKontoauszug04.txt"), hasNote("Gehalt/Rente"))));
}
}
Expand Up @@ -549,10 +549,12 @@ private void addAccountStatementTransaction()
// @formatter:off
// 27.06.2016 Gutschrift Max Mustermann 10.000,00
// 14.02.2020 Dauerauftrag/Terminueberw. Max Mustermann -30,00
// 29.04.2021 Gehalt/Rente Hauptkasse des Freistaates Sachsen 806,83
// @formatter:on
Block depositBlock = new Block("^[\\d]{2}\\.[\\d]{2}\\.[\\d]{4} " //
+ "(Gutschrift" //
+ "|Gutschrift\\/Dauerauftrag) " //
+ "|Gutschrift\\/Dauerauftrag"
+ "|Gehalt\\/Rente) " //
+ ".* [\\.,\\d]+$");
type.addBlock(depositBlock);
depositBlock.set(new Transaction<AccountTransaction>()
Expand All @@ -567,7 +569,8 @@ private void addAccountStatementTransaction()
.documentContext("currency") //
.match("^(?<date>[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}) " //
+ "(?<note>Gutschrift" //
+ "|Gutschrift\\/Dauerauftrag) " //
+ "|Gutschrift\\/Dauerauftrag"
+ "|Gehalt\\/Rente) " //
+ ".* (?<amount>[\\.,\\d]+)$") //
.assign((t, v) -> {
t.setDateTime(asDate(v.get("date")));
Expand Down Expand Up @@ -638,6 +641,30 @@ private void addAccountStatementTransaction()
t.setNote(v.get("note"));
})

.wrap(TransactionItem::new));

// @formatter:off
// 03.05.2023 Entgelt EgumoUc -0,99
// @formatter:on
Block feesBlock = new Block("^[\\d]{2}\\.[\\d]{2}\\.[\\d]{4} Entgelt .* \\-[\\.,\\d]+$");
type.addBlock(feesBlock);
feesBlock.set(new Transaction<AccountTransaction>()

.subject(() -> {
AccountTransaction accountTransaction = new AccountTransaction();
accountTransaction.setType(AccountTransaction.Type.FEES);
return accountTransaction;
})

.section("date", "amount") //
.documentContext("currency") //
.match("^(?<date>[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}) Entgelt .* \\-(?<amount>[\\.,\\d]+)$") //
.assign((t, v) -> {
t.setDateTime(asDate(v.get("date")));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(v.get("currency"));
})

.wrap(TransactionItem::new));
}

Expand Down