Skip to content

Commit

Permalink
Modify Solarisbank AG PDF-Importer to support new transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Nirus2000 committed Jan 19, 2025
1 parent 2326636 commit c8e148d
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
PDFBox Version: 1.8.17
Portfolio Performance Version: 0.73.0
System: macosx | x86_64 | 21.0.5+11-LTS | Azul Systems, Inc.
-----------------------------------------
yO. PaUJjtjmb eeTM VqQIwqA soJB
gKNyegeBZxo. DE74110101015790579546
53 BIC
96790 sDUYvLCB SOBKDEB2XXX
ERÖFFNUNGSDATUM
07.11.2024
RECHNUNGSDATUM
02.01.2025
KONTOAUSZUG ERÖFFNUNGSBILANZ ABSCHLUSSSALDO
07.11.2024 - 30.11.2024 0€ 3105.19€
Transaktionen Buchungsdatum Valutadatum
YLbKRus qXwsATAvg 08.11.2024 08.11.2024 3000€
EUWAX Aktiengesellschaft 10.11.2024 10.11.2024 -1000€
EUWAX Aktiengesellschaft 14.11.2024 14.11.2024 1105.19€
sMPghUOQW KOQy PbfeyvP 15.11.2024 15.11.2024 0.01€
UVOshYrqp ejDi CIXGqbX 15.11.2024 15.11.2024 -0.01€
Solaris SE Amtsgericht Charlottenburg HRB 168180 B Vorstand:
Cuvrystraße 53, 10997 Berlin Dr. Roland Folz (Vorsitzender),
+49 (0) 30 2325 678 900 Chloé Mayenobe, Dr. Jörg Howein, Thomas Rasser
[email protected] | www.solarisgroup.de Aufsichtsratsvorsitzender:
Ramin Niroumand
Solaris SE Amtsgericht Charlottenburg HRB 168180 B Vorstand:
Cuvrystraße 53, 10997 Berlin Dr. Roland Folz (Vorsitzender),
+49 (0) 30 2325 678 900 Chloé Mayenobe, Dr. Jörg Howein, Thomas Rasser
[email protected] | www.solarisgroup.de Aufsichtsratsvorsitzender:
Ramin Niroumand
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ public void testGiroKontoauszug01()
new AssertImportActions().check(results, CurrencyUnit.EUR);

// assert transaction
assertThat(results, hasItem(deposit(hasDate("2022-10-26"), hasAmount("EUR", 200), //
assertThat(results, hasItem(deposit(hasDate("2022-10-26"), hasAmount("EUR", 200.00), //
hasSource("GiroKontoauszug01.txt"), hasNote("008eb3a1d003 etoken-google"))));

// assert transaction
assertThat(results, hasItem(deposit(hasDate("2022-10-27"), hasAmount("EUR", 150), //
assertThat(results, hasItem(deposit(hasDate("2022-10-27"), hasAmount("EUR", 150.00), //
hasSource("GiroKontoauszug01.txt"), hasNote("a141b0b25f9d etoken-google"))));

// assert transaction
assertThat(results, hasItem(removal(hasDate("2022-10-26"), hasAmount("EUR", 100), //
assertThat(results, hasItem(removal(hasDate("2022-10-26"), hasAmount("EUR", 100.00), //
hasSource("GiroKontoauszug01.txt"), hasNote("an Peter Panzwischen Kunden DE11111111111111111111"))));

// assert transaction
Expand All @@ -79,7 +79,7 @@ public void testGiroKontoauszug02()
new AssertImportActions().check(results, CurrencyUnit.EUR);

// assert transaction
assertThat(results, hasItem(deposit(hasDate("2022-10-26"), hasAmount("EUR", 100), //
assertThat(results, hasItem(deposit(hasDate("2022-10-26"), hasAmount("EUR", 100.00), //
hasNote("von Peter Panzwischen Kunden DE11111111111111111111"))));
}

Expand Down Expand Up @@ -121,7 +121,7 @@ public void testGiroKontoauszug04()
new AssertImportActions().check(results, CurrencyUnit.EUR);

// assert transaction
assertThat(results, hasItem(deposit(hasDate("2022-10-03"), hasAmount("EUR", 200), //
assertThat(results, hasItem(deposit(hasDate("2022-10-03"), hasAmount("EUR", 200.00), //
hasSource("GiroKontoauszug04.txt"), hasNote("von Peter Pan"))));

// assert transaction
Expand All @@ -132,4 +132,41 @@ public void testGiroKontoauszug04()
assertThat(results, hasItem(removal(hasDate("2022-10-20"), hasAmount("EUR", 18.78), //
hasSource("GiroKontoauszug04.txt"), hasNote("an Peter Pan"))));
}

@Test
public void testReferenzkontoauszug01()
{
SolarisbankAGPDFExtractor extractor = new SolarisbankAGPDFExtractor(new Client());

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

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

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

// assert transaction
assertThat(results, hasItem(deposit(hasDate("2024-11-08"), hasAmount("EUR", 3000.00), //
hasSource("Referenzkontoauszug01.txt"), hasNote("YLbKRus qXwsATAvg"))));

// assert transaction
assertThat(results, hasItem(removal(hasDate("2024-11-10"), hasAmount("EUR", 1000.00), //
hasSource("Referenzkontoauszug01.txt"), hasNote("EUWAX Aktiengesellschaft"))));

// assert transaction
assertThat(results, hasItem(deposit(hasDate("2024-11-14"), hasAmount("EUR", 1105.19), //
hasSource("Referenzkontoauszug01.txt"), hasNote("EUWAX Aktiengesellschaft"))));

// assert transaction
assertThat(results, hasItem(deposit(hasDate("2024-11-15"), hasAmount("EUR", 0.01), //
hasSource("Referenzkontoauszug01.txt"), hasNote("sMPghUOQW KOQy PbfeyvP"))));

// assert transaction
assertThat(results, hasItem(removal(hasDate("2024-11-15"), hasAmount("EUR", 0.01), //
hasSource("Referenzkontoauszug01.txt"), hasNote("UVOshYrqp ejDi CIXGqbX"))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import static name.abuchen.portfolio.util.TextUtil.trim;

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.money.Values;

@SuppressWarnings("nls")
public class SolarisbankAGPDFExtractor extends AbstractPDFExtractor
Expand All @@ -19,6 +21,7 @@ public SolarisbankAGPDFExtractor(Client client)
addBankIdentifier("Solaris SE");

addAccountStatementTransaction();
addDepotStatementTransaction();
}

@Override
Expand Down Expand Up @@ -84,4 +87,61 @@ private void addAccountStatementTransaction()

.wrap(TransactionItem::new));
}

private void addDepotStatementTransaction()
{
final DocumentType type = new DocumentType("KONTOAUSZUG");
this.addDocumentTyp(type);

// @formatter:off
// YLbKRus qXwsATAvg 08.11.2024 08.11.2024 3000€
// EUWAX Aktiengesellschaft 14.11.2024 14.11.2024 1105.19€
// EUWAX Aktiengesellschaft 10.11.2024 10.11.2024 -1000€
// @formatter:on
Block depositRemovalBlock = new Block("^.* [\\d]{2}\\.[\\d]{2}\\.[\\d]{4} [\\d]{2}\\.[\\d]{2}\\.[\\d]{4} ([\\-])?[\\.,\\d]+\\p{Sc}$");
type.addBlock(depositRemovalBlock);
depositRemovalBlock.set(new Transaction<AccountTransaction>()

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

.section("note", "date", "type", "amount", "currency") //
.match("^(?<note>.*) [\\d]{2}\\.[\\d]{2}\\.[\\d]{4} (?<date>[\\d]{2}\\.[\\d]{2}\\.[\\d]{4})(?<type>[\\-\\s]+)(?<amount>[\\.,\\d]+)(?<currency>\\p{Sc})$") //
.assign((t, v) -> {
// @formatter:off
// Is type is "-" change from DEPOSIT to REMOVAL
// @formatter:on
if ("-".equals(trim(v.get("type"))))
t.setType(AccountTransaction.Type.REMOVAL);

t.setDateTime(asDate(v.get("date")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(asAmount(v.get("amount")));
t.setNote(trim(v.get("note")));
})

.wrap(TransactionItem::new));
}

@Override
protected long asAmount(String value)
{
String language = "de";
String country = "DE";

int lastDot = value.lastIndexOf(".");
int lastComma = value.lastIndexOf(",");

// returns the greater of two int values
if (Math.max(lastDot, lastComma) == lastDot)
{
language = "en";
country = "US";
}

return ExtractorUtils.convertToNumberLong(value, Values.Amount, language, country);
}
}

0 comments on commit c8e148d

Please sign in to comment.