Skip to content

Commit

Permalink
Improve BigBank PDF-Importer
Browse files Browse the repository at this point in the history
Issue #3884
  • Loading branch information
Nirus2000 committed Mar 27, 2024
1 parent 22ae258 commit b68ddc4
Showing 1 changed file with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package name.abuchen.portfolio.datatransfer.pdf;

import name.abuchen.portfolio.datatransfer.ExtractorUtils;
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;
import name.abuchen.portfolio.money.Values;

@SuppressWarnings("nls")
public class BigbankPDFExtractor extends AbstractPDFExtractor
Expand Down Expand Up @@ -42,7 +43,7 @@ private void addAccountStatementTransaction()
// @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}$");
Block depositBlock = new Block("^[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}.*Einzahlung.* \\+[\\.,\\d\\s]+$");
type.addBlock(depositBlock);
depositBlock.set(new Transaction<AccountTransaction>()

Expand All @@ -52,20 +53,21 @@ private void addAccountStatementTransaction()
return accountTransaction;
})

.section("date", "amount")
.documentContext("currency")
.match("^(?<date>[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}).*Einzahlung.*\\+(?<amount>[\\d\\s]+\\,[\\d]{2})$")
.section("date", "amount") //
.documentContext("currency") //
.match("^(?<date>[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}).*Einzahlung.* \\+(?<amount>[\\.,\\d\\s]+)$") //
.assign((t, v) -> {
t.setDateTime(asDate(v.get("date")));
t.setAmount(asAmount(TextUtil.stripBlanks(v.get("amount"))));
t.setAmount(asAmount(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}.*$");
Block removalBlock = new Block("^[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}.*Auszahlung.* \\-[\\.,\\d\\s]+$");
type.addBlock(removalBlock);
removalBlock.set(new Transaction<AccountTransaction>()

Expand All @@ -76,13 +78,20 @@ private void addAccountStatementTransaction()
})

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

.wrap(TransactionItem::new));
}

@Override
protected long asAmount(String value)
{
return ExtractorUtils.convertToNumberLong(value, Values.Amount, "de", "CH");
}
}

0 comments on commit b68ddc4

Please sign in to comment.