Skip to content

Commit 21396f0

Browse files
authored
Improve Debitum Investments PDF-Importer (#5778)
- Replace non-canonical wrap() returning null for zero-amount deposit/removal transactions with the canonical SkippedItem form including getCurrencyCode() != null guard - Add import name.abuchen.portfolio.Messages to the extractor - Update testAccountStatement02: adjust countSkippedItems from 0L to 2L and results.size() from 1 to 3 to reflect the two zero-amount DEPOSITS/WITHDRAWALS lines that are now correctly recorded as skipped items - Add two skippedItem(Messages.MsgErrorTransactionTypeNotSupportedOrRequired, deposit/removal(...)) assertions to testAccountStatement02 to explicitly verify the skipped zero-amount transactions - Add skippedItem, Messages imports to the test class
1 parent 1cf49ad commit 21396f0

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

name.abuchen.portfolio.tests/src/name/abuchen/portfolio/datatransfer/pdf/debituminvestments/DebitumPDFExtractorTest.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasTaxes;
1111
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.interest;
1212
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.removal;
13+
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.skippedItem;
1314
import static name.abuchen.portfolio.datatransfer.ExtractorTestUtilities.countAccountTransactions;
1415
import static name.abuchen.portfolio.datatransfer.ExtractorTestUtilities.countAccountTransfers;
1516
import static name.abuchen.portfolio.datatransfer.ExtractorTestUtilities.countBuySell;
@@ -26,6 +27,7 @@
2627

2728
import org.junit.Test;
2829

30+
import name.abuchen.portfolio.Messages;
2931
import name.abuchen.portfolio.datatransfer.actions.AssertImportActions;
3032
import name.abuchen.portfolio.datatransfer.pdf.DebitumInvestmentsPDFExtractor;
3133
import name.abuchen.portfolio.datatransfer.pdf.PDFInputFile;
@@ -84,10 +86,22 @@ public void testAccountStatement02()
8486
assertThat(countAccountTransactions(results), is(1L));
8587
assertThat(countAccountTransfers(results), is(0L));
8688
assertThat(countItemsWithFailureMessage(results), is(0L));
87-
assertThat(countSkippedItems(results), is(0L));
88-
assertThat(results.size(), is(1));
89+
assertThat(countSkippedItems(results), is(2L));
90+
assertThat(results.size(), is(3));
8991
new AssertImportActions().check(results, "EUR");
9092

93+
// check skipped item (DEPOSITS = 0.0)
94+
assertThat(results, hasItem(skippedItem( //
95+
Messages.MsgErrorTransactionTypeNotSupportedOrRequired, //
96+
deposit(hasDate("2025-12-17"), hasAmount("EUR", 0.00), //
97+
hasSource("AccountStatement02.txt"), hasNote(null)))));
98+
99+
// check skipped item (WITHDRAWALS = 0.0)
100+
assertThat(results, hasItem(skippedItem( //
101+
Messages.MsgErrorTransactionTypeNotSupportedOrRequired, //
102+
removal(hasDate("2025-12-17"), hasAmount("EUR", 0.00), //
103+
hasSource("AccountStatement02.txt"), hasNote(null)))));
104+
91105
// assert transaction
92106
assertThat(results, hasItem(interest( //
93107
hasDate("2025-12-17"), //

name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/DebitumInvestmentsPDFExtractor.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package name.abuchen.portfolio.datatransfer.pdf;
22

3+
import name.abuchen.portfolio.Messages;
34
import name.abuchen.portfolio.datatransfer.ExtractorUtils;
45
import name.abuchen.portfolio.datatransfer.pdf.PDFParser.Block;
56
import name.abuchen.portfolio.datatransfer.pdf.PDFParser.DocumentType;
@@ -74,9 +75,10 @@ private void addAccountStatementTransaction()
7475
})
7576

7677
.wrap(t -> {
77-
if (t.getAmount() != 0)
78-
return new TransactionItem(t);
79-
return null;
78+
if (t.getCurrencyCode() != null && t.getAmount() == 0)
79+
return new SkippedItem(new TransactionItem(t), Messages.MsgErrorTransactionTypeNotSupportedOrRequired);
80+
81+
return new TransactionItem(t);
8082
}));
8183

8284
// @formatter:off

0 commit comments

Comments
 (0)