Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package name.abuchen.portfolio.datatransfer.pdf.kbcgroupnv;

import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.deposit;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.dividend;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasAmount;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasCurrencyCode;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasDate;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasFees;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasForexGrossValue;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasGrossValue;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasIsin;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasName;
Expand Down Expand Up @@ -225,4 +227,67 @@ public void testRekeninguittreksel01()
assertThat(results, hasItem(removal(hasDate("2024-09-04"), hasAmount("EUR", 32339.70), //
hasSource("Rekeninguittreksel01.txt"), hasNote("Overschrijving naar klant"))));
}

@Test
public void testRekeninguittreksel02()
{
KBCGroupNVPDFExtractor extractor = new KBCGroupNVPDFExtractor(new Client());

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

List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "Rekeninguittreksel02.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(deposit(hasDate("2022-08-18"), hasAmount("EUR", 50000.00), //
hasSource("Rekeninguittreksel02.txt"), hasNote("Provisionering rekening klant"))));
}

@Test
public void testRekeninguittreksel03()
{
KBCGroupNVPDFExtractor extractor = new KBCGroupNVPDFExtractor(new Client());

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

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

assertThat(errors, empty());
assertThat(countSecurities(results), is(1L));
assertThat(countBuySell(results), is(1L));
assertThat(countAccountTransactions(results), is(2L));
assertThat(results.size(), is(4));
new AssertImportActions().check(results, "EUR", "USD");

// check security
assertThat(results, hasItem(security( //
hasIsin("IE00BKM4GZ66"), hasWkn(null), hasTicker(null), //
hasName("ISHARES PLC CORE MSC E.M.IM UC"), //
hasCurrencyCode("EUR"))));

// check buy sell transaction
assertThat(results, hasItem(sale( //
hasDate("2023-06-12T11:55:21"), hasShares(2300.00), //
hasSource("Rekeninguittreksel03.txt"), //
hasNote("Borderel 017462864"), //
hasAmount("USD", 69606.12), hasGrossValue("USD", 69743.43), //
hasForexGrossValue("EUR", 64918.22), //
hasTaxes("USD", (78.06 / 0.932651)), hasFees("USD", (50.00 / 0.932651)))));

// assert transaction
assertThat(results, hasItem(deposit(hasDate("2023-06-12"), hasAmount("EUR", 45000.00), //
hasSource("Rekeninguittreksel03.txt"), hasNote("Provisionering rekening klant"))));

// assert transaction
assertThat(results, hasItem(deposit(hasDate("2023-06-12"), hasAmount("EUR", 132673.91), //
hasSource("Rekeninguittreksel03.txt"), hasNote("Provisionering rekening klant"))));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
PDFBox Version: 1.8.17
Portfolio Performance Version: 0.71.2
-----------------------------------------
mYWICNAN-ffIFTWit rjpnOt TWYfCFpM-koyXdfc
tNlrzb
Overzicht transacties en rekeninguittreksels voor klantnummer 0964124
18/08/2022
EUR-REKENING - 6
Rekeninguittreksel Nr 5 Vorig Saldo: 2.450,91 EUR
18/08/2022 Provisionering rekening klant Valuta 17/08/2022 50.000,00 EUR
Mededeling: wXFGAEmx-yDDlwpCK V + C
Nieuw Saldo 52.450,91 EUR
Dit deposito komt in aanmerking voor depositobescherming. Meer info: www.kbc.be/depositobescherming
YaNvmsru-GHhLuMii XOzWOG wrbkcVpO-fwqfYhz GjWQoo Pagina 1
0964124
_______________________________________________________________________________________
KBC BANK NV Documentreferte: 6
Havenlaan 2, 1080 Brussels, Belgium VAT BE 0462.920.226
Account N° BE77 4096 5474 0142 - BIC KREDBEBB
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
PDFBox Version: 1.8.17
Portfolio Performance Version: 0.71.2
-----------------------------------------
IPWFSVCs-rZgJERYI GMQcGr cymcYnij-SynWcel
HRYvzB
Overzicht transacties en rekeninguittreksels voor klantnummer 0964124
12/06/2023
EUR-REKENING - 30
Rekeninguittreksel Nr 25 Vorig Saldo: 2.284,27 EUR
12/06/2023 Provisionering rekening klant Valuta 12/06/2023 45.000,00 EUR
eQpiFBGUAS: hCMysjNX-inibtnxb V + C
12/06/2023 Provisionering rekening klant Valuta 12/06/2023 132.673,91 EUR
Mededeling: CFRyrSqp-vVYKXZKc V + C
Nieuw Saldo 179.958,18 EUR
Dit deposito komt in aanmerking voor depositobescherming. Meer info: www.kbc.be/depositobescherming
pmzhGIum-CtGGMNMT WQzXXw vJoLnahg-iZkkhOk BWaUyO Pagina 1
0964124
_______________________________________________________________________________________
KBC BANK NV Documentreferte: 30
Havenlaan 2, 1080 Brussels, Belgium VAT BE 0462.920.226
Account N° BE77 4096 5474 0142 - BIC KREDBEBB
USD-REKENING - 1
Borderel 017462864 Limit order
12/06/2023 11:55:21 Valuta 14/06/2023 MSEU
Uw Verkoop Online van 2.300 ISHARES PLC CORE MSC E.M.IM UC aan 28,281 65.046,30 EUR
EUR
Makelaarsloon 50,00 EUR
Beurstaks 78,06 EUR
Netto 64.918,24 EUR
1 USD = 0,932651 EUR
Netto credit 69.606,12 USD
Wettelijke fiscale informatie Basisbedrag beurstaks 65.046,30 EUR
Beurstaks 0,12% 78,06 EUR
Waardecode IE00BKM4GZ66
eJopUQSI-ZCowhiKu CQoHLc qDJXdQrR-SQNJxQD HhjKWM Pagina 2
0964124
_______________________________________________________________________________________
KBC BANK NV Documentreferte: 30
Havenlaan 2, 1080 Brussels, Belgium VAT BE 0462.920.226
Account N° BE77 4096 5474 0142 - BIC KREDBEBB
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package name.abuchen.portfolio.datatransfer.pdf;

import static name.abuchen.portfolio.datatransfer.ExtractorUtils.checkAndSetGrossUnit;
import static name.abuchen.portfolio.util.TextUtil.trim;

import java.math.BigDecimal;

import name.abuchen.portfolio.datatransfer.ExtrExchangeRate;
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.BuySellEntry;
import name.abuchen.portfolio.model.Client;
import name.abuchen.portfolio.model.PortfolioTransaction;
import name.abuchen.portfolio.money.Money;
import name.abuchen.portfolio.money.Values;

@SuppressWarnings("nls")
Expand Down Expand Up @@ -196,13 +200,32 @@ private void addBuySellTransaction()
t.setAmount(asAmount(v.get("amount")));
})

// @formatter:off
// 1 USD = 0,932651 EUR
// Netto credit 69.606,12 USD
// @formatter:on
.section("termCurrency", "exchangeRate", "baseCurrency", "gross").optional() //
.match("^[\\.,\\d]+ (?<baseCurrency>[\\w]{3}) = (?<exchangeRate>[\\.,\\d]+) (?<termCurrency>[\\w]{3})$") //
.match("^Netto (debit|credit) (\\-)?(?<gross>[\\.,\\d]+) [\\w]{3}$") //
.assign((t, v) -> {
ExtrExchangeRate rate = asExchangeRate(v);
type.getCurrentContext().putType(rate);

Money gross = Money.of(rate.getBaseCurrency(), asAmount(v.get("gross")));
Money fxGross = rate.convert(rate.getTermCurrency(), gross);

checkAndSetGrossUnit(gross, fxGross, t, type.getCurrentContext());
})

// @formatter:off
// Borderel 275825809 Limit order
// @formatter:on
.section("note").optional() //
.match("^(?<note>Borderel [\\d]+).*$") //
.assign((t, v) -> t.setNote(trim(v.get("note"))))

.conclude(ExtractorUtils.fixGrossValueBuySell())

.wrap(BuySellEntryItem::new);

addTaxesSectionsTransaction(pdfTransaction, type);
Expand Down Expand Up @@ -281,11 +304,40 @@ private void addAccountStatementTransaction()
final DocumentType type = new DocumentType("Rekeninguittreksel Nr");
this.addDocumentTyp(type);

// @formatter:off
// 18/08/2022 Provisionering rekening klant Valuta 17/08/2022 50.000,00 EUR
// @formatter:on
Block depositBlock = new Block("^[\\d]{2}\\/[\\d]{2}\\/[\\d]{4} Provisionering rekening klant.*$");
type.addBlock(depositBlock);
depositBlock.setMaxSize(1);
depositBlock.set(new Transaction<AccountTransaction>()

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

.section("date", "note", "amount", "currency") //
.match("^(?<date>[\\d]{2}\\/[\\d]{2}\\/[\\d]{4}) " //
+ "(?<note>Provisionering rekening klant) " //
+ "Valuta [\\d]{2}\\/[\\d]{2}\\/[\\d]{4} " //
+ "(?<amount>[\\.,\\d]+) (?<currency>[\\w]{3})$") //
.assign((t, v) -> {
t.setDateTime(asDate(v.get("date")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(asAmount(v.get("amount")));
t.setNote(v.get("note"));
})

.wrap(TransactionItem::new));

// @formatter:off
// 04/09/2024 Overschrijving naar klant Valuta 04/09/2024 -32.339,70 EUR
// @formatter:on
Block removalBlock = new Block("^[\\d]{2}\\/[\\d]{2}\\/[\\d]{4} Overschrijving naar klant.*$");
type.addBlock(removalBlock);
removalBlock.setMaxSize(1);
removalBlock.set(new Transaction<AccountTransaction>()

.subject(() -> {
Expand Down