Skip to content

Commit 1efdc4a

Browse files
committed
Added check to ensure that only dividend transactions have an ex-date
Issue: #5439
1 parent 421a5f4 commit 1efdc4a

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

name.abuchen.portfolio/META-INF/services/name.abuchen.portfolio.checks.Check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ name.abuchen.portfolio.checks.impl.FixWrongTransfersCheck
1414
name.abuchen.portfolio.checks.impl.FixDepositsWithSecurityCheck
1515
name.abuchen.portfolio.checks.impl.NegativeExchangeRateCheck
1616
name.abuchen.portfolio.checks.impl.MissingTransactionDateCheck
17+
name.abuchen.portfolio.checks.impl.OnlyDividendsCanHaveExDateCheck
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package name.abuchen.portfolio.checks.impl;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
import name.abuchen.portfolio.checks.Check;
7+
import name.abuchen.portfolio.checks.Issue;
8+
import name.abuchen.portfolio.model.AccountTransaction;
9+
import name.abuchen.portfolio.model.Client;
10+
11+
public class OnlyDividendsCanHaveExDateCheck implements Check
12+
{
13+
@Override
14+
public List<Issue> execute(Client client)
15+
{
16+
var answer = new ArrayList<Issue>();
17+
18+
for (var account : client.getAccounts())
19+
{
20+
for (var tx : account.getTransactions())
21+
{
22+
if (tx.getExDate() != null && tx.getType() != AccountTransaction.Type.DIVIDENDS)
23+
{
24+
tx.setExDate(null);
25+
}
26+
}
27+
}
28+
29+
return answer;
30+
}
31+
}

0 commit comments

Comments
 (0)