Skip to content

Commit

Permalink
Improve BigBank PDF Importer (#4513)
Browse files Browse the repository at this point in the history
Add support for interest transaction "Zinsgutschrift"
  • Loading branch information
MonkeySon authored Feb 6, 2025
1 parent 368cd91 commit 4a57a60
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasDate;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasNote;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasSource;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.interest;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.removal;
import static name.abuchen.portfolio.datatransfer.ExtractorTestUtilities.countAccountTransactions;
import static name.abuchen.portfolio.datatransfer.ExtractorTestUtilities.countBuySell;
Expand Down Expand Up @@ -90,4 +91,25 @@ public void testKontoauszug02()
assertThat(results, hasItem(removal(hasDate("2024-03-28"), hasAmount("EUR", 3500.00), //
hasSource("Kontoauszug02.txt"), hasNote(null))));
}

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

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

List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "Kontoauszug03.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(interest(hasDate("2024-12-31"), hasAmount("EUR", 99.01), //
hasSource("Kontoauszug03.txt"), hasNote(null))));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
```
PDFBox Version: 3.0.3 != 1.8.17
Portfolio Performance Version: 0.74.0
System: win32 | x86_64 | 21.0.5+11-LTS | Azul Systems, Inc.
-----------------------------------------

30.01.2025
SxLm xsCrPa DnuCCBpQY
nhCgNxTQJpkTacKQ 30
6717 WkqT
nRIffyzcUp
Tagesgeldvertrag SD-ATC-36285392
Kontoauszug von 01.12.2024 bis 31.12.2024
IBAN: EE123456789101112131
Anfangssaldo 01.12.2024 163,98
Datum Gegenkonto Buchung Name Betrag in EUR
31.12.2024 Zinsgutschrift +99,01
Endsaldo 31.12.2024 262,99
Anfangssaldo 01.12.2024 163,98
Summe Belastungen -0,00
Summe Gutschriften +99,01
Endsaldo 31.12.2024 262,99
Dies ist ein automatisch generierter Kontoauszug.
BIGBANK AS Telefon 0810 900 629
Riia 2, Tartu E-mail kundenservice@bigbank.at
64967 Reg. Nr. 81505659
www.bigbank.at VAT. Nr. FG349272663
1 / 1
Powered by PDF Generator API

```
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,30 @@ private void addAccountStatementTransaction()
t.setCurrencyCode(v.get("currency"));
})

.wrap(TransactionItem::new));

// @formatter:off
// 31.12.2024 Zinsgutschrift +99,01
// @formatter:on
Block interestBlock = new Block("^[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}.*Zinsgutschrift.* \\+[\\.,\\d\\s]+$");
type.addBlock(interestBlock);
interestBlock.set(new Transaction<AccountTransaction>()

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

.section("date", "amount") //
.documentContext("currency") //
.match("^(?<date>[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}).*Zinsgutschrift.* \\+(?<amount>[\\.,\\d\\s]+)$") //
.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

0 comments on commit 4a57a60

Please sign in to comment.