diff --git a/name.abuchen.portfolio.tests/src/name/abuchen/portfolio/datatransfer/pdf/bigbank/BigbankPDFExtractorTest.java b/name.abuchen.portfolio.tests/src/name/abuchen/portfolio/datatransfer/pdf/bigbank/BigbankPDFExtractorTest.java new file mode 100644 index 0000000000..dfb80bdc52 --- /dev/null +++ b/name.abuchen.portfolio.tests/src/name/abuchen/portfolio/datatransfer/pdf/bigbank/BigbankPDFExtractorTest.java @@ -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 errors = new ArrayList<>(); + + List 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)))); + } +} diff --git a/name.abuchen.portfolio.tests/src/name/abuchen/portfolio/datatransfer/pdf/bigbank/Kontoauszug01.txt b/name.abuchen.portfolio.tests/src/name/abuchen/portfolio/datatransfer/pdf/bigbank/Kontoauszug01.txt new file mode 100644 index 0000000000..5fd2855c92 --- /dev/null +++ b/name.abuchen.portfolio.tests/src/name/abuchen/portfolio/datatransfer/pdf/bigbank/Kontoauszug01.txt @@ -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 kundenservice@bigbank.at +51004 Reg. Nr. 10183757 +www.bigbank.at VAT. Nr. EE100041383 +1 / 1 +Powered by TCPDF (www.tcpdf.org) + +``` \ No newline at end of file diff --git a/name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/BigbankPDFExtractor.java b/name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/BigbankPDFExtractor.java new file mode 100644 index 0000000000..d3db5fd305 --- /dev/null +++ b/name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/BigbankPDFExtractor.java @@ -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 (?[\\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() + + .subject(() -> { + AccountTransaction accountTransaction = new AccountTransaction(); + accountTransaction.setType(AccountTransaction.Type.DEPOSIT); + return accountTransaction; + }) + + .section("date", "amount") + .documentContext("currency") + .match("^(?[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}).*Einzahlung.*\\+(?[\\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() + + .subject(() -> { + AccountTransaction accountTransaction = new AccountTransaction(); + accountTransaction.setType(AccountTransaction.Type.REMOVAL); + return accountTransaction; + }) + + .section("date", "amount") // + .documentContext("currency") + .match("^(?[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}).*Auszahlung.*\\-(?[\\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)); + } +} diff --git a/name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/PDFImportAssistant.java b/name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/PDFImportAssistant.java index f2e0122e7a..c692332445 100644 --- a/name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/PDFImportAssistant.java +++ b/name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/PDFImportAssistant.java @@ -36,6 +36,7 @@ public PDFImportAssistant(Client client, List 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));