Skip to content

Commit

Permalink
Added PDF importer for Bigbank
Browse files Browse the repository at this point in the history
  • Loading branch information
MonkeySon authored and Nirus2000 committed Mar 27, 2024
1 parent 051a96f commit 22ae258
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package name.abuchen.portfolio.datatransfer.pdf.bigbank;

import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.deposit;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasAmount;
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.removal;
import static name.abuchen.portfolio.datatransfer.ExtractorTestUtilities.countAccountTransactions;
import static name.abuchen.portfolio.datatransfer.ExtractorTestUtilities.countBuySell;
import static name.abuchen.portfolio.datatransfer.ExtractorTestUtilities.countSecurities;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.collection.IsEmptyCollection.empty;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

import name.abuchen.portfolio.datatransfer.Extractor.Item;
import name.abuchen.portfolio.datatransfer.actions.AssertImportActions;
import name.abuchen.portfolio.datatransfer.pdf.BigbankPDFExtractor;
import name.abuchen.portfolio.datatransfer.pdf.PDFInputFile;
import name.abuchen.portfolio.model.Client;
import name.abuchen.portfolio.money.CurrencyUnit;

@SuppressWarnings("nls")
public class BigbankPDFExtractorTest
{
@Test
public void testKontoauszug01()
{
BigbankPDFExtractor extractor = new BigbankPDFExtractor(new Client());

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

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

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

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

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

// assert transaction
assertThat(results, hasItem(removal(hasDate("2024-03-25"), hasAmount("EUR", 10.00), //
hasSource("Kontoauszug01.txt"), hasNote(null))));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
```
PDFBox Version: 1.8.17
Portfolio Performance Version: 0.68.3
-----------------------------------------
26.03.2024
tedj yGBqfR MusjIylOz
pnLTPRWhlvLQRQip 06
2242 PyWc
vBRjZIShrz
Tagesgeldvertrag SD-ATC-55443596
Kontoauszug von 01.03.2024 bis 25.03.2024
IBAN: EE123456789101112131
Anfangssaldo 01.03.2024 0,00
Datum Gegenkonto Buchung Name Betrag in EUR
20.03.2024 AT123456789101112131 Einzahlung ffIpWotyu dJMdyU +10,00
21.03.2024 AT123456789101112131 Einzahlung oDkoRVZEb TxDUxE +1 500,00
25.03.2024 AT123456789101112131 Auszahlung sUBHAKqzf vNNKxT -10,00
Endsaldo 25.03.2024 1 500,00
Anfangssaldo 01.03.2024 0,00
Summe Belastungen -10,00
Summe Gutschriften +1 510,00
Endsaldo 25.03.2024 1 500,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
@@ -0,0 +1,88 @@
package name.abuchen.portfolio.datatransfer.pdf;

import name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block;
import name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType;
import name.abuchen.portfolio.datatransfer.pdf.PDFParser.Transaction;
import name.abuchen.portfolio.model.AccountTransaction;
import name.abuchen.portfolio.model.Client;
import name.abuchen.portfolio.util.TextUtil;

@SuppressWarnings("nls")
public class BigbankPDFExtractor extends AbstractPDFExtractor
{
public BigbankPDFExtractor(Client client)
{
super(client);

addBankIdentifier("BIGBANK AS");

addAccountStatementTransaction();
}

@Override
public String getLabel()
{
return "Bigbank AS";
}


private void addAccountStatementTransaction()
{
final DocumentType type = new DocumentType("Kontoauszug",
documentContext -> documentContext
// @formatter:off
// Datum Gegenkonto Buchung Name Betrag in EUR
// @formatter:on
.section("currency") //
.match("^.*Betrag in (?<currency>[\\w]{3}).*$") //
.assign((ctx, v) -> ctx.put("currency", asCurrencyCode(v.get("currency")))));

this.addDocumentTyp(type);

// @formatter:off
// 21.03.2024 AT123456789101112131 Einzahlung oDkoRVZEb TxDUxE +1 500,00
// @formatter:on
Block depositBlock = new Block("^[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}.*Einzahlung.*\\+[\\d\\s]+\\,[\\d]{2}$");
type.addBlock(depositBlock);
depositBlock.set(new Transaction<AccountTransaction>()

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

.section("date", "amount")
.documentContext("currency")
.match("^(?<date>[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}).*Einzahlung.*\\+(?<amount>[\\d\\s]+\\,[\\d]{2})$")
.assign((t, v) -> {
t.setDateTime(asDate(v.get("date")));
t.setAmount(asAmount(TextUtil.stripBlanks(v.get("amount"))));
t.setCurrencyCode(v.get("currency"));
})
.wrap(TransactionItem::new));

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

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

.section("date", "amount") //
.documentContext("currency")
.match("^(?<date>[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}).*Auszahlung.*\\-(?<amount>[\\d\\s]+,[\\d]{2}).*$")
.assign((t, v) -> {
t.setDateTime(asDate(v.get("date")));
t.setAmount(asAmount(TextUtil.stripBlanks(v.get("amount"))));
t.setCurrencyCode(v.get("currency"));
})
.wrap(TransactionItem::new));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public PDFImportAssistant(Client client, List<File> files)
extractors.add(new Bank11PDFExtractor(client));
extractors.add(new BankSLMPDFExtractor(client));
extractors.add(new BarclaysBankIrelandPLCPDFExtractor(client));
extractors.add(new BigbankPDFExtractor(client));
extractors.add(new BisonPDFExtractor(client));
extractors.add(new BondoraCapitalPDFExtractor(client));
extractors.add(new ComdirectPDFExtractor(client));
Expand Down

0 comments on commit 22ae258

Please sign in to comment.