use of name.abuchen.portfolio.model.SecurityEvent in project portfolio by buchen.
the class SecurityListView method createEventsTable.
// //////////////////////////////////////////////////////////////
// tab item: transactions
// //////////////////////////////////////////////////////////////
protected Composite createEventsTable(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
events = new TableViewer(container, SWT.FULL_SELECTION);
ShowHideColumnHelper support = new // $NON-NLS-1$
ShowHideColumnHelper(// $NON-NLS-1$
SecurityListView.class.getSimpleName() + "@events", getPreferenceStore(), events, layout);
Column column = new Column(Messages.ColumnDate, SWT.None, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return Values.Date.format(((SecurityEvent) element).getDate());
}
});
column.setSorter(ColumnViewerSorter.create(e -> ((SecurityEvent) e).getDate()), SWT.UP);
support.addColumn(column);
column = new Column(Messages.ColumnTransactionType, SWT.None, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((SecurityEvent) element).getType().toString();
}
});
support.addColumn(column);
column = new Column(Messages.ColumnDetails, SWT.None, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((SecurityEvent) element).getDetails();
}
});
support.addColumn(column);
support.createColumns();
events.getTable().setHeaderVisible(true);
events.getTable().setLinesVisible(true);
events.setContentProvider(ArrayContentProvider.getInstance());
return container;
}
use of name.abuchen.portfolio.model.SecurityEvent in project portfolio by buchen.
the class StockSplitModel method applyChanges.
@Override
public void applyChanges() {
// $NON-NLS-1$
SecurityEvent event = new SecurityEvent(exDate, SecurityEvent.Type.STOCK_SPLIT, newShares + ":" + oldShares);
security.addEvent(event);
if (isChangeTransactions()) {
List<TransactionPair<?>> transactions = security.getTransactions(getClient());
for (TransactionPair<?> pair : transactions) {
Transaction t = pair.getTransaction();
if (t.getDateTime().toLocalDate().isBefore(exDate))
t.setShares(t.getShares() * newShares / oldShares);
}
}
if (isChangeHistoricalQuotes()) {
List<SecurityPrice> quotes = security.getPrices();
for (SecurityPrice p : quotes) {
if (p.getDate().isBefore(exDate))
p.setValue(p.getValue() * oldShares / newShares);
}
}
}
Aggregations