Skip to content

Commit

Permalink
Improve Bigbank PDF importer
Browse files Browse the repository at this point in the history
* Added support for transaction type "Interne Belastung"
  • Loading branch information
MonkeySon committed Apr 1, 2024
1 parent 1b899ba commit b9b10bf
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,37 @@ public void testKontoauszug01()
assertThat(results, hasItem(removal(hasDate("2024-03-25"), hasAmount("EUR", 10.12), //
hasSource("Kontoauszug01.txt"), hasNote(null))));
}

@Test
public void testKontoauszug02()
{
BigbankPDFExtractor extractor = new BigbankPDFExtractor(new Client());

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

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

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

// assert transaction
assertThat(results, hasItem(deposit(hasDate("2024-03-20"), hasAmount("EUR", 10.00), //
hasSource("Kontoauszug02.txt"), hasNote(null))));

// assert transaction
assertThat(results, hasItem(deposit(hasDate("2024-03-21"), hasAmount("EUR", 10500.00), //
hasSource("Kontoauszug02.txt"), hasNote(null))));

// assert transaction
assertThat(results, hasItem(removal(hasDate("2024-03-25"), hasAmount("EUR", 10.00), //
hasSource("Kontoauszug02.txt"), hasNote(null))));

// assert transaction
assertThat(results, hasItem(removal(hasDate("2024-03-28"), hasAmount("EUR", 3500.00), //
hasSource("Kontoauszug02.txt"), hasNote(null))));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
```
PDFBox Version: 1.8.17
Portfolio Performance Version: 0.68.3
-----------------------------------------
01.04.2024
tyFY kJRhzK MNFKoXDym
XYJuNusQOtCEvbPy 59
3951 nzHW
qSUUJWYLLx
Tagesgeldvertrag SD-ATC-01331910
Kontoauszug von 01.03.2024 bis 31.03.2024
IBAN: EE123456789101112131
Anfangssaldo 01.03.2024 0,00
Datum Gegenkonto Buchung Name Betrag in EUR
20.03.2024 AT123456789101112131 Einzahlung EEVtAWeOf irRZwa +10,00
21.03.2024 AT123456789101112131 Einzahlung eGuACSyzF yuNzvi +10 500,00
25.03.2024 AT123456789101112131 Auszahlung rCVrxYZph CHeMVH -10,00
28.03.2024 EE123456789101112132 Interne Belastung wMGSJi WajHthpvl -3 500,00
Endsaldo 31.03.2024 7 000,00
Anfangssaldo 01.03.2024 0,00
Summe Belastungen -3 510,00
Summe Gutschriften +10 510,00
Endsaldo 31.03.2024 7 000,00
Dies ist ein automatisch generierter Kontoauszug.
BIGBANK AS Telefon 0810 900 629
Riia 2, Tartu E-mail [email protected]
51004 Reg. Nr. 10183757
www.bigbank.at VAT. Nr. EE100041383
1 / 1
Powered by TCPDF (www.tcpdf.org)

```
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private void addAccountStatementTransaction()
this.addDocumentTyp(type);

// @formatter:off
// 21.03.2024 AT123456789101112131 Einzahlung oDkoRVZEb TxDUxE +1 500,00
// 21.03.2024 AT123456789101112131 Einzahlung oDkoRVZEb TxDUxE +1 500,34
// @formatter:on
Block depositBlock = new Block("^[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}.*Einzahlung.* \\+[\\.,\\d\\s]+$");
type.addBlock(depositBlock);
Expand All @@ -65,9 +65,11 @@ private void addAccountStatementTransaction()
.wrap(TransactionItem::new));

// @formatter:off
// 25.03.2024 AT123456789101112131 Auszahlung sUBHAKqzf vNNKxT -10,00
// 25.03.2024 AT123456789101112131 Auszahlung sUBHAKqzf vNNKxT -10,12
// 28.03.2024 EE123456789101112132 Interne Belastung wMGSJi WajHthpvl -3 500,00
// @formatter:on
Block removalBlock = new Block("^[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}.*Auszahlung.* \\-[\\.,\\d\\s]+$");
Block removalBlock = new Block(
"^[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}.*(Auszahlung|Interne Belastung).* \\-[\\.,\\d\\s]+$");
type.addBlock(removalBlock);
removalBlock.set(new Transaction<AccountTransaction>()

Expand All @@ -79,7 +81,7 @@ private void addAccountStatementTransaction()

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

0 comments on commit b9b10bf

Please sign in to comment.