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

Improve Bigbank PDF importer #3894

Merged
merged 1 commit into from
Apr 4, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading