-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new Audi Bank PDF-Importer (#4324)
- Loading branch information
Showing
4 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
....tests/src/name/abuchen/portfolio/datatransfer/pdf/audibank/AudiBankPDFExtractorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package name.abuchen.portfolio.datatransfer.pdf.audibank; | ||
|
||
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.interest; | ||
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.taxes; | ||
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.AudiBankPDFExtractor; | ||
import name.abuchen.portfolio.datatransfer.pdf.PDFInputFile; | ||
import name.abuchen.portfolio.model.Client; | ||
import name.abuchen.portfolio.money.CurrencyUnit; | ||
|
||
@SuppressWarnings("nls") | ||
public class AudiBankPDFExtractorTest | ||
{ | ||
@Test | ||
public void testKontoauszug01() | ||
{ | ||
AudiBankPDFExtractor extractor = new AudiBankPDFExtractor(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(4L)); | ||
assertThat(results.size(), is(4)); | ||
new AssertImportActions().check(results, CurrencyUnit.EUR); | ||
|
||
// assert transaction | ||
assertThat(results, hasItem(interest(hasDate("2021-12-25"), hasAmount("EUR", 0.83), // | ||
hasSource("Kontoauszug01.txt"), hasNote(null)))); | ||
|
||
// assert transaction | ||
assertThat(results, hasItem(taxes(hasDate("2021-12-25"), hasAmount("EUR", 0.01), // | ||
hasSource("Kontoauszug01.txt"), hasNote(null)))); | ||
|
||
// assert transaction | ||
assertThat(results, hasItem(taxes(hasDate("2021-12-25"), hasAmount("EUR", 0.01), // | ||
hasSource("Kontoauszug01.txt"), hasNote(null)))); | ||
|
||
// assert transaction | ||
assertThat(results, hasItem(taxes(hasDate("2021-12-25"), hasAmount("EUR", 0.20), // | ||
hasSource("Kontoauszug01.txt"), hasNote(null)))); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...en.portfolio.tests/src/name/abuchen/portfolio/datatransfer/pdf/audibank/Kontoauszug01.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
PDFBox Version: 1.8.17 | ||
Portfolio Performance Version: 0.71.2 | ||
----------------------------------------- | ||
Audi Bank · 38093 Braunschweig | ||
VdmFnXH deSiV | ||
asddsfsf 243 | ||
13913 xVwIXDvEE Th QfnbVl | ||
Kontoauszug / Saldenmitteilung Plus Konto online.pur | ||
Kontonummer: 3363081904 Erstellungsdatum: 26.12.2021 | ||
Kontobezeichnung: YrRBg oHyEpik Kontoauszug Nummer: 000003 / 2021 | ||
Bankleitzahl: 27020001 Seite: 1 / 1 | ||
BIC: AUDFDE21XXX letzter Auszug vom: 25.11.2021 | ||
IBAN: DE57270200013363081904 Ihr Ansprechpartner: Team Anlageberatung | ||
Telefon-Durchwahl: 0531 212-859601 | ||
Alter Kontostand in EUR: 1.001,29 | ||
lfd. Buchungs- Umsatzinformationen Wertstellung Soll (EUR) Haben (EUR) | ||
Nr. datum | ||
Rechnungsabschluss 25.12.2021 | ||
1 23.12.2021 Habenzinsen 25.12.2021 0,83 | ||
2 23.12.2021 Solidaritätszuschlag 25.12.2021 -0,01 | ||
3 23.12.2021 Kirchensteuer 25.12.2021 -0,01 | ||
4 23.12.2021 Abgeltungsteuer 25.12.2021 -0,20 | ||
Neuer Kontostand in EUR: 1.001,90 | ||
Freistellungs- NV Gültig bis Gesamt- Verbleibender Abgeltungsteuer/ Solidaritäts- Kirchen- Kirchensteuer- | ||
auftrag zinserträge Freibetrag Kapitalertragsteuer zuschlag steuer Betrag | ||
EUR 0,00 Nein 00.00.0000 EUR 2,02 EUR 0,00 EUR 0,49 EUR 0,02 8,00 % EUR 0,02 | ||
Ihre Freistellungsdaten vom 23.12.2021 | ||
Genehmigung des Rechnungsabschlusses | ||
Einwendungen wegen Unrichtigkeit oder Unvollständigkeit des Rechnungsabschlusses müssen Sie spätestens vor Ablauf von sechs Wochen nach | ||
dessen Zugang erheben. Sofern Sie Ihre Einwendungen schriftlich oder - falls diese Form vereinbart ist - in Textform geltend machen, genügt die | ||
Absendung innerhalb der Sechs-Wochen-Frist. Sie können Ihre Einwendungen an die interne Revision der Volkswagen Bank GmbH, | ||
Gifhorner Str. 57, 38 112 Braunschweig, richten. Das Unterlassen rechtzeitiger Einwendungen gilt als Genehmigung des Rechnungsabschlusses. | ||
Bitte beachten Sie, dass Zinserträge einkommensteuerpflichtig sind. | ||
Guthaben sind als Einlagen nach Maßgabe des Einlagensicherungsgesetzes entschädigungsfähig. Nähere Informationen können dem "Informationsbogen für den Einleger" entnommen werden. | ||
206500 | ||
A // B // M |
91 changes: 91 additions & 0 deletions
91
name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/AudiBankPDFExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
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; | ||
|
||
@SuppressWarnings("nls") | ||
public class AudiBankPDFExtractor extends AbstractPDFExtractor | ||
{ | ||
public AudiBankPDFExtractor(Client client) | ||
{ | ||
super(client); | ||
|
||
addBankIdentifier("Audi Bank"); | ||
|
||
addAccountStatementTransaction(); | ||
} | ||
|
||
@Override | ||
public String getLabel() | ||
{ | ||
return "Audi Bank"; | ||
} | ||
|
||
|
||
private void addAccountStatementTransaction() | ||
{ | ||
final DocumentType type = new DocumentType("Kontoauszug / Saldenmitteilung", // | ||
documentContext -> documentContext // | ||
// @formatter:off | ||
// Alter Kontostand in EUR: 1.001,29 | ||
// @formatter:on | ||
.section("currency") // | ||
.match("^Alter Kontostand in (?<currency>[\\w]{3}):.*$") // | ||
.assign((ctx, v) -> ctx.put("currency", asCurrencyCode(v.get("currency"))))); | ||
|
||
this.addDocumentTyp(type); | ||
|
||
// @formatter:off | ||
// 1 23.12.2021 Habenzinsen 25.12.2021 0,83 | ||
// @formatter:on | ||
Block interestBlock = new Block("^[\\d]+ [\\d]{2}\\.[\\d]{2}\\.[\\d]{4} Habenzinsen [\\d]{2}\\.[\\d]{2}\\.[\\d]{4} [\\.,\\d]+$"); | ||
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("^[\\d]+ [\\d]{2}\\.[\\d]{2}\\.[\\d]{4} Habenzinsen (?<date>[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}) (?<amount>[\\.,\\d]+)$") | ||
.assign((t, v) -> { | ||
t.setDateTime(asDate(v.get("date"))); | ||
t.setAmount(asAmount(v.get("amount"))); | ||
t.setCurrencyCode(v.get("currency")); | ||
}) | ||
|
||
.wrap(TransactionItem::new)); | ||
|
||
// @formatter:off | ||
// 2 23.12.2021 Solidaritätszuschlag 25.12.2021 -0,01 | ||
// 3 23.12.2021 Kirchensteuer 25.12.2021 -0,01 | ||
// 4 23.12.2021 Abgeltungsteuer 25.12.2021 -0,20 | ||
// @formatter:on | ||
Block taxesBlock = new Block("^[\\d]+ [\\d]{2}\\.[\\d]{2}\\.[\\d]{4} (Solidarit.tszuschlag|Kirchensteuer|Abgeltungsteuer) [\\d]{2}\\.[\\d]{2}\\.[\\d]{4} \\-[\\.,\\d]+$"); | ||
type.addBlock(taxesBlock); | ||
taxesBlock.set(new Transaction<AccountTransaction>() | ||
|
||
.subject(() -> { | ||
AccountTransaction accountTransaction = new AccountTransaction(); | ||
accountTransaction.setType(AccountTransaction.Type.TAXES); | ||
return accountTransaction; | ||
}) | ||
|
||
.section("date", "amount") // | ||
.documentContext("currency") // | ||
.match("^[\\d]+ [\\d]{2}\\.[\\d]{2}\\.[\\d]{4} (Solidarit.tszuschlag|Kirchensteuer|Abgeltungsteuer) (?<date>[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}) \\-(?<amount>[\\.,\\d]+)$") // | ||
.assign((t, v) -> { | ||
t.setDateTime(asDate(v.get("date"))); | ||
t.setAmount(asAmount(v.get("amount"))); | ||
t.setCurrencyCode(v.get("currency")); | ||
}) | ||
|
||
.wrap(TransactionItem::new)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters