diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/dialogs/transactions/AccountTransactionModel.java b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/dialogs/transactions/AccountTransactionModel.java index adf619ab36..c6c527160a 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/dialogs/transactions/AccountTransactionModel.java +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/dialogs/transactions/AccountTransactionModel.java @@ -13,6 +13,7 @@ import name.abuchen.portfolio.model.AccountTransaction; import name.abuchen.portfolio.model.Client; import name.abuchen.portfolio.model.Security; +import name.abuchen.portfolio.model.SecurityEvent; import name.abuchen.portfolio.model.Transaction; import name.abuchen.portfolio.money.CurrencyConverter; import name.abuchen.portfolio.money.CurrencyConverterImpl; @@ -151,6 +152,12 @@ public void applyChanges() Money.of(getSecurityCurrencyCode(), fxTaxes), // exchangeRate)); } + if (type == AccountTransaction.Type.DIVIDENDS) + { + SecurityEvent event = new SecurityEvent(date, SecurityEvent.Type.STOCK_DIVIDEND, Money.of(getFxCurrencyCode(), dividendAmount)); //$NON-NLS-1$ + security.addEvent(event); + } + } @Override diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/SecuritiesChart.java b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/SecuritiesChart.java index c1c4f1abfb..323ee7e044 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/SecuritiesChart.java +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/SecuritiesChart.java @@ -22,10 +22,13 @@ import org.swtchart.ISeries; import org.swtchart.ISeries.SeriesType; +import name.abuchen.portfolio.model.Account; +import name.abuchen.portfolio.model.AccountTransaction; import name.abuchen.portfolio.model.Client; import name.abuchen.portfolio.model.Portfolio; import name.abuchen.portfolio.model.PortfolioTransaction; import name.abuchen.portfolio.model.Security; +import name.abuchen.portfolio.model.SecurityEvent; import name.abuchen.portfolio.model.SecurityPrice; import name.abuchen.portfolio.money.CurrencyConverter; import name.abuchen.portfolio.money.Values; @@ -219,10 +222,21 @@ private void addChartMarker() } } + for (Account account : client.getAccounts()) + { + for (AccountTransaction t : account.getTransactions()) + { + if (t.getSecurity() == security && (chartPeriod == null || chartPeriod.isBefore(t.getDate())) && t.getType() == AccountTransaction.Type.DIVIDENDS) + { + Color color = Display.getDefault().getSystemColor(SWT.COLOR_DARK_CYAN); + chart.addMarkerLine(t.getDate(), color, t.getGrossValue().toString()); + } + } + } + security.getEvents().stream() // .filter(e -> chartPeriod == null || chartPeriod.isBefore(e.getDate())) // - .forEach(e -> chart.addMarkerLine(e.getDate(), - Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY), e.getDetails())); - + .forEach(e -> chart.addMarkerLine(e.getDate(), + Display.getDefault().getSystemColor(e.getType() == SecurityEvent.Type.STOCK_SPLIT ? SWT.COLOR_DARK_GRAY : SWT.COLOR_MAGENTA), e.getDetails())); } } diff --git a/name.abuchen.portfolio/src/name/abuchen/portfolio/model/SecurityEvent.java b/name.abuchen.portfolio/src/name/abuchen/portfolio/model/SecurityEvent.java index 982d842295..5e4c6538cc 100644 --- a/name.abuchen.portfolio/src/name/abuchen/portfolio/model/SecurityEvent.java +++ b/name.abuchen.portfolio/src/name/abuchen/portfolio/model/SecurityEvent.java @@ -3,11 +3,13 @@ import java.time.LocalDate; import java.util.ResourceBundle; +import name.abuchen.portfolio.money.Money; + public class SecurityEvent { public enum Type { - STOCK_SPLIT; + STOCK_SPLIT, STOCK_DIVIDEND; private static final ResourceBundle RESOURCES = ResourceBundle.getBundle("name.abuchen.portfolio.model.labels"); //$NON-NLS-1$ @@ -20,6 +22,7 @@ public String toString() private LocalDate date; private Type type; private String details; + private Money dividend; public SecurityEvent() { @@ -31,8 +34,18 @@ public SecurityEvent(LocalDate date, Type type, String details) this.date = date; this.type = type; this.details = details; + this.dividend = null; } + public SecurityEvent(LocalDate date, Type type, Money money) + { + this.date = date; + this.type = type; + this.dividend = money; + this.details = null; + } + + public LocalDate getDate() { return date; @@ -45,6 +58,12 @@ public Type getType() public String getDetails() { - return details; + if (details != null) { + return details; + } else { + // details == null + return dividend.toString(); + } } + } diff --git a/name.abuchen.portfolio/src/name/abuchen/portfolio/model/labels.properties b/name.abuchen.portfolio/src/name/abuchen/portfolio/model/labels.properties index 8cc0d1a12e..0e2699d74f 100644 --- a/name.abuchen.portfolio/src/name/abuchen/portfolio/model/labels.properties +++ b/name.abuchen.portfolio/src/name/abuchen/portfolio/model/labels.properties @@ -13,6 +13,7 @@ account.TRANSFER_IN = Transfer (Inbound) account.TRANSFER_OUT = Transfer (Outbound) event.STOCK_SPLIT = Stock Split +event.STOCK_DIVIDEND = Dividend Payment portfolio.BUY = Buy portfolio.DELIVERY_INBOUND = Delivery (Inbound) diff --git a/name.abuchen.portfolio/src/name/abuchen/portfolio/model/labels_de.properties b/name.abuchen.portfolio/src/name/abuchen/portfolio/model/labels_de.properties index f877e27f8b..70f8cdecb2 100644 --- a/name.abuchen.portfolio/src/name/abuchen/portfolio/model/labels_de.properties +++ b/name.abuchen.portfolio/src/name/abuchen/portfolio/model/labels_de.properties @@ -13,6 +13,7 @@ account.TRANSFER_IN = Umbuchung (Eingang) account.TRANSFER_OUT = Umbuchung (Ausgang) event.STOCK_SPLIT = Aktiensplit +event.STOCK_DIVIDEND = Dividendenzahlung portfolio.BUY = Kauf portfolio.DELIVERY_INBOUND = Einlieferung